Skip to content

Commit

Permalink
Remove always-true --harmony-string-matchall runtime flag
Browse files Browse the repository at this point in the history
It shipped in Chrome 73.

Bug: v8:6890
Change-Id: Idd8c98cf05a0d6e8fa58c5b0a34d079631f68b1b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1582879
Reviewed-by: Jakob Gruber <[email protected]>
Reviewed-by: Mathias Bynens <[email protected]>
Commit-Queue: Peter Wong <[email protected]>
Cr-Commit-Position: refs/heads/master@{#61005}
  • Loading branch information
peterwmwong authored and Commit Bot committed Apr 25, 2019
1 parent 3d84611 commit 3632d5a
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 82 deletions.
97 changes: 35 additions & 62 deletions src/bootstrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1990,6 +1990,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
#endif // V8_INTL_SUPPORT
SimpleInstallFunction(isolate_, prototype, "match",
Builtins::kStringPrototypeMatch, 1, true);
SimpleInstallFunction(isolate_, prototype, "matchAll",
Builtins::kStringPrototypeMatchAll, 1, true);
#ifdef V8_INTL_SUPPORT
SimpleInstallFunction(isolate_, prototype, "normalize",
Builtins::kStringPrototypeNormalizeIntl, 0, false);
Expand Down Expand Up @@ -2118,6 +2120,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallConstant(isolate_, symbol_fun, "iterator",
factory->iterator_symbol());
InstallConstant(isolate_, symbol_fun, "match", factory->match_symbol());
InstallConstant(isolate_, symbol_fun, "matchAll",
factory->match_all_symbol());
InstallConstant(isolate_, symbol_fun, "replace", factory->replace_symbol());
InstallConstant(isolate_, symbol_fun, "search", factory->search_symbol());
InstallConstant(isolate_, symbol_fun, "species", factory->species_symbol());
Expand Down Expand Up @@ -2486,6 +2490,12 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
DCHECK_EQ(JSRegExp::kSymbolMatchFunctionDescriptorIndex,
prototype->map()->LastAdded());

InstallFunctionAtSymbol(isolate_, prototype, factory->match_all_symbol(),
"[Symbol.matchAll]",
Builtins::kRegExpPrototypeMatchAll, 1, true);
DCHECK_EQ(JSRegExp::kSymbolMatchAllFunctionDescriptorIndex,
prototype->map()->LastAdded());

InstallFunctionAtSymbol(isolate_, prototype, factory->replace_symbol(),
"[Symbol.replace]",
Builtins::kRegExpPrototypeReplace, 2, false);
Expand Down Expand Up @@ -2599,6 +2609,31 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
JSObject::MigrateSlowToFast(regexp_fun, 0, "Bootstrapping");
}

{ // --- R e g E x p S t r i n g I t e r a t o r ---
Handle<JSObject> iterator_prototype(
native_context()->initial_iterator_prototype(), isolate());

Handle<JSObject> regexp_string_iterator_prototype = factory->NewJSObject(
isolate()->object_function(), AllocationType::kOld);
JSObject::ForceSetPrototype(regexp_string_iterator_prototype,
iterator_prototype);

InstallToStringTag(isolate(), regexp_string_iterator_prototype,
"RegExp String Iterator");

SimpleInstallFunction(isolate(), regexp_string_iterator_prototype, "next",
Builtins::kRegExpStringIteratorPrototypeNext, 0,
true);

Handle<JSFunction> regexp_string_iterator_function = CreateFunction(
isolate(), "RegExpStringIterator", JS_REGEXP_STRING_ITERATOR_TYPE,
JSRegExpStringIterator::kSize, 0, regexp_string_iterator_prototype,
Builtins::kIllegal);
regexp_string_iterator_function->shared()->set_native(false);
native_context()->set_initial_regexp_string_iterator_prototype_map(
regexp_string_iterator_function->initial_map());
}

{ // -- E r r o r
InstallError(isolate_, global, factory->Error_string(),
Context::ERROR_FUNCTION_INDEX);
Expand Down Expand Up @@ -4193,68 +4228,6 @@ void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
InstallToStringTag(isolate_, isolate()->atomics_object(), "Atomics");
}

void Genesis::InitializeGlobal_harmony_string_matchall() {
if (!FLAG_harmony_string_matchall) return;

{ // String.prototype.matchAll
Handle<JSFunction> string_fun(native_context()->string_function(),
isolate());
Handle<JSObject> string_prototype(
JSObject::cast(string_fun->instance_prototype()), isolate());

SimpleInstallFunction(isolate(), string_prototype, "matchAll",
Builtins::kStringPrototypeMatchAll, 1, true);
}

{ // RegExp.prototype[@@matchAll]
Handle<JSFunction> regexp_fun(native_context()->regexp_function(),
isolate());
Handle<JSObject> regexp_prototype(
JSObject::cast(regexp_fun->instance_prototype()), isolate());
InstallFunctionAtSymbol(isolate(), regexp_prototype,
factory()->match_all_symbol(), "[Symbol.matchAll]",
Builtins::kRegExpPrototypeMatchAll, 1, true);
DCHECK_EQ(JSRegExp::kSymbolMatchAllFunctionDescriptorIndex,
regexp_prototype->map()->LastAdded());

Handle<Map> regexp_prototype_map(regexp_prototype->map(), isolate());
Map::SetShouldBeFastPrototypeMap(regexp_prototype_map, true, isolate());
native_context()->set_regexp_prototype_map(*regexp_prototype_map);
}

{ // --- R e g E x p S t r i n g I t e r a t o r ---
Handle<JSObject> iterator_prototype(
native_context()->initial_iterator_prototype(), isolate());

Handle<JSObject> regexp_string_iterator_prototype = factory()->NewJSObject(
isolate()->object_function(), AllocationType::kOld);
JSObject::ForceSetPrototype(regexp_string_iterator_prototype,
iterator_prototype);

InstallToStringTag(isolate(), regexp_string_iterator_prototype,
"RegExp String Iterator");

SimpleInstallFunction(isolate(), regexp_string_iterator_prototype, "next",
Builtins::kRegExpStringIteratorPrototypeNext, 0,
true);

Handle<JSFunction> regexp_string_iterator_function = CreateFunction(
isolate(), "RegExpStringIterator", JS_REGEXP_STRING_ITERATOR_TYPE,
JSRegExpStringIterator::kSize, 0, regexp_string_iterator_prototype,
Builtins::kIllegal);
regexp_string_iterator_function->shared()->set_native(false);
native_context()->set_initial_regexp_string_iterator_prototype_map(
regexp_string_iterator_function->initial_map());
}

{ // @@matchAll Symbol
Handle<JSFunction> symbol_fun(native_context()->symbol_function(),
isolate());
InstallConstant(isolate(), symbol_fun, "matchAll",
factory()->match_all_symbol());
}
}

void Genesis::InitializeGlobal_harmony_weak_refs() {
if (!FLAG_harmony_weak_refs) return;

Expand Down
1 change: 0 additions & 1 deletion src/flag-definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ DEFINE_IMPLICATION(harmony_private_methods, harmony_private_fields)
V(harmony_global, "harmony global") \
V(harmony_public_fields, "harmony public instance fields in class literals") \
V(harmony_static_fields, "harmony static fields in class literals") \
V(harmony_string_matchall, "harmony String.prototype.matchAll") \
V(harmony_object_from_entries, "harmony Object.fromEntries()") \
V(harmony_await_optimization, "harmony await taking 1 tick") \
V(harmony_private_fields, "harmony private fields in class literals") \
Expand Down
8 changes: 4 additions & 4 deletions src/objects/js-regexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ class JSRegExp : public JSObject {
// Descriptor array index to important methods in the prototype.
static const int kExecFunctionDescriptorIndex = 1;
static const int kSymbolMatchFunctionDescriptorIndex = 13;
static const int kSymbolReplaceFunctionDescriptorIndex = 14;
static const int kSymbolSearchFunctionDescriptorIndex = 15;
static const int kSymbolSplitFunctionDescriptorIndex = 16;
static const int kSymbolMatchAllFunctionDescriptorIndex = 17;
static const int kSymbolMatchAllFunctionDescriptorIndex = 14;
static const int kSymbolReplaceFunctionDescriptorIndex = 15;
static const int kSymbolSearchFunctionDescriptorIndex = 16;
static const int kSymbolSplitFunctionDescriptorIndex = 17;

// The uninitialized value for a regexp code object.
static const int kUninitializedValue = -1;
Expand Down
3 changes: 0 additions & 3 deletions test/js-perf-test/JSTests3.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@
"name": "StringMatchAll",
"main": "run.js",
"resources": [ "string-matchall.js" ],
"flags": [
"--harmony-string-matchall"
],
"test_flags": [ "string-matchall" ],
"results_regexp": "^%s\\-Strings\\(Score\\): (.+)$",
"run_count": 1,
Expand Down
2 changes: 0 additions & 2 deletions test/mjsunit/harmony/string-matchAll-deleted-matchAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-string-matchall

delete RegExp.prototype[Symbol.matchAll];
const str = 'a';
assertThrows(() => str.matchAll(/\w/g), TypeError);
2 changes: 0 additions & 2 deletions test/mjsunit/harmony/string-matchAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-string-matchall

(function TestReceiverNonString() {
const iter = 'a'.matchAll(/./);
assertThrows(
Expand Down
2 changes: 0 additions & 2 deletions test/mjsunit/regexp-override-symbol-match-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-string-matchall

var s = "baa";

assertEquals([["b"]], [...s.matchAll(/./)]);
Expand Down
2 changes: 1 addition & 1 deletion test/mjsunit/regress-v8-8445-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --allow-natives-syntax --harmony-string-matchall
// Flags: --allow-natives-syntax

class MyRegExp {
exec() { return null; }
Expand Down
2 changes: 1 addition & 1 deletion test/mjsunit/regress-v8-8445.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --allow-natives-syntax --harmony-string-matchall
// Flags: --allow-natives-syntax

class MyRegExp {
exec() { return null; }
Expand Down
2 changes: 0 additions & 2 deletions test/mjsunit/regress/regress-crbug-899464.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-string-matchall

''.matchAll(/./u);
2 changes: 0 additions & 2 deletions test/test262/testcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
'class-static-fields-public': '--harmony-class-fields',
'class-fields-private': '--harmony-private-fields',
'class-static-fields-private': '--harmony-private-fields',
'String.prototype.matchAll': '--harmony-string-matchall',
'Symbol.matchAll': '--harmony-string-matchall',
'numeric-separator-literal': '--harmony-numeric-separator',
'Intl.DateTimeFormat-datetimestyle': '--harmony-intl-datetime-style',
'Intl.Locale': '--harmony-locale',
Expand Down

0 comments on commit 3632d5a

Please sign in to comment.