Commit 56c0acfb authored by Adam Klein's avatar Adam Klein Committed by Commit Bot

[parser] Remove always-true flag --harmony-restrictive-generators

It's been on by default since Chrome 61.

Bug: v8:4806
Change-Id: I748d9008d29997667458649d7bf4999e15ff8615
Reviewed-on: https://chromium-review.googlesource.com/737416
Commit-Queue: Adam Klein <adamk@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48943}
parent 6f1c3b78
......@@ -605,12 +605,10 @@ void DeclarationScope::HoistSloppyBlockFunctions(AstNodeFactory* factory) {
auto declaration =
factory->NewVariableDeclaration(proxy, kNoSourcePosition);
// Based on the preceding checks, it doesn't matter what we pass as
// allow_harmony_restrictive_generators and
// sloppy_mode_block_scope_function_redefinition.
bool ok = true;
DeclareVariable(declaration, VAR,
Variable::DefaultInitializationFlag(VAR), false, nullptr,
&ok);
Variable::DefaultInitializationFlag(VAR), nullptr, &ok);
DCHECK(ok);
} else {
DCHECK(is_being_lazily_parsed_);
......@@ -1078,7 +1076,6 @@ Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode,
Variable* Scope::DeclareVariable(
Declaration* declaration, VariableMode mode, InitializationFlag init,
bool allow_harmony_restrictive_generators,
bool* sloppy_mode_block_scope_function_redefinition, bool* ok) {
DCHECK(IsDeclaredVariableMode(mode));
DCHECK(!already_resolved_);
......@@ -1087,8 +1084,8 @@ Variable* Scope::DeclareVariable(
if (mode == VAR && !is_declaration_scope()) {
return GetDeclarationScope()->DeclareVariable(
declaration, mode, init, allow_harmony_restrictive_generators,
sloppy_mode_block_scope_function_redefinition, ok);
declaration, mode, init, sloppy_mode_block_scope_function_redefinition,
ok);
}
DCHECK(!is_catch_scope());
DCHECK(!is_with_scope());
......@@ -1149,8 +1146,7 @@ Variable* Scope::DeclareVariable(
map->Lookup(const_cast<AstRawString*>(name),
name->Hash()) != nullptr &&
!IsAsyncFunction(function_kind) &&
!(allow_harmony_restrictive_generators &&
IsGeneratorFunction(function_kind));
!IsGeneratorFunction(function_kind);
}
if (duplicate_allowed) {
*sloppy_mode_block_scope_function_redefinition = true;
......
......@@ -196,7 +196,6 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
Variable* DeclareVariable(Declaration* declaration, VariableMode mode,
InitializationFlag init,
bool allow_harmony_restrictive_generators,
bool* sloppy_mode_block_scope_function_redefinition,
bool* ok);
......
......@@ -4253,7 +4253,6 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_generators)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_tostring)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_class_fields)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_rest_spread)
......
......@@ -223,8 +223,6 @@ DEFINE_IMPLICATION(harmony_import_meta, harmony_dynamic_import)
#define HARMONY_SHIPPING_BASE(V) \
V(harmony_strict_legacy_accessor_builtins, \
"treat __defineGetter__ and related functions as strict") \
V(harmony_restrictive_generators, \
"harmony restrictions on generator declarations") \
V(harmony_object_rest_spread, "harmony object rest spread properties") \
V(harmony_sharedarraybuffer, "harmony sharedarraybuffer") \
V(harmony_regexp_dotall, "harmony regexp dotAll flag") \
......
......@@ -274,7 +274,6 @@ class ParserBase {
allow_natives_(false),
allow_harmony_do_expressions_(false),
allow_harmony_function_sent_(false),
allow_harmony_restrictive_generators_(false),
allow_harmony_class_fields_(false),
allow_harmony_object_rest_spread_(false),
allow_harmony_dynamic_import_(false),
......@@ -289,7 +288,6 @@ class ParserBase {
ALLOW_ACCESSORS(natives);
ALLOW_ACCESSORS(harmony_do_expressions);
ALLOW_ACCESSORS(harmony_function_sent);
ALLOW_ACCESSORS(harmony_restrictive_generators);
ALLOW_ACCESSORS(harmony_class_fields);
ALLOW_ACCESSORS(harmony_object_rest_spread);
ALLOW_ACCESSORS(harmony_dynamic_import);
......@@ -1520,7 +1518,6 @@ class ParserBase {
bool allow_natives_;
bool allow_harmony_do_expressions_;
bool allow_harmony_function_sent_;
bool allow_harmony_restrictive_generators_;
bool allow_harmony_class_fields_;
bool allow_harmony_object_rest_spread_;
bool allow_harmony_dynamic_import_;
......@@ -4028,9 +4025,9 @@ ParserBase<Impl>::ParseHoistableDeclaration(
// sloppy_block_function_map. Don't add them to the map for async functions.
// Generators are also supposed to be prohibited; currently doing this behind
// a flag and UseCounting violations to assess web compatibility.
bool is_sloppy_block_function =
is_sloppy(language_mode()) && !scope()->is_declaration_scope() &&
!is_async && !(allow_harmony_restrictive_generators() && is_generator);
bool is_sloppy_block_function = is_sloppy(language_mode()) &&
!scope()->is_declaration_scope() &&
!is_async && !is_generator;
return impl()->DeclareFunction(variable_name, function, mode, pos,
is_sloppy_block_function, names, ok);
......
......@@ -540,7 +540,6 @@ Parser::Parser(ParseInfo* info)
set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
set_allow_harmony_do_expressions(FLAG_harmony_do_expressions);
set_allow_harmony_function_sent(FLAG_harmony_function_sent);
set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators);
set_allow_harmony_class_fields(FLAG_harmony_class_fields);
set_allow_harmony_object_rest_spread(FLAG_harmony_object_rest_spread);
set_allow_harmony_dynamic_import(FLAG_harmony_dynamic_import);
......@@ -1433,8 +1432,8 @@ Variable* Parser::Declare(Declaration* declaration,
}
bool sloppy_mode_block_scope_function_redefinition = false;
Variable* variable = scope->DeclareVariable(
declaration, mode, init, allow_harmony_restrictive_generators(),
&sloppy_mode_block_scope_function_redefinition, ok);
declaration, mode, init, &sloppy_mode_block_scope_function_redefinition,
ok);
if (!*ok) {
// If we only have the start position of a proxy, we can't highlight the
// whole variable name. Pretend its length is 1 so that we highlight at
......
......@@ -296,7 +296,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
SET_ALLOW(harmony_import_meta);
SET_ALLOW(harmony_async_iteration);
SET_ALLOW(harmony_template_escapes);
SET_ALLOW(harmony_restrictive_generators);
SET_ALLOW(harmony_bigint);
#undef SET_ALLOW
}
......
......@@ -1311,7 +1311,6 @@ enum ParserFlag {
kAllowLazy,
kAllowNatives,
kAllowHarmonyFunctionSent,
kAllowHarmonyRestrictiveGenerators,
kAllowHarmonyClassFields,
kAllowHarmonyObjectRestSpread,
kAllowHarmonyDynamicImport,
......@@ -1329,8 +1328,6 @@ enum ParserSyncTestResult {
void SetGlobalFlags(i::EnumSet<ParserFlag> flags) {
i::FLAG_allow_natives_syntax = flags.Contains(kAllowNatives);
i::FLAG_harmony_function_sent = flags.Contains(kAllowHarmonyFunctionSent);
i::FLAG_harmony_restrictive_generators =
flags.Contains(kAllowHarmonyRestrictiveGenerators);
i::FLAG_harmony_class_fields = flags.Contains(kAllowHarmonyClassFields);
i::FLAG_harmony_object_rest_spread =
flags.Contains(kAllowHarmonyObjectRestSpread);
......@@ -1345,8 +1342,6 @@ void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) {
parser->set_allow_natives(flags.Contains(kAllowNatives));
parser->set_allow_harmony_function_sent(
flags.Contains(kAllowHarmonyFunctionSent));
parser->set_allow_harmony_restrictive_generators(
flags.Contains(kAllowHarmonyRestrictiveGenerators));
parser->set_allow_harmony_class_fields(
flags.Contains(kAllowHarmonyClassFields));
parser->set_allow_harmony_object_rest_spread(
......@@ -8795,14 +8790,11 @@ TEST(NoDuplicateGeneratorsInBlock) {
const char* error_data[] = {"function* x() {} function* x() {}",
"function x() {} function* x() {}",
"function* x() {} function x() {}", nullptr};
static const ParserFlag always_flags[] = {kAllowHarmonyRestrictiveGenerators};
// The preparser doesn't enforce the restriction, so turn it off.
bool test_preparser = false;
RunParserSyncTest(block_context_data, error_data, kError, nullptr, 0,
always_flags, arraysize(always_flags), nullptr, 0, false,
test_preparser);
RunParserSyncTest(top_level_context_data, error_data, kSuccess, nullptr, 0,
always_flags, arraysize(always_flags));
RunParserSyncTest(block_context_data, error_data, kError, nullptr, 0, nullptr,
0, nullptr, 0, false, test_preparser);
RunParserSyncTest(top_level_context_data, error_data, kSuccess);
}
TEST(NoDuplicateAsyncFunctionInBlock) {
......
......@@ -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-restrictive-generators
// Generators don't get sloppy-mode block-scoped function hoisting
// No hoisting to the global scope
......
// Copyright 2016 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.
// Flags: --no-harmony-restrictive-generators
// In legacy mode, generators get sloppy-mode block-scoped function hoisting
// Hoisting to the global scope
{
function* foo() {}
assertEquals('function', typeof foo);
}
//assertEquals('function', typeof foo);
// Hoisting within a function scope
(function() {
{ function* bar() {} }
assertEquals('function', typeof bar);
})();
// Lexical shadowing allowed; hoisting happens
(function() {
function* x() { yield 1; }
{ function* x() { yield 2 } }
assertEquals(2, x().next().value);
})();
// Duplicates allowed
(function() {
function* y() { yield 1; }
function* y() { yield 2 }
assertEquals(2, y().next().value);
})();
// Functions and generators may duplicate each other
(function() {
function* z() { yield 1; }
function z() { return 2 }
assertEquals(2, z());
function a() { return 1; }
function* a() { yield 2 }
assertEquals(2, a().next().value);
})();
// In strict mode, none of this happens
(function() {
'use strict';
{ function* bar() {} }
assertEquals('undefined', typeof bar);
// Lexical shadowing allowed; hoisting happens
function* x() { yield 1; }
{ function* x() { yield 2 } }
assertEquals(1, x().next().value);
})();
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