Commit b0fadf7f authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[regexp] Expose RegExp::NewWithBacktrackLimit through the API

Bug: v8:9695
Change-Id: I401a18c84a9ec1af7e14f44004a0788cbfd4a34b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1864657Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64501}
parent b71af5c3
...@@ -5739,6 +5739,15 @@ class V8_EXPORT RegExp : public Object { ...@@ -5739,6 +5739,15 @@ class V8_EXPORT RegExp : public Object {
Local<String> pattern, Local<String> pattern,
Flags flags); Flags flags);
/**
* Like New, but additionally specifies a backtrack limit. If the number of
* backtracks done in one Exec call hits the limit, a match failure is
* immediately returned.
*/
static V8_WARN_UNUSED_RESULT MaybeLocal<RegExp> NewWithBacktrackLimit(
Local<Context> context, Local<String> pattern, Flags flags,
uint32_t backtrack_limit);
/** /**
* Returns the value of the source property: a string representing * Returns the value of the source property: a string representing
* the regular expression. * the regular expression.
......
...@@ -6617,6 +6617,21 @@ MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context, ...@@ -6617,6 +6617,21 @@ MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context,
RETURN_ESCAPED(result); RETURN_ESCAPED(result);
} }
MaybeLocal<v8::RegExp> v8::RegExp::NewWithBacktrackLimit(
Local<Context> context, Local<String> pattern, Flags flags,
uint32_t backtrack_limit) {
CHECK(i::Smi::IsValid(backtrack_limit));
CHECK_NE(backtrack_limit, i::JSRegExp::kNoBacktrackLimit);
PREPARE_FOR_EXECUTION(context, RegExp, New, RegExp);
Local<v8::RegExp> result;
has_pending_exception = !ToLocal<RegExp>(
i::JSRegExp::New(isolate, Utils::OpenHandle(*pattern),
static_cast<i::JSRegExp::Flags>(flags), backtrack_limit),
&result);
RETURN_ON_FAILED_EXECUTION(RegExp);
RETURN_ESCAPED(result);
}
Local<v8::String> v8::RegExp::GetSource() const { Local<v8::String> v8::RegExp::GetSource() const {
i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
return Utils::ToLocal( return Utils::ToLocal(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment