Commit cebddb66 authored by wingo@igalia.com's avatar wingo@igalia.com

Enable ES6 iteration by default

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
parent a1f3f024
......@@ -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",
......
......@@ -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")
......
......@@ -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,
......
......@@ -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());
......
......@@ -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;
......
......@@ -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.
......
......@@ -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();
......@@ -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;
......
......@@ -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) {
......
......@@ -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
......
......@@ -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;
......
......@@ -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.
......
......@@ -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');
......
......@@ -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));
......
......@@ -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,
......
......@@ -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.
......
......@@ -1807,7 +1807,7 @@ TestKeysThrow({
},
})
TestKeysThrow([], {
TestKeysThrow({
get getOwnPropertyNames() {
return function() { return [1, 2] }
},
......
......@@ -155,10 +155,10 @@
'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.
......
......@@ -1409,13 +1409,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',
'../../src/unscopables.js',
......
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