Commit d9d6a609 authored by rossberg@chromium.org's avatar rossberg@chromium.org

Enable ES6 unscopables

R=yangguo@chromium.org
BUG=v8:3401
LOG=Y

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22994 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 055fe8c3
...@@ -1471,6 +1471,20 @@ function SetUpArray() { ...@@ -1471,6 +1471,20 @@ function SetUpArray() {
// object. // object.
%AddNamedProperty($Array.prototype, "constructor", $Array, DONT_ENUM); %AddNamedProperty($Array.prototype, "constructor", $Array, DONT_ENUM);
// Set up unscopable properties on the Array.prototype object.
var unscopables = {
__proto__: null,
copyWithin: true,
entries: true,
fill: true,
find: true,
findIndex: true,
keys: true,
values: true,
};
%AddNamedProperty($Array.prototype, symbolUnscopables, unscopables,
DONT_ENUM | READ_ONLY);
// Set up non-enumerable functions on the Array object. // Set up non-enumerable functions on the Array object.
InstallFunctions($Array, DONT_ENUM, $Array( InstallFunctions($Array, DONT_ENUM, $Array(
"isArray", ArrayIsArray "isArray", ArrayIsArray
......
...@@ -1592,6 +1592,7 @@ void Genesis::InstallNativeFunctions() { ...@@ -1592,6 +1592,7 @@ void Genesis::InstallNativeFunctions() {
native_object_notifier_perform_change); native_object_notifier_perform_change);
INSTALL_NATIVE(Symbol, "symbolIterator", iterator_symbol); INSTALL_NATIVE(Symbol, "symbolIterator", iterator_symbol);
INSTALL_NATIVE(Symbol, "symbolUnscopables", unscopables_symbol);
INSTALL_NATIVE_MATH(abs) INSTALL_NATIVE_MATH(abs)
INSTALL_NATIVE_MATH(acos) INSTALL_NATIVE_MATH(acos)
...@@ -1622,10 +1623,6 @@ void Genesis::InstallExperimentalNativeFunctions() { ...@@ -1622,10 +1623,6 @@ void Genesis::InstallExperimentalNativeFunctions() {
INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap);
INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate);
} }
if (FLAG_harmony_unscopables) {
INSTALL_NATIVE(Symbol, "symbolUnscopables", unscopables_symbol);
}
} }
#undef INSTALL_NATIVE #undef INSTALL_NATIVE
...@@ -2062,7 +2059,6 @@ bool Genesis::InstallExperimentalNatives() { ...@@ -2062,7 +2059,6 @@ bool Genesis::InstallExperimentalNatives() {
INSTALL_EXPERIMENTAL_NATIVE(i, generators, "generator.js") INSTALL_EXPERIMENTAL_NATIVE(i, generators, "generator.js")
INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js") INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js")
INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js") INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js")
INSTALL_EXPERIMENTAL_NATIVE(i, unscopables, "unscopables.js")
} }
InstallExperimentalNativeFunctions(); InstallExperimentalNativeFunctions();
......
...@@ -142,7 +142,7 @@ Handle<Object> Context::Lookup(Handle<String> name, ...@@ -142,7 +142,7 @@ Handle<Object> Context::Lookup(Handle<String> name,
if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 ||
object->IsJSContextExtensionObject()) { object->IsJSContextExtensionObject()) {
maybe = JSReceiver::GetOwnPropertyAttributes(object, name); maybe = JSReceiver::GetOwnPropertyAttributes(object, name);
} else if (FLAG_harmony_unscopables && context->IsWithContext()) { } else if (context->IsWithContext()) {
LookupIterator it(object, name); LookupIterator it(object, name);
maybe = UnscopableLookup(&it); maybe = UnscopableLookup(&it);
} else { } else {
......
...@@ -160,7 +160,6 @@ DEFINE_BOOL(harmony_numeric_literals, false, ...@@ -160,7 +160,6 @@ DEFINE_BOOL(harmony_numeric_literals, false,
DEFINE_BOOL(harmony_strings, false, "enable harmony string") DEFINE_BOOL(harmony_strings, false, "enable harmony string")
DEFINE_BOOL(harmony_arrays, false, "enable harmony arrays") DEFINE_BOOL(harmony_arrays, false, "enable harmony arrays")
DEFINE_BOOL(harmony_arrow_functions, false, "enable harmony arrow functions") DEFINE_BOOL(harmony_arrow_functions, false, "enable harmony arrow functions")
DEFINE_BOOL(harmony_unscopables, false, "enable harmony unscopables")
DEFINE_BOOL(harmony, false, "enable all harmony features (except proxies)") DEFINE_BOOL(harmony, false, "enable all harmony features (except proxies)")
DEFINE_IMPLICATION(harmony, harmony_scoping) DEFINE_IMPLICATION(harmony, harmony_scoping)
...@@ -175,7 +174,6 @@ DEFINE_IMPLICATION(harmony, harmony_arrow_functions) ...@@ -175,7 +174,6 @@ DEFINE_IMPLICATION(harmony, harmony_arrow_functions)
DEFINE_IMPLICATION(harmony_modules, harmony_scoping) DEFINE_IMPLICATION(harmony_modules, harmony_scoping)
DEFINE_IMPLICATION(harmony, es_staging) DEFINE_IMPLICATION(harmony, es_staging)
DEFINE_IMPLICATION(es_staging, harmony_unscopables)
// Flags for experimental implementation features. // Flags for experimental implementation features.
DEFINE_BOOL(compiled_keyed_dictionary_loads, true, DEFINE_BOOL(compiled_keyed_dictionary_loads, true,
......
...@@ -103,9 +103,9 @@ function SetUpSymbol() { ...@@ -103,9 +103,9 @@ function SetUpSymbol() {
// "hasInstance", symbolHasInstance, // "hasInstance", symbolHasInstance,
// "isConcatSpreadable", symbolIsConcatSpreadable, // "isConcatSpreadable", symbolIsConcatSpreadable,
// "isRegExp", symbolIsRegExp, // "isRegExp", symbolIsRegExp,
"iterator", symbolIterator "iterator", symbolIterator,
// "toStringTag", symbolToStringTag, // "toStringTag", symbolToStringTag,
// "unscopables", symbolUnscopables // added in unscopables.js "unscopables", symbolUnscopables
)); ));
InstallFunctions($Symbol, DONT_ENUM, $Array( InstallFunctions($Symbol, DONT_ENUM, $Array(
"for", SymbolFor, "for", SymbolFor,
......
// Copyright 2014 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.
'use strict';
// This file relies on the fact that the following declaration has been made.
// var $Array = global.Array;
// var $Symbol = global.Symbol;
function UnscopablesExtendSymbol() {
%CheckIsBootstrapping();
InstallConstants($Symbol, $Array(
"unscopables", symbolUnscopables
));
}
UnscopablesExtendSymbol();
var arrayUnscopables = {
__proto__: null,
copyWithin: true,
entries: true,
fill: true,
find: true,
findIndex: true,
keys: true,
values: true,
};
function UnscopablesExtendArrayPrototype() {
%CheckIsBootstrapping();
%AddNamedProperty($Array.prototype, symbolUnscopables, arrayUnscopables,
DONT_ENUM | READ_ONLY);
}
UnscopablesExtendArrayPrototype();
...@@ -20,8 +20,6 @@ static void Cleanup() { ...@@ -20,8 +20,6 @@ static void Cleanup() {
TEST(Unscopables) { TEST(Unscopables) {
i::FLAG_harmony_unscopables = true;
LocalContext context; LocalContext context;
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
......
...@@ -447,7 +447,7 @@ function TestWellKnown() { ...@@ -447,7 +447,7 @@ function TestWellKnown() {
var symbols = [ var symbols = [
// TODO(rossberg): reactivate once implemented. // TODO(rossberg): reactivate once implemented.
// "hasInstance", "isConcatSpreadable", "isRegExp", // "hasInstance", "isConcatSpreadable", "isRegExp",
"iterator" //, "toStringTag", "unscopables" "iterator", /* "toStringTag", */ "unscopables"
] ]
for (var i in symbols) { for (var i in symbols) {
......
...@@ -51,7 +51,7 @@ EXPECTED_FUNCTION_COUNT = 427 ...@@ -51,7 +51,7 @@ EXPECTED_FUNCTION_COUNT = 427
EXPECTED_FUZZABLE_COUNT = 330 EXPECTED_FUZZABLE_COUNT = 330
EXPECTED_CCTEST_COUNT = 7 EXPECTED_CCTEST_COUNT = 7
EXPECTED_UNKNOWN_COUNT = 16 EXPECTED_UNKNOWN_COUNT = 16
EXPECTED_BUILTINS_COUNT = 811 EXPECTED_BUILTINS_COUNT = 809
# Don't call these at all. # Don't call these at all.
......
...@@ -1387,6 +1387,7 @@ ...@@ -1387,6 +1387,7 @@
'library_files': [ 'library_files': [
'../../src/runtime.js', '../../src/runtime.js',
'../../src/v8natives.js', '../../src/v8natives.js',
'../../src/symbol.js',
'../../src/array.js', '../../src/array.js',
'../../src/string.js', '../../src/string.js',
'../../src/uri.js', '../../src/uri.js',
...@@ -1405,7 +1406,6 @@ ...@@ -1405,7 +1406,6 @@
'../../src/weak_collection.js', '../../src/weak_collection.js',
'../../src/promise.js', '../../src/promise.js',
'../../src/object-observe.js', '../../src/object-observe.js',
'../../src/symbol.js',
'../../src/collection.js', '../../src/collection.js',
'../../src/collection-iterator.js', '../../src/collection-iterator.js',
'../../src/macros.py', '../../src/macros.py',
...@@ -1418,7 +1418,6 @@ ...@@ -1418,7 +1418,6 @@
'../../src/generator.js', '../../src/generator.js',
'../../src/harmony-string.js', '../../src/harmony-string.js',
'../../src/harmony-array.js', '../../src/harmony-array.js',
'../../src/unscopables.js',
], ],
'libraries_bin_file': '<(SHARED_INTERMEDIATE_DIR)/libraries.bin', 'libraries_bin_file': '<(SHARED_INTERMEDIATE_DIR)/libraries.bin',
'libraries_experimental_bin_file': '<(SHARED_INTERMEDIATE_DIR)/libraries-experimental.bin', 'libraries_experimental_bin_file': '<(SHARED_INTERMEDIATE_DIR)/libraries-experimental.bin',
......
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