From f8a43459d4ee65ec2c9afc4aa8bc9746f9cc6c0b Mon Sep 17 00:00:00 2001 From: yangguo Date: Mon, 2 Nov 2015 00:42:43 -0800 Subject: [PATCH] Expose string/regexp related public symbols on harmony flag. R=littledan@chromium.org BUG=v8:4305, v8:4343, v8:4344, v8:4345 LOG=N Review URL: https://codereview.chromium.org/1408223004 Cr-Commit-Position: refs/heads/master@{#31702} --- BUILD.gn | 2 -- src/bootstrapper.cc | 50 +++++++++++++++++++++++++---- src/flag-definitions.h | 3 +- src/js/harmony-concat-spreadable.js | 19 ----------- src/js/harmony-tostring.js | 19 ----------- src/js/symbol.js | 4 --- tools/gyp/v8.gyp | 2 -- 7 files changed, 46 insertions(+), 53 deletions(-) delete mode 100644 src/js/harmony-concat-spreadable.js delete mode 100644 src/js/harmony-tostring.js diff --git a/BUILD.gn b/BUILD.gn index 96ec26db8e..340954871e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -309,8 +309,6 @@ action("js2c_experimental") { "src/js/generator.js", "src/js/harmony-atomics.js", "src/js/harmony-array-includes.js", - "src/js/harmony-concat-spreadable.js", - "src/js/harmony-tostring.js", "src/js/harmony-regexp.js", "src/js/harmony-reflect.js", "src/js/harmony-object-observe.js", diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 6d887bc692..7a1a14bdb2 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -2157,10 +2157,8 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_default_parameters) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_observe) -EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_concat_spreadable) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexps) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode_regexps) -EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_completion) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tolength) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) @@ -2180,6 +2178,47 @@ static void SimpleInstallFunction(Handle& base, const char* name, } +void InstallPublicSymbol(Factory* factory, Handle native_context, + const char* name, Handle value) { + Handle global( + JSGlobalObject::cast(native_context->global_object())); + Handle symbol_string = factory->InternalizeUtf8String("Symbol"); + Handle symbol = Handle::cast( + JSObject::GetProperty(global, symbol_string).ToHandleChecked()); + Handle name_string = factory->InternalizeUtf8String(name); + PropertyAttributes attributes = + static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); + JSObject::AddProperty(symbol, name_string, value, attributes); +} + + +void Genesis::InitializeGlobal_harmony_tostring() { + if (!FLAG_harmony_tostring) return; + InstallPublicSymbol(factory(), native_context(), "toStringTag", + factory()->to_string_tag_symbol()); +} + + +void Genesis::InitializeGlobal_harmony_concat_spreadable() { + if (!FLAG_harmony_concat_spreadable) return; + InstallPublicSymbol(factory(), native_context(), "isConcatSpreadable", + factory()->is_concat_spreadable_symbol()); +} + + +void Genesis::InitializeGlobal_harmony_regexp_subclass() { + if (!FLAG_harmony_regexp_subclass) return; + InstallPublicSymbol(factory(), native_context(), "match", + factory()->match_symbol()); + InstallPublicSymbol(factory(), native_context(), "replace", + factory()->replace_symbol()); + InstallPublicSymbol(factory(), native_context(), "search", + factory()->search_symbol()); + InstallPublicSymbol(factory(), native_context(), "split", + factory()->split_symbol()); +} + + void Genesis::InitializeGlobal_harmony_reflect() { if (!FLAG_harmony_reflect) return; @@ -2622,8 +2661,7 @@ bool Genesis::InstallExperimentalNatives() { static const char* harmony_modules_natives[] = {nullptr}; static const char* harmony_regexps_natives[] = {"native harmony-regexp.js", nullptr}; - static const char* harmony_tostring_natives[] = {"native harmony-tostring.js", - nullptr}; + static const char* harmony_tostring_natives[] = {nullptr}; static const char* harmony_sloppy_natives[] = {nullptr}; static const char* harmony_sloppy_function_natives[] = {nullptr}; static const char* harmony_sloppy_let_natives[] = {nullptr}; @@ -2637,13 +2675,13 @@ bool Genesis::InstallExperimentalNatives() { "native harmony-object-observe.js", nullptr}; static const char* harmony_sharedarraybuffer_natives[] = { "native harmony-sharedarraybuffer.js", "native harmony-atomics.js", NULL}; - static const char* harmony_concat_spreadable_natives[] = { - "native harmony-concat-spreadable.js", nullptr}; + static const char* harmony_concat_spreadable_natives[] = {nullptr}; static const char* harmony_simd_natives[] = {"native harmony-simd.js", nullptr}; static const char* harmony_tolength_natives[] = {nullptr}; static const char* harmony_completion_natives[] = {nullptr}; static const char* harmony_do_expressions_natives[] = {nullptr}; + static const char* harmony_regexp_subclass_natives[] = {nullptr}; for (int i = ExperimentalNatives::GetDebuggerCount(); i < ExperimentalNatives::GetBuiltinsCount(); i++) { diff --git a/src/flag-definitions.h b/src/flag-definitions.h index bbedfe9e5d..344a6a7ad6 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -200,7 +200,8 @@ DEFINE_NEG_IMPLICATION(es_staging, legacy_const) V(harmony_default_parameters, "harmony default parameters") \ V(harmony_sharedarraybuffer, "harmony sharedarraybuffer") \ V(harmony_simd, "harmony simd") \ - V(harmony_do_expressions, "harmony do-expressions") + V(harmony_do_expressions, "harmony do-expressions") \ + V(harmony_regexp_subclass, "harmony regexp subclassing") // Features that are complete (but still behind --harmony/es-staging flag). #define HARMONY_STAGED(V) \ diff --git a/src/js/harmony-concat-spreadable.js b/src/js/harmony-concat-spreadable.js deleted file mode 100644 index c5d906a642..0000000000 --- a/src/js/harmony-concat-spreadable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -(function(global, utils) { - -'use strict'; - -%CheckIsBootstrapping(); - -var isConcatSpreadableSymbol = - utils.ImportNow("is_concat_spreadable_symbol"); - -utils.InstallConstants(global.Symbol, [ - // TODO(littledan): Move to symbol.js when shipping - "isConcatSpreadable", isConcatSpreadableSymbol -]); - -}) diff --git a/src/js/harmony-tostring.js b/src/js/harmony-tostring.js deleted file mode 100644 index 8e76c3a5bb..0000000000 --- a/src/js/harmony-tostring.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -(function(global, utils) { - -"use strict"; - -%CheckIsBootstrapping(); - -var GlobalSymbol = global.Symbol; -var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); - -utils.InstallConstants(GlobalSymbol, [ - // TODO(dslomov, caitp): Move to symbol.js when shipping - "toStringTag", toStringTagSymbol -]); - -}) diff --git a/src/js/symbol.js b/src/js/symbol.js index 4a565cc5fd..bb03ed211c 100644 --- a/src/js/symbol.js +++ b/src/js/symbol.js @@ -19,11 +19,7 @@ var isConcatSpreadableSymbol = var isRegExpSymbol = utils.ImportNow("is_regexp_symbol"); var iteratorSymbol = utils.ImportNow("iterator_symbol"); var MakeTypeError; -var matchSymbol = utils.ImportNow("match_symbol"); var ObjectGetOwnPropertyKeys; -var replaceSymbol = utils.ImportNow("replace_symbol"); -var searchSymbol = utils.ImportNow("search_symbol"); -var splitSymbol = utils.ImportNow("split_symbol"); var toPrimitiveSymbol = utils.ImportNow("to_primitive_symbol"); var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index 802f21adc8..88f370273a 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -1864,8 +1864,6 @@ '../../src/js/generator.js', '../../src/js/harmony-atomics.js', '../../src/js/harmony-array-includes.js', - '../../src/js/harmony-concat-spreadable.js', - '../../src/js/harmony-tostring.js', '../../src/js/harmony-regexp.js', '../../src/js/harmony-reflect.js', '../../src/js/harmony-object-observe.js',