diff --git a/src/regexp/experimental/experimental-compiler.cc b/src/regexp/experimental/experimental-compiler.cc index 4068801ce7..9f331cbbd2 100644 --- a/src/regexp/experimental/experimental-compiler.cc +++ b/src/regexp/experimental/experimental-compiler.cc @@ -18,8 +18,9 @@ constexpr uc32 kMaxSupportedCodepoint = 0xFFFFu; class CanBeHandledVisitor final : private RegExpVisitor { // Visitor to implement `ExperimentalRegExp::CanBeHandled`. public: - static bool Check(RegExpTree* node, JSRegExp::Flags flags, Zone* zone) { - if (!AreSuitableFlags(flags)) { + static bool Check(RegExpTree* node, JSRegExp::Flags flags, int capture_count, + Zone* zone) { + if (!AreSuitableFlags(flags) || capture_count > 0) { return false; } CanBeHandledVisitor visitor(zone); @@ -145,9 +146,9 @@ class CanBeHandledVisitor final : private RegExpVisitor { bool ExperimentalRegExpCompiler::CanBeHandled(RegExpTree* tree, JSRegExp::Flags flags, - Zone* zone) { + int capture_count, Zone* zone) { DCHECK(FLAG_enable_experimental_regexp_engine); - return CanBeHandledVisitor::Check(tree, flags, zone); + return CanBeHandledVisitor::Check(tree, flags, capture_count, zone); } namespace { diff --git a/src/regexp/experimental/experimental-compiler.h b/src/regexp/experimental/experimental-compiler.h index 542592796c..115a324f0c 100644 --- a/src/regexp/experimental/experimental-compiler.h +++ b/src/regexp/experimental/experimental-compiler.h @@ -19,7 +19,8 @@ class ExperimentalRegExpCompiler final : public AllStatic { // but see the definition. // TODO(mbid,v8:10765): Currently more things are not handled, e.g. some // quantifiers and unicode. - static bool CanBeHandled(RegExpTree* tree, JSRegExp::Flags flags, Zone* zone); + static bool CanBeHandled(RegExpTree* tree, JSRegExp::Flags flags, + int capture_count, Zone* zone); // Compile regexp into a bytecode program. The regexp must be handlable by // the experimental engine; see`CanBeHandled`. The program is returned as a // ZoneList backed by the same Zone that is used in the RegExpTree argument. diff --git a/src/regexp/experimental/experimental.cc b/src/regexp/experimental/experimental.cc index 916d8b02a9..9551592dff 100644 --- a/src/regexp/experimental/experimental.cc +++ b/src/regexp/experimental/experimental.cc @@ -14,8 +14,9 @@ namespace v8 { namespace internal { bool ExperimentalRegExp::CanBeHandled(RegExpTree* tree, JSRegExp::Flags flags, - Zone* zone) { - return ExperimentalRegExpCompiler::CanBeHandled(tree, flags, zone); + int capture_count, Zone* zone) { + return ExperimentalRegExpCompiler::CanBeHandled(tree, flags, capture_count, + zone); } void ExperimentalRegExp::Initialize(Isolate* isolate, Handle re, diff --git a/src/regexp/experimental/experimental.h b/src/regexp/experimental/experimental.h index 7953e88bc9..607fb93b4b 100644 --- a/src/regexp/experimental/experimental.h +++ b/src/regexp/experimental/experimental.h @@ -19,7 +19,8 @@ class ExperimentalRegExp final : public AllStatic { // TODO(mbid, v8:10765): This walks the RegExpTree, but it could also be // checked on the fly in the parser. Not done currently because walking the // AST again is more flexible and less error prone (but less performant). - static bool CanBeHandled(RegExpTree* tree, JSRegExp::Flags flags, Zone* zone); + static bool CanBeHandled(RegExpTree* tree, JSRegExp::Flags flags, + int capture_count, Zone* zone); static void Initialize(Isolate* isolate, Handle re, Handle pattern, JSRegExp::Flags flags, int capture_count); diff --git a/src/regexp/regexp.cc b/src/regexp/regexp.cc index c1f5b10d34..8e821f6683 100644 --- a/src/regexp/regexp.cc +++ b/src/regexp/regexp.cc @@ -175,7 +175,8 @@ MaybeHandle RegExp::Compile(Isolate* isolate, Handle re, bool has_been_compiled = false; if (FLAG_enable_experimental_regexp_engine && - ExperimentalRegExp::CanBeHandled(parse_result.tree, flags, &zone)) { + ExperimentalRegExp::CanBeHandled(parse_result.tree, flags, + parse_result.capture_count, &zone)) { ExperimentalRegExp::Initialize(isolate, re, pattern, flags, parse_result.capture_count); has_been_compiled = true;