Commit 76cb4fe6 authored by peterwmwong's avatar peterwmwong Committed by Commit Bot

[esnext] Ship String.p.matchAll/RegExp.p.[@@matchAll]

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/1377774Reviewed-by: 's avatarMathias Bynens <mathias@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Peter Wong <peter.wm.wong@gmail.com>
Cr-Commit-Position: refs/heads/master@{#58250}
parent a43fa12a
......@@ -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:
......
......@@ -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) \
......
......@@ -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)`);
......
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