Enable ES6 iteration by default
authorwingo@igalia.com <wingo@igalia.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 7 Aug 2014 16:42:14 +0000 (16:42 +0000)
committerwingo@igalia.com <wingo@igalia.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 7 Aug 2014 16:42:14 +0000 (16:42 +0000)
This enables for-of, as well as @@iterator implementations for strings
and arrays.

R=rossberg@chromium.org
BUG=v8:2214
LOG=Y

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22980 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

20 files changed:
BUILD.gn
src/bootstrapper.cc
src/flag-definitions.h
src/parser.cc
src/preparser.cc
src/preparser.h
src/unscopables.js
test/cctest/test-parsing.cc
test/mjsunit/builtins.js
test/mjsunit/debug-script.js
test/mjsunit/es6/array-iterator.js [moved from test/mjsunit/harmony/array-iterator.js with 99% similarity]
test/mjsunit/es6/iteration-semantics.js [moved from test/mjsunit/harmony/iteration-semantics.js with 99% similarity]
test/mjsunit/es6/iteration-syntax.js [moved from test/mjsunit/harmony/iteration-syntax.js with 98% similarity]
test/mjsunit/es6/regress/regress-crbug-248025.js [moved from test/mjsunit/harmony/regress/regress-crbug-248025.js with 98% similarity]
test/mjsunit/es6/string-iterator.js [moved from test/mjsunit/harmony/string-iterator.js with 98% similarity]
test/mjsunit/es6/typed-array-iterator.js [moved from test/mjsunit/harmony/typed-array-iterator.js with 98% similarity]
test/mjsunit/harmony/generators-iteration.js
test/mjsunit/harmony/proxies.js
test/mjsunit/mjsunit.status
tools/gyp/v8.gyp

index 39c1dc7..c2c1730 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -200,6 +200,8 @@ action("js2c") {
     "src/promise.js",
     "src/object-observe.js",
     "src/macros.py",
+    "src/array-iterator.js",
+    "src/string-iterator.js",
   ]
 
   outputs = [
@@ -238,7 +240,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",
     "src/unscopables.js",
index 44803f8..a3b3742 100644 (file)
@@ -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;
@@ -2060,8 +2060,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")
     INSTALL_EXPERIMENTAL_NATIVE(i, unscopables, "unscopables.js")
index b4e9423..fbe1ed7 100644 (file)
@@ -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")
@@ -175,7 +174,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 48e8c4a..6c941da 100644 (file)
@@ -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;
   }
@@ -3741,7 +3739,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 1336857..7ce8e3d 100644 (file)
@@ -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 b00cbbb..8a93258 100644 (file)
@@ -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) {
@@ -570,7 +567,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 0d70ac6..fc030c6 100644 (file)
@@ -8,14 +8,14 @@
 // var $Array = global.Array;
 // var $Symbol = global.Symbol;
 
-function ExtendSymbol() {
+function UnscopablesExtendSymbol() {
   %CheckIsBootstrapping();
   InstallConstants($Symbol, $Array(
     "unscopables", symbolUnscopables
   ));
 }
 
-ExtendSymbol();
+UnscopablesExtendSymbol();
 
 
 var arrayUnscopables = {
@@ -30,10 +30,10 @@ var arrayUnscopables = {
 };
 
 
-function ExtendArrayPrototype() {
+function UnscopablesExtendArrayPrototype() {
   %CheckIsBootstrapping();
   %AddNamedProperty($Array.prototype, symbolUnscopables, arrayUnscopables,
                     DONT_ENUM | READ_ONLY);
 }
 
-ExtendArrayPrototype();
+UnscopablesExtendArrayPrototype();
index 74ece30..9cb5d69 100644 (file)
@@ -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 3c92af8..fe7d35d 100644 (file)
@@ -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 54e80e0..5b5e759 100644 (file)
@@ -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
similarity index 99%
rename from test/mjsunit/harmony/array-iterator.js
rename to test/mjsunit/es6/array-iterator.js
index 2328876..63a7415 100644 (file)
@@ -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;
similarity index 99%
rename from test/mjsunit/harmony/iteration-semantics.js
rename to test/mjsunit/es6/iteration-semantics.js
index de4719e..7849b29 100644 (file)
@@ -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.
similarity index 98%
rename from test/mjsunit/harmony/iteration-syntax.js
rename to test/mjsunit/es6/iteration-syntax.js
index 015523d..356a978 100644 (file)
@@ -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.
 
@@ -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');
 
similarity index 98%
rename from test/mjsunit/harmony/string-iterator.js
rename to test/mjsunit/es6/string-iterator.js
index 3e37178..e6bea6d 100644 (file)
@@ -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));
similarity index 98%
rename from test/mjsunit/harmony/typed-array-iterator.js
rename to test/mjsunit/es6/typed-array-iterator.js
index 8559dfe..a2e4906 100644 (file)
@@ -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 e60e2a9..1a79367 100644 (file)
@@ -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 00e605f..b082c06 100644 (file)
@@ -1807,7 +1807,7 @@ TestKeysThrow({
   },
 })
 
-TestKeysThrow([], {
+TestKeysThrow({
   get getOwnPropertyNames() {
     return function() { return [1, 2] }
   },
index fe22d1b..7728d5e 100644 (file)
   'harmony/regress/regress-3280': [PASS, NO_VARIANTS],
 
   # Support for ES6 for-of iteration is missing.
-  'harmony/array-iterator': [PASS, NO_VARIANTS],
-  'harmony/iteration-semantics': [PASS, NO_VARIANTS],
-  'harmony/string-iterator': [PASS, NO_VARIANTS],
-  'harmony/typed-array-iterator': [PASS, NO_VARIANTS],
+  'es6/array-iterator': [PASS, NO_VARIANTS],
+  'es6/iteration-semantics': [PASS, NO_VARIANTS],
+  'es6/string-iterator': [PASS, NO_VARIANTS],
+  'es6/typed-array-iterator': [PASS, NO_VARIANTS],
 
   ##############################################################################
   # Too slow in debug mode with --stress-opt mode.
index 7853a43..5da1d88 100644 (file)
           '../../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',
           '../../src/unscopables.js',