Reviewers: rossberg,
Description:
Enable ES6 iteration by default
This enables for-of, as well as @@iterator implementations for strings
and arrays.
[email protected]
BUG=v8:2214
LOG=Y
Please review this at https://codereview.chromium.org/446023002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+20, -40 lines):
M BUILD.gn
M src/bootstrapper.cc
M src/flag-definitions.h
M src/parser.cc
M src/preparser.h
M src/preparser.cc
M test/cctest/test-parsing.cc
M test/mjsunit/builtins.js
M test/mjsunit/debug-script.js
M test/mjsunit/harmony/array-iterator.js
M test/mjsunit/harmony/generators-iteration.js
M test/mjsunit/harmony/iteration-semantics.js
M test/mjsunit/harmony/iteration-syntax.js
M test/mjsunit/harmony/proxies.js
M test/mjsunit/harmony/regress/regress-crbug-248025.js
M test/mjsunit/harmony/string-iterator.js
M test/mjsunit/harmony/typed-array-iterator.js
M tools/gyp/v8.gyp
Index: BUILD.gn
diff --git a/BUILD.gn b/BUILD.gn
index
b3813d2504dcf5cfb5b96e8ecf3b901e41f6a84c..302d71f61665baa30faf9e5d0a2a1fb2308b5bf1
100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -212,6 +212,8 @@ action("js2c") {
"src/promise.js",
"src/object-observe.js",
"src/macros.py",
+ "src/array-iterator.js",
+ "src/string-iterator.js",
]
outputs = [
@@ -250,7 +252,6 @@ action("js2c_experimental") {
"src/macros.py",
"src/proxy.js",
"src/generator.js",
- "src/array-iterator.js",
"src/harmony-string.js",
"src/harmony-array.js",
]
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index
c297a37e1ceef40c9be1c3e4d0e016301a3b110f..9b3566eb6d0e5c99413ebddb6a5fd8eb79bd6cfa
100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -121,7 +121,7 @@ char* Bootstrapper::AllocateAutoDeletedArray(int bytes)
{
void Bootstrapper::TearDown() {
if (delete_these_non_arrays_on_tear_down_ != NULL) {
int len = delete_these_non_arrays_on_tear_down_->length();
- DCHECK(len < 25); // Don't use this mechanism for unbounded
allocations.
+ DCHECK(len < 27); // Don't use this mechanism for unbounded
allocations.
for (int i = 0; i < len; i++) {
delete delete_these_non_arrays_on_tear_down_->at(i);
delete_these_non_arrays_on_tear_down_->at(i) = NULL;
@@ -2059,8 +2059,6 @@ bool Genesis::InstallExperimentalNatives() {
i++) {
INSTALL_EXPERIMENTAL_NATIVE(i, proxies, "proxy.js")
INSTALL_EXPERIMENTAL_NATIVE(i, generators, "generator.js")
- INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "array-iterator.js")
- INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "string-iterator.js")
INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js")
INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js")
}
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
8de6b3ab04bda6350a37408e62ff1239af312169..03d2c120557e5ee8204500aa6522f4504e716f8b
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -155,7 +155,6 @@ DEFINE_BOOL(harmony_modules, false,
"enable harmony modules (implies block scoping)")
DEFINE_BOOL(harmony_proxies, false, "enable harmony proxies")
DEFINE_BOOL(harmony_generators, false, "enable harmony generators")
-DEFINE_BOOL(harmony_iteration, false, "enable harmony iteration (for-of)")
DEFINE_BOOL(harmony_numeric_literals, false,
"enable harmony numeric literals (0o77, 0b11)")
DEFINE_BOOL(harmony_strings, false, "enable harmony string")
@@ -174,7 +173,6 @@ DEFINE_IMPLICATION(harmony, harmony_arrow_functions)
DEFINE_IMPLICATION(harmony_modules, harmony_scoping)
DEFINE_IMPLICATION(harmony, es_staging)
-DEFINE_IMPLICATION(es_staging, harmony_iteration)
// Flags for experimental implementation features.
DEFINE_BOOL(compiled_keyed_dictionary_loads, true,
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index
a3970db20640bca0515556ec0bc31b2724807340..d52846038b6cf80d03bf3e3e24dd601abd13b742
100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -729,7 +729,6 @@ Parser::Parser(CompilationInfo* info)
set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native());
set_allow_lazy(false); // Must be explicitly enabled.
set_allow_generators(FLAG_harmony_generators);
- set_allow_for_of(FLAG_harmony_iteration);
set_allow_arrow_functions(FLAG_harmony_arrow_functions);
set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
@@ -2759,8 +2758,7 @@ bool Parser::CheckInOrOf(bool accept_OF,
if (Check(Token::IN)) {
*visit_mode = ForEachStatement::ENUMERATE;
return true;
- } else if (allow_for_of() && accept_OF &&
- CheckContextualKeyword(CStrVector("of"))) {
+ } else if (accept_OF && CheckContextualKeyword(CStrVector("of"))) {
*visit_mode = ForEachStatement::ITERATE;
return true;
}
@@ -3739,7 +3737,6 @@ PreParser::PreParseResult
Parser::ParseLazyFunctionBodyWithPreParser(
reusable_preparser_->set_allow_natives_syntax(allow_natives_syntax());
reusable_preparser_->set_allow_lazy(true);
reusable_preparser_->set_allow_generators(allow_generators());
- reusable_preparser_->set_allow_for_of(allow_for_of());
reusable_preparser_->set_allow_arrow_functions(allow_arrow_functions());
reusable_preparser_->set_allow_harmony_numeric_literals(
allow_harmony_numeric_literals());
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index
1336857593f621de7f3349c0be30ed86a12cdb7c..7ce8e3d91aa4628d1d5dde2474ac10cc9164bab7
100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -653,8 +653,7 @@ PreParser::Statement
PreParser::ParseWhileStatement(bool* ok) {
bool PreParser::CheckInOrOf(bool accept_OF) {
if (Check(Token::IN) ||
- (allow_for_of() && accept_OF &&
- CheckContextualKeyword(CStrVector("of")))) {
+ (accept_OF && CheckContextualKeyword(CStrVector("of")))) {
return true;
}
return false;
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index
517403d34733eba81ea86c7bedd38162feded389..1f2352d882ac74387c445cac68e458684e0ae425
100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -81,7 +81,6 @@ class ParserBase : public Traits {
allow_lazy_(false),
allow_natives_syntax_(false),
allow_generators_(false),
- allow_for_of_(false),
allow_arrow_functions_(false),
zone_(zone) {}
@@ -90,7 +89,6 @@ class ParserBase : public Traits {
bool allow_lazy() const { return allow_lazy_; }
bool allow_natives_syntax() const { return allow_natives_syntax_; }
bool allow_generators() const { return allow_generators_; }
- bool allow_for_of() const { return allow_for_of_; }
bool allow_arrow_functions() const { return allow_arrow_functions_; }
bool allow_modules() const { return scanner()->HarmonyModules(); }
bool allow_harmony_scoping() const { return scanner()->HarmonyScoping();
}
@@ -103,7 +101,6 @@ class ParserBase : public Traits {
void set_allow_lazy(bool allow) { allow_lazy_ = allow; }
void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ =
allow; }
void set_allow_generators(bool allow) { allow_generators_ = allow; }
- void set_allow_for_of(bool allow) { allow_for_of_ = allow; }
void set_allow_arrow_functions(bool allow) { allow_arrow_functions_ =
allow; }
void set_allow_modules(bool allow) {
scanner()->SetHarmonyModules(allow); }
void set_allow_harmony_scoping(bool allow) {
@@ -534,7 +531,6 @@ class ParserBase : public Traits {
bool allow_lazy_;
bool allow_natives_syntax_;
bool allow_generators_;
- bool allow_for_of_;
bool allow_arrow_functions_;
typename Traits::Type::Zone* zone_; // Only used by Parser.
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index
74ece30680ad3927d7eab8a1a4904f96d5c3e291..9cb5d69e6c5c1849465a769c2205451cdc7f2421
100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1208,7 +1208,6 @@ enum ParserFlag {
kAllowHarmonyScoping,
kAllowModules,
kAllowGenerators,
- kAllowForOf,
kAllowHarmonyNumericLiterals,
kAllowArrowFunctions
};
@@ -1228,7 +1227,6 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
parser->set_allow_harmony_scoping(flags.Contains(kAllowHarmonyScoping));
parser->set_allow_modules(flags.Contains(kAllowModules));
parser->set_allow_generators(flags.Contains(kAllowGenerators));
- parser->set_allow_for_of(flags.Contains(kAllowForOf));
parser->set_allow_harmony_numeric_literals(
flags.Contains(kAllowHarmonyNumericLiterals));
parser->set_allow_arrow_functions(flags.Contains(kAllowArrowFunctions));
@@ -1436,10 +1434,9 @@ TEST(ParserSync) {
CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition()
-
128 * 1024);
- static const ParserFlag flags1[] = {
- kAllowLazy, kAllowHarmonyScoping, kAllowModules, kAllowGenerators,
- kAllowForOf, kAllowArrowFunctions
- };
+ static const ParserFlag flags1[] = {kAllowLazy, kAllowHarmonyScoping,
+ kAllowModules, kAllowGenerators,
+ kAllowArrowFunctions};
for (int i = 0; context_data[i][0] != NULL; ++i) {
for (int j = 0; statement_data[j] != NULL; ++j) {
for (int k = 0; termination_data[k] != NULL; ++k) {
@@ -1514,9 +1511,8 @@ void RunParserSyncTest(const char* context_data[][2],
128 * 1024);
static const ParserFlag default_flags[] = {
- kAllowLazy, kAllowHarmonyScoping, kAllowModules, kAllowGenerators,
- kAllowForOf, kAllowNativesSyntax, kAllowArrowFunctions
- };
+ kAllowLazy, kAllowHarmonyScoping, kAllowModules,
+ kAllowGenerators, kAllowNativesSyntax, kAllowArrowFunctions};
ParserFlag* generated_flags = NULL;
if (flags == NULL) {
flags = default_flags;
Index: test/mjsunit/builtins.js
diff --git a/test/mjsunit/builtins.js b/test/mjsunit/builtins.js
index
3c92af82509b34b2fa2502d6174c61efd5ba5d75..fe7d35d8ea160fc447fe187980488f27a1581bbf
100644
--- a/test/mjsunit/builtins.js
+++ b/test/mjsunit/builtins.js
@@ -41,7 +41,9 @@ function isFunction(obj) {
function isV8Native(name) {
return name == "GeneratorFunctionPrototype" ||
name == "SetIterator" ||
- name == "MapIterator";
+ name == "MapIterator" ||
+ name == "ArrayIterator" ||
+ name == "StringIterator";
}
function checkConstructor(func, name) {
Index: test/mjsunit/debug-script.js
diff --git a/test/mjsunit/debug-script.js b/test/mjsunit/debug-script.js
index
54e80e07a095c162cebb1b261dad1aaf5777f858..5b5e75962fe32bb1ca3d93fe12a44bcad6925ac6
100644
--- a/test/mjsunit/debug-script.js
+++ b/test/mjsunit/debug-script.js
@@ -59,7 +59,7 @@ for (i = 0; i < scripts.length; i++) {
}
// This has to be updated if the number of native scripts change.
-assertTrue(named_native_count == 23 || named_native_count == 24);
+assertTrue(named_native_count == 25 || named_native_count == 26);
// Only the 'gc' extension is loaded.
assertEquals(1, extension_count);
// This script and mjsunit.js has been loaded. If using d8, d8 loads
Index: test/mjsunit/harmony/array-iterator.js
diff --git a/test/mjsunit/harmony/array-iterator.js
b/test/mjsunit/harmony/array-iterator.js
index
23288761a6afed49700c973638b02cf6d9f02978..63a7415b966f9bbe9fbdc5266fc5b5c4447238ff
100644
--- a/test/mjsunit/harmony/array-iterator.js
+++ b/test/mjsunit/harmony/array-iterator.js
@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-iteration --allow-natives-syntax
+// Flags: --allow-natives-syntax
var NONE = 0;
Index: test/mjsunit/harmony/generators-iteration.js
diff --git a/test/mjsunit/harmony/generators-iteration.js
b/test/mjsunit/harmony/generators-iteration.js
index
e60e2a94e2dab051a37525a7b3efad3e3ec907ea..1a793678d93c4e0d3acbec82059b90d658bac71e
100644
--- a/test/mjsunit/harmony/generators-iteration.js
+++ b/test/mjsunit/harmony/generators-iteration.js
@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-generators --expose-gc --harmony-iteration
+// Flags: --harmony-generators --expose-gc
// Test generator iteration.
Index: test/mjsunit/harmony/iteration-semantics.js
diff --git a/test/mjsunit/harmony/iteration-semantics.js
b/test/mjsunit/harmony/iteration-semantics.js
index
de4719e46f29988987ecbcf3b3eada274edf7087..7849b29abe09da629e12f71f841450907f2b88de
100644
--- a/test/mjsunit/harmony/iteration-semantics.js
+++ b/test/mjsunit/harmony/iteration-semantics.js
@@ -25,7 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-iteration
// Flags: --harmony-generators --harmony-scoping --harmony-proxies
// Test for-of semantics.
Index: test/mjsunit/harmony/iteration-syntax.js
diff --git a/test/mjsunit/harmony/iteration-syntax.js
b/test/mjsunit/harmony/iteration-syntax.js
index
015523dae62e416f0586e349c90d9f5c7f486a41..356a97898a363b1eb750110ef96eac7d3f2290de
100644
--- a/test/mjsunit/harmony/iteration-syntax.js
+++ b/test/mjsunit/harmony/iteration-syntax.js
@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-iteration --harmony-scoping --use-strict
+// Flags: --harmony-scoping --use-strict
// Test for-of syntax.
Index: test/mjsunit/harmony/proxies.js
diff --git a/test/mjsunit/harmony/proxies.js
b/test/mjsunit/harmony/proxies.js
index
00e605f8d2d80bbab152d9ee8dafe88be6c5effb..b082c066969f0f5f0d6c982f8ac9affb64dbaa6a
100644
--- a/test/mjsunit/harmony/proxies.js
+++ b/test/mjsunit/harmony/proxies.js
@@ -1807,7 +1807,7 @@ TestKeysThrow({
},
})
-TestKeysThrow([], {
+TestKeysThrow({
get getOwnPropertyNames() {
return function() { return [1, 2] }
},
Index: test/mjsunit/harmony/regress/regress-crbug-248025.js
diff --git a/test/mjsunit/harmony/regress/regress-crbug-248025.js
b/test/mjsunit/harmony/regress/regress-crbug-248025.js
index
c5988595663c9622853e98585ed4a4e9bed089b1..b7982cda7442860018825da64b537aaa9c9b9d43
100644
--- a/test/mjsunit/harmony/regress/regress-crbug-248025.js
+++ b/test/mjsunit/harmony/regress/regress-crbug-248025.js
@@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-iteration
-
// Filler long enough to trigger lazy parsing.
var filler = "//" + new Array(1024).join('x');
Index: test/mjsunit/harmony/string-iterator.js
diff --git a/test/mjsunit/harmony/string-iterator.js
b/test/mjsunit/harmony/string-iterator.js
index
3e371781a548c1ce99e451fd6f2c69260d814fbb..e6bea6dfe76a286b7c7e22cf632e9ad389c5a46a
100644
--- a/test/mjsunit/harmony/string-iterator.js
+++ b/test/mjsunit/harmony/string-iterator.js
@@ -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-iteration
-
function TestStringPrototypeIterator() {
assertTrue(String.prototype.hasOwnProperty(Symbol.iterator));
Index: test/mjsunit/harmony/typed-array-iterator.js
diff --git a/test/mjsunit/harmony/typed-array-iterator.js
b/test/mjsunit/harmony/typed-array-iterator.js
index
8559dfe9af0deff2cd84354981c03063af927196..a2e4906c191c7b81137052da7e027aea15185c3c
100644
--- a/test/mjsunit/harmony/typed-array-iterator.js
+++ b/test/mjsunit/harmony/typed-array-iterator.js
@@ -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-iteration
-
var constructors = [Uint8Array, Int8Array,
Uint16Array, Int16Array,
Index: tools/gyp/v8.gyp
diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
index
967497bfb5782b83ce314f84f49305adb2769330..4de9d2c3f30b73344b46b3a9243db5c21b15c525
100644
--- a/tools/gyp/v8.gyp
+++ b/tools/gyp/v8.gyp
@@ -1408,13 +1408,13 @@
'../../src/collection.js',
'../../src/collection-iterator.js',
'../../src/macros.py',
+ '../../src/array-iterator.js',
+ '../../src/string-iterator.js'
],
'experimental_library_files': [
'../../src/macros.py',
'../../src/proxy.js',
'../../src/generator.js',
- '../../src/array-iterator.js',
- '../../src/string-iterator.js',
'../../src/harmony-string.js',
'../../src/harmony-array.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.