From 76cb4fe6263dcfd6f97137dbb4905283b75d3ce2 Mon Sep 17 00:00:00 2001 From: peterwmwong Date: Thu, 13 Dec 2018 23:21:42 -0600 Subject: [PATCH] [esnext] Ship String.p.matchAll/RegExp.p.[@@matchAll] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable --harmony-string-matchall by default. String.prototype.matchAll behaves similarly to String.prototype.match, but returns a full regexp result object for each match in a global or sticky regexp. This offers a simple way to iterate over matches when access to e.g. capture groups is needed. const string = 'a b c'; const regex = /[ac]/g; for (const match of string.matchAll(regex)) { console.log(`${match[0]} at ${match.index}`); } // a at 0 // c at 4 More information can be found here: https://github.com/tc39/proposal-string-matchall Drive-by: Update debug evaluate side effect expectations to handle String.p.matchAll and RegExp.p[@@matchAll] Bug: v8:6890 Change-Id: Ie3e712af66689936b7d2a15df705b792ccf06bd3 Reviewed-on: https://chromium-review.googlesource.com/c/1377774 Reviewed-by: Mathias Bynens Reviewed-by: Sathya Gunasekaran Reviewed-by: Jakob Gruber Commit-Queue: Peter Wong Cr-Commit-Position: refs/heads/master@{#58250} --- src/debug/debug-evaluate.cc | 2 ++ src/flag-definitions.h | 4 ++-- .../side-effect/debug-evaluate-no-side-effect-builtins.js | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/debug/debug-evaluate.cc b/src/debug/debug-evaluate.cc index f35cd45dba..ce155c3aa4 100644 --- a/src/debug/debug-evaluate.cc +++ b/src/debug/debug-evaluate.cc @@ -749,6 +749,7 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) { case Builtins::kStringPrototypeItalics: case Builtins::kStringPrototypeLastIndexOf: case Builtins::kStringPrototypeLink: + case Builtins::kStringPrototypeMatchAll: case Builtins::kStringPrototypePadEnd: case Builtins::kStringPrototypePadStart: case Builtins::kStringPrototypeRepeat: @@ -834,6 +835,7 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) { case Builtins::kRegExpPrototypeFlagsGetter: case Builtins::kRegExpPrototypeGlobalGetter: case Builtins::kRegExpPrototypeIgnoreCaseGetter: + case Builtins::kRegExpPrototypeMatchAll: case Builtins::kRegExpPrototypeMultilineGetter: case Builtins::kRegExpPrototypeDotAllGetter: case Builtins::kRegExpPrototypeUnicodeGetter: diff --git a/src/flag-definitions.h b/src/flag-definitions.h index c302fe6c9b..287ab87800 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -219,7 +219,6 @@ DEFINE_IMPLICATION(harmony_private_methods, harmony_private_fields) #define HARMONY_STAGED_BASE(V) \ V(harmony_private_fields, "harmony private fields in class literals") \ V(harmony_numeric_separator, "harmony numeric separator between digits") \ - V(harmony_string_matchall, "harmony String.prototype.matchAll") \ V(harmony_object_from_entries, "harmony Object.fromEntries()") #ifdef V8_INTL_SUPPORT @@ -243,7 +242,8 @@ DEFINE_IMPLICATION(harmony_private_methods, harmony_private_fields) V(harmony_global, "harmony global") \ V(harmony_json_stringify, "well-formed JSON.stringify") \ V(harmony_public_fields, "harmony public instance fields in class literals") \ - V(harmony_static_fields, "harmony static fields in class literals") + V(harmony_static_fields, "harmony static fields in class literals") \ + V(harmony_string_matchall, "harmony String.prototype.matchAll") #ifdef V8_INTL_SUPPORT #define HARMONY_SHIPPING(V) \ diff --git a/test/debugger/debug/side-effect/debug-evaluate-no-side-effect-builtins.js b/test/debugger/debug/side-effect/debug-evaluate-no-side-effect-builtins.js index 2ed350f3f5..92d534ce58 100644 --- a/test/debugger/debug/side-effect/debug-evaluate-no-side-effect-builtins.js +++ b/test/debugger/debug/side-effect/debug-evaluate-no-side-effect-builtins.js @@ -182,6 +182,7 @@ function listener(event, exec_state, event_data, data) { } if (f == "normalize") continue; if (f == "match") continue; + if (f == "matchAll") continue; if (f == "search") continue; if (f == "split" || f == "replace") { fail(`'abcd'.${f}(2)`);