Reviewers: adamk,

Description:
Guard @@isConcatSpreadable behind a flag

The breakage to Chrome seems to be based on @@isConcatSpreadable
and turning that part off with this patch fixes the Maps Tips & Tricks
test case.

BUG=chromium:507553
LOG=Y
R=adamk

Please review this at https://codereview.chromium.org/1226063002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+33, -13 lines):
  M BUILD.gn
  M src/bootstrapper.cc
  M src/flag-definitions.h
  M src/harmony-array.js
  A src/harmony-concat-spreadable.js
  M src/runtime/runtime-array.cc
  M tools/gyp/v8.gyp


Index: BUILD.gn
diff --git a/BUILD.gn b/BUILD.gn
index e75ffb7656c5b1ef8412a96cd364151596369c24..059ee07086248da5ef965c679041e0e0a356e0af 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -273,6 +273,7 @@ action("js2c_experimental") {
     "src/generator.js",
     "src/harmony-atomics.js",
     "src/harmony-array-includes.js",
+    "src/harmony-concat-spreadable.js",
     "src/harmony-tostring.js",
     "src/harmony-regexp.js",
     "src/harmony-reflect.js",
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 983da4787fe5a3064b3369e7e8f550544c8beeea..43fc0eb8355a7ad0d1be7ccb0fe4bd233ac81dd9 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1819,6 +1819,7 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spread_arrays)
 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sharedarraybuffer)
 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_atomics)
 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_new_target)
+EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_concat_spreadable)


 void Genesis::InstallNativeFunctions_harmony_proxies() {
@@ -1850,6 +1851,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spread_arrays)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_atomics)
 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_new_target)
+EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_concat_spreadable)

 void Genesis::InitializeGlobal_harmony_regexps() {
   Handle<JSObject> builtins(native_context()->builtins());
@@ -2500,6 +2502,8 @@ bool Genesis::InstallExperimentalNatives() {
static const char* harmony_atomics_natives[] = {"native harmony-atomics.js",
                                                   nullptr};
   static const char* harmony_new_target_natives[] = {nullptr};
+  static const char* harmony_concat_spreadable_natives[] = {
+      "native harmony-concat-spreadable.js", nullptr};

   for (int i = ExperimentalNatives::GetDebuggerCount();
        i < ExperimentalNatives::GetBuiltinsCount(); i++) {
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index 033d0b3e8fab230f08bef9dbc2ff3fcb2813687a..072308f4af8a1a62ac0a8e95e341cfd7903b1c37 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -196,7 +196,8 @@ DEFINE_BOOL(legacy_const, true, "legacy semantics for const in sloppy mode")
   V(harmony_destructuring, "harmony destructuring")             \
   V(harmony_sharedarraybuffer, "harmony sharedarraybuffer")     \
   V(harmony_atomics, "harmony atomics")                         \
-  V(harmony_new_target, "harmony new.target")
+  V(harmony_new_target, "harmony new.target")                   \
+  V(harmony_concat_spreadable, "harmony isConcatSpreadable")

 // Features that are complete (but still behind --harmony/es-staging flag).
 #define HARMONY_STAGED(V)                 \
Index: src/harmony-array.js
diff --git a/src/harmony-array.js b/src/harmony-array.js
index 637dd6ed857639f8b743f617a744aea9460a4e85..e94134b81aa851a9539ceb86d38e72971279fa78 100644
--- a/src/harmony-array.js
+++ b/src/harmony-array.js
@@ -287,11 +287,6 @@ function ArrayOf() {

 // -------------------------------------------------------------------

-utils.InstallConstants(GlobalSymbol, [
-  // TODO(dslomov, caitp): Move to symbol.js when shipping
-  "isConcatSpreadable", symbolIsConcatSpreadable
-]);
-
 %FunctionSetLength(ArrayCopyWithin, 2);
 %FunctionSetLength(ArrayFrom, 1);
 %FunctionSetLength(ArrayFill, 1);
Index: src/harmony-concat-spreadable.js
diff --git a/src/harmony-concat-spreadable.js b/src/harmony-concat-spreadable.js
new file mode 100644
index 0000000000000000000000000000000000000000..c42e0dfdc2d95b7a63ffdee8a601efcf29d9a502
--- /dev/null
+++ b/src/harmony-concat-spreadable.js
@@ -0,0 +1,16 @@
+// 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();
+
+utils.InstallConstants(global.Symbol, [
+  // TODO(dslomov, caitp): Move to symbol.js when shipping
+  "isConcatSpreadable", symbolIsConcatSpreadable
+]);
+
+})
Index: src/runtime/runtime-array.cc
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc
index b2865dcbdf323b6829fec9e02d2f262036fcd0c1..d00df71576bf27edcee2131a8c0cd5656e314d8c 100644
--- a/src/runtime/runtime-array.cc
+++ b/src/runtime/runtime-array.cc
@@ -729,13 +729,15 @@ static bool IterateElements(Isolate* isolate, Handle<JSObject> receiver,
 static bool IsConcatSpreadable(Isolate* isolate, Handle<Object> obj) {
   HandleScope handle_scope(isolate);
   if (!obj->IsSpecObject()) return false;
-  Handle<Symbol> key(isolate->factory()->is_concat_spreadable_symbol());
-  Handle<Object> value;
-  MaybeHandle<Object> maybeValue =
-      i::Runtime::GetObjectProperty(isolate, obj, key);
-  if (maybeValue.ToHandle(&value)) {
-    if (!value->IsUndefined()) {
-      return value->BooleanValue();
+  if (FLAG_harmony_concat_spreadable) {
+    Handle<Symbol> key(isolate->factory()->is_concat_spreadable_symbol());
+    Handle<Object> value;
+    MaybeHandle<Object> maybeValue =
+        i::Runtime::GetObjectProperty(isolate, obj, key);
+    if (maybeValue.ToHandle(&value)) {
+      if (!value->IsUndefined()) {
+        return value->BooleanValue();
+      }
     }
   }
   return obj->IsJSArray();
Index: tools/gyp/v8.gyp
diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
index 6ef9b3818e35b42b14cc5c97fd176708dc9c1e31..a77acfa1091ed9fb392895c28ca62e572b8249a1 100644
--- a/tools/gyp/v8.gyp
+++ b/tools/gyp/v8.gyp
@@ -1786,6 +1786,7 @@
           '../../src/generator.js',
           '../../src/harmony-atomics.js',
           '../../src/harmony-array-includes.js',
+          '../../src/harmony-concat-spreadable.js',
           '../../src/harmony-tostring.js',
           '../../src/harmony-regexp.js',
           '../../src/harmony-reflect.js',


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to