Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Guard @@isConcatSpreadable behind a flag
Browse files Browse the repository at this point in the history
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

Review URL: https://codereview.chromium.org/1226063002

Cr-Commit-Position: refs/heads/master@{#29545}
  • Loading branch information
littledan authored and Commit bot committed Jul 8, 2015
1 parent 5457228 commit a415f59
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 15 deletions.
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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++) {
Expand Down
5 changes: 3 additions & 2 deletions src/flag-definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ DEFINE_BOOL(legacy_const, true, "legacy semantics for const in sloppy mode")
V(harmony_new_target, "harmony new.target")

// Features that are complete (but still behind --harmony/es-staging flag).
#define HARMONY_STAGED(V) \
V(harmony_tostring, "harmony toString") \
#define HARMONY_STAGED(V) \
V(harmony_tostring, "harmony toString") \
V(harmony_concat_spreadable, "harmony isConcatSpreadable") \
V(harmony_rest_parameters, "harmony rest parameters")

// Features that are shipping (turned on by default, but internal flag remains).
Expand Down
5 changes: 0 additions & 5 deletions src/harmony-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions src/harmony-concat-spreadable.js
Original file line number Diff line number Diff line change
@@ -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(littledan): Move to symbol.js when shipping
"isConcatSpreadable", symbolIsConcatSpreadable
]);

})
16 changes: 9 additions & 7 deletions src/runtime/runtime-array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/mjsunit/harmony/array-concat.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: --harmony-arrays
// Flags: --harmony-concat-spreadable

(function testArrayConcatArity() {
"use strict";
Expand Down
1 change: 1 addition & 0 deletions tools/gyp/v8.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit a415f59

Please sign in to comment.