Skip to content

Commit a0a8ecd

Browse files
ajkleinCommit bot
authored andcommitted
Remove runtime flags for sloppy mode block scoping features
These were all on by default in M49 without complaint. R=littledan@chromium.org Review URL: https://codereview.chromium.org/1858943002 Cr-Commit-Position: refs/heads/master@{#35342}
1 parent 920370d commit a0a8ecd

64 files changed

Lines changed: 80 additions & 605 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/bootstrapper.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,9 +2379,6 @@ void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate,
23792379
#define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \
23802380
void Genesis::InitializeGlobal_##id() {}
23812381

2382-
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy)
2383-
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_function)
2384-
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let)
23852382
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_observe)
23862383
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode_regexps)
23872384
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions)
@@ -2918,9 +2915,6 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
29182915

29192916
bool Genesis::InstallExperimentalNatives() {
29202917
static const char* harmony_iterator_close_natives[] = {nullptr};
2921-
static const char* harmony_sloppy_natives[] = {nullptr};
2922-
static const char* harmony_sloppy_function_natives[] = {nullptr};
2923-
static const char* harmony_sloppy_let_natives[] = {nullptr};
29242918
static const char* harmony_species_natives[] = {"native harmony-species.js",
29252919
nullptr};
29262920
static const char* harmony_tailcalls_natives[] = {nullptr};

src/flag-definitions.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,6 @@ DEFINE_IMPLICATION(es_staging, move_object_start)
219219
V(harmony_iterator_close, "harmony iterator finalization") \
220220
V(harmony_unicode_regexps, "harmony unicode regexps") \
221221
V(harmony_regexp_exec, "harmony RegExp exec override behavior") \
222-
V(harmony_sloppy, "harmony features in sloppy mode") \
223-
V(harmony_sloppy_let, "harmony let in sloppy mode") \
224-
V(harmony_sloppy_function, "harmony sloppy function block scoping") \
225222
V(harmony_regexp_subclass, "harmony regexp subclassing") \
226223
V(harmony_restrictive_declarations, \
227224
"harmony limitations on sloppy mode function declarations") \
@@ -250,11 +247,6 @@ HARMONY_STAGED(FLAG_STAGED_FEATURES)
250247
HARMONY_SHIPPING(FLAG_SHIPPING_FEATURES)
251248
#undef FLAG_SHIPPING_FEATURES
252249

253-
254-
// Feature dependencies.
255-
DEFINE_IMPLICATION(harmony_sloppy_let, harmony_sloppy)
256-
DEFINE_IMPLICATION(harmony_sloppy_function, harmony_sloppy)
257-
258250
// Flags for experimental implementation features.
259251
DEFINE_BOOL(compiled_keyed_generic_loads, false,
260252
"use optimizing compiler to generate keyed generic load stubs")

src/messages.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,6 @@ class CallSite {
430430
T(SloppyFunction, \
431431
"In non-strict mode code, functions can only be declared at top level, " \
432432
"inside a block, or as the body of an if statement.") \
433-
T(SloppyLexical, \
434-
"Block-scoped declarations (let, const, function, class) not yet " \
435-
"supported outside strict mode") \
436433
T(SpeciesNotConstructor, \
437434
"object.constructor[Symbol.species] is not a constructor") \
438435
T(StrictDelete, "Delete of an unqualified identifier in strict mode.") \

src/parsing/parser-base.h

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ class ParserBase : public Traits {
113113
allow_lazy_(false),
114114
allow_natives_(false),
115115
allow_tailcalls_(false),
116-
allow_harmony_sloppy_(false),
117-
allow_harmony_sloppy_function_(false),
118-
allow_harmony_sloppy_let_(false),
119116
allow_harmony_restrictive_declarations_(false),
120117
allow_harmony_do_expressions_(false),
121118
allow_harmony_function_name_(false),
@@ -134,9 +131,6 @@ class ParserBase : public Traits {
134131
ALLOW_ACCESSORS(lazy);
135132
ALLOW_ACCESSORS(natives);
136133
ALLOW_ACCESSORS(tailcalls);
137-
ALLOW_ACCESSORS(harmony_sloppy);
138-
ALLOW_ACCESSORS(harmony_sloppy_function);
139-
ALLOW_ACCESSORS(harmony_sloppy_let);
140134
ALLOW_ACCESSORS(harmony_restrictive_declarations);
141135
ALLOW_ACCESSORS(harmony_do_expressions);
142136
ALLOW_ACCESSORS(harmony_function_name);
@@ -564,14 +558,6 @@ class ParserBase : public Traits {
564558
LanguageMode language_mode() { return scope_->language_mode(); }
565559
bool is_generator() const { return function_state_->is_generator(); }
566560

567-
bool allow_const() {
568-
return is_strict(language_mode()) || allow_harmony_sloppy();
569-
}
570-
571-
bool allow_let() {
572-
return is_strict(language_mode()) || allow_harmony_sloppy_let();
573-
}
574-
575561
// Report syntax errors.
576562
void ReportMessage(MessageTemplate::Template message, const char* arg = NULL,
577563
ParseErrorType error_type = kSyntaxError) {
@@ -926,9 +912,6 @@ class ParserBase : public Traits {
926912
bool allow_lazy_;
927913
bool allow_natives_;
928914
bool allow_tailcalls_;
929-
bool allow_harmony_sloppy_;
930-
bool allow_harmony_sloppy_function_;
931-
bool allow_harmony_sloppy_let_;
932915
bool allow_harmony_restrictive_declarations_;
933916
bool allow_harmony_do_expressions_;
934917
bool allow_harmony_function_name_;
@@ -1329,11 +1312,6 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
13291312
case Token::CLASS: {
13301313
BindingPatternUnexpectedToken(classifier);
13311314
Consume(Token::CLASS);
1332-
if (!allow_harmony_sloppy() && is_sloppy(language_mode())) {
1333-
ReportMessage(MessageTemplate::kSloppyLexical);
1334-
*ok = false;
1335-
return this->EmptyExpression();
1336-
}
13371315
int class_token_position = position();
13381316
IdentifierT name = this->EmptyIdentifier();
13391317
bool is_strict_reserved_name = false;
@@ -2787,9 +2765,6 @@ void ParserBase<Traits>::CheckArityRestrictions(int param_count,
27872765
template <class Traits>
27882766
bool ParserBase<Traits>::IsNextLetKeyword() {
27892767
DCHECK(peek() == Token::LET);
2790-
if (!allow_let()) {
2791-
return false;
2792-
}
27932768
Token::Value next_next = PeekAhead();
27942769
switch (next_next) {
27952770
case Token::LBRACE:
@@ -2890,9 +2865,7 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
28902865
CheckStrictOctalLiteral(formal_parameters.scope->start_position(),
28912866
scanner()->location().end_pos, CHECK_OK);
28922867
}
2893-
if (is_strict(language_mode()) || allow_harmony_sloppy()) {
2894-
this->CheckConflictingVarDeclarations(formal_parameters.scope, CHECK_OK);
2895-
}
2868+
this->CheckConflictingVarDeclarations(formal_parameters.scope, CHECK_OK);
28962869

28972870
Traits::RewriteDestructuringAssignments();
28982871
}

src/parsing/parser.cc

Lines changed: 11 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,6 @@ Parser::Parser(ParseInfo* info)
786786
set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
787787
set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() &&
788788
info->isolate()->is_tail_call_elimination_enabled());
789-
set_allow_harmony_sloppy(FLAG_harmony_sloppy);
790-
set_allow_harmony_sloppy_function(FLAG_harmony_sloppy_function);
791-
set_allow_harmony_sloppy_let(FLAG_harmony_sloppy_let);
792789
set_allow_harmony_do_expressions(FLAG_harmony_do_expressions);
793790
set_allow_harmony_function_name(FLAG_harmony_function_name);
794791
set_allow_harmony_function_sent(FLAG_harmony_function_sent);
@@ -941,7 +938,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
941938
if (ok && is_strict(language_mode())) {
942939
CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
943940
}
944-
if (ok && is_sloppy(language_mode()) && allow_harmony_sloppy_function()) {
941+
if (ok && is_sloppy(language_mode())) {
945942
// TODO(littledan): Function bindings on the global object that modify
946943
// pre-existing bindings should be made writable, enumerable and
947944
// nonconfigurable if possible, whereas this code will leave attributes
@@ -1258,10 +1255,7 @@ Statement* Parser::ParseStatementListItem(bool* ok) {
12581255
Consume(Token::CLASS);
12591256
return ParseClassDeclaration(NULL, ok);
12601257
case Token::CONST:
1261-
if (allow_const()) {
1262-
return ParseVariableStatement(kStatementListItem, NULL, ok);
1263-
}
1264-
break;
1258+
return ParseVariableStatement(kStatementListItem, NULL, ok);
12651259
case Token::VAR:
12661260
return ParseVariableStatement(kStatementListItem, NULL, ok);
12671261
case Token::LET:
@@ -1909,11 +1903,8 @@ Variable* Parser::Declare(Declaration* declaration,
19091903
}
19101904
var = declaration_scope->DeclareLocal(
19111905
name, mode, declaration->initialization(), kind, kNotAssigned);
1912-
} else if ((IsLexicalVariableMode(mode) ||
1913-
IsLexicalVariableMode(var->mode())) &&
1914-
// Lexical bindings may appear for some parameters in sloppy
1915-
// mode even with --harmony-sloppy off.
1916-
(is_strict(language_mode()) || allow_harmony_sloppy())) {
1906+
} else if (IsLexicalVariableMode(mode) ||
1907+
IsLexicalVariableMode(var->mode())) {
19171908
// Allow duplicate function decls for web compat, see bug 4693.
19181909
if (is_sloppy(language_mode()) && is_function_declaration &&
19191910
var->is_function()) {
@@ -2103,19 +2094,14 @@ Statement* Parser::ParseFunctionDeclaration(
21032094
// initial value upon entering the corresponding scope.
21042095
// In ES6, a function behaves as a lexical binding, except in
21052096
// a script scope, or the initial scope of eval or another function.
2106-
VariableMode mode =
2107-
(is_strict(language_mode()) || allow_harmony_sloppy_function()) &&
2108-
!scope_->is_declaration_scope()
2109-
? LET
2110-
: VAR;
2097+
VariableMode mode = !scope_->is_declaration_scope() ? LET : VAR;
21112098
VariableProxy* proxy = NewUnresolved(name, mode);
21122099
Declaration* declaration =
21132100
factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos);
21142101
Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK);
21152102
if (names) names->Add(name, zone());
21162103
EmptyStatement* empty = factory()->NewEmptyStatement(RelocInfo::kNoPosition);
2117-
if (is_sloppy(language_mode()) && allow_harmony_sloppy_function() &&
2118-
!scope_->is_declaration_scope()) {
2104+
if (is_sloppy(language_mode()) && !scope_->is_declaration_scope()) {
21192105
SloppyBlockFunctionStatement* delegate =
21202106
factory()->NewSloppyBlockFunctionStatement(empty, scope_);
21212107
scope_->DeclarationScope()->sloppy_block_function_map()->Declare(name,
@@ -2143,12 +2129,6 @@ Statement* Parser::ParseClassDeclaration(ZoneList<const AstRawString*>* names,
21432129
//
21442130
// so rewrite it as such.
21452131

2146-
if (!allow_harmony_sloppy() && is_sloppy(language_mode())) {
2147-
ReportMessage(MessageTemplate::kSloppyLexical);
2148-
*ok = false;
2149-
return NULL;
2150-
}
2151-
21522132
int pos = position();
21532133
bool is_strict_reserved = false;
21542134
const AstRawString* name =
@@ -2279,12 +2259,11 @@ Block* Parser::ParseVariableDeclarations(
22792259

22802260
if (peek() == Token::VAR) {
22812261
Consume(Token::VAR);
2282-
} else if (peek() == Token::CONST && allow_const()) {
2262+
} else if (peek() == Token::CONST) {
22832263
Consume(Token::CONST);
2284-
DCHECK(is_strict(language_mode()) || allow_harmony_sloppy());
22852264
DCHECK(var_context != kStatement);
22862265
parsing_result->descriptor.mode = CONST;
2287-
} else if (peek() == Token::LET && allow_let()) {
2266+
} else if (peek() == Token::LET) {
22882267
Consume(Token::LET);
22892268
DCHECK(var_context != kStatement);
22902269
parsing_result->descriptor.mode = LET;
@@ -2493,15 +2472,6 @@ Statement* Parser::ParseExpressionOrLabelledStatement(
24932472
}
24942473

24952474
// Parsed expression statement, followed by semicolon.
2496-
// Detect attempts at 'let' declarations in sloppy mode.
2497-
if (!allow_harmony_sloppy_let() && peek() == Token::IDENTIFIER &&
2498-
expr->AsVariableProxy() != NULL &&
2499-
expr->AsVariableProxy()->raw_name() ==
2500-
ast_value_factory()->let_string()) {
2501-
ReportMessage(MessageTemplate::kSloppyLexical, NULL);
2502-
*ok = false;
2503-
return NULL;
2504-
}
25052475
ExpectSemicolon(CHECK_OK);
25062476
return factory()->NewExpressionStatement(expr, pos);
25072477
}
@@ -3497,10 +3467,9 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
34973467
Expect(Token::FOR, CHECK_OK);
34983468
Expect(Token::LPAREN, CHECK_OK);
34993469
for_scope->set_start_position(scanner()->location().beg_pos);
3500-
bool is_let_identifier_expression = false;
35013470
DeclarationParsingResult parsing_result;
35023471
if (peek() != Token::SEMICOLON) {
3503-
if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) ||
3472+
if (peek() == Token::VAR || peek() == Token::CONST ||
35043473
(peek() == Token::LET && IsNextLetKeyword())) {
35053474
ParseVariableDeclarations(kForStatement, &parsing_result, nullptr,
35063475
CHECK_OK);
@@ -3673,10 +3642,6 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
36733642
Expression* expression = ParseExpression(false, &classifier, CHECK_OK);
36743643
int lhs_end_pos = scanner()->location().end_pos;
36753644
ForEachStatement::VisitMode mode = ForEachStatement::ENUMERATE;
3676-
is_let_identifier_expression =
3677-
expression->IsVariableProxy() &&
3678-
expression->AsVariableProxy()->raw_name() ==
3679-
ast_value_factory()->let_string();
36803645

36813646
bool is_for_each = CheckInOrOf(&mode, ok);
36823647
if (!*ok) return nullptr;
@@ -3737,13 +3702,6 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
37373702
Target target(&this->target_stack_, loop);
37383703

37393704
// Parsed initializer at this point.
3740-
// Detect attempts at 'let' declarations in sloppy mode.
3741-
if (!allow_harmony_sloppy_let() && peek() == Token::IDENTIFIER &&
3742-
is_sloppy(language_mode()) && is_let_identifier_expression) {
3743-
ReportMessage(MessageTemplate::kSloppyLexical, NULL);
3744-
*ok = false;
3745-
return NULL;
3746-
}
37473705
Expect(Token::SEMICOLON, CHECK_OK);
37483706

37493707
Expression* cond = NULL;
@@ -4039,42 +3997,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
40393997
function_name = ast_value_factory()->empty_string();
40403998
}
40413999

4042-
// Function declarations are function scoped in normal mode, so they are
4043-
// hoisted. In harmony block scoping mode they are block scoped, so they
4044-
// are not hoisted.
4045-
//
4046-
// One tricky case are function declarations in a local sloppy-mode eval:
4047-
// their declaration is hoisted, but they still see the local scope. E.g.,
4048-
//
4049-
// function() {
4050-
// var x = 0
4051-
// try { throw 1 } catch (x) { eval("function g() { return x }") }
4052-
// return g()
4053-
// }
4054-
//
4055-
// needs to return 1. To distinguish such cases, we need to detect
4056-
// (1) whether a function stems from a sloppy eval, and
4057-
// (2) whether it actually hoists across the eval.
4058-
// Unfortunately, we do not represent sloppy eval scopes, so we do not have
4059-
// either information available directly, especially not when lazily compiling
4060-
// a function like 'g'. We hence rely on the following invariants:
4061-
// - (1) is the case iff the innermost scope of the deserialized scope chain
4062-
// under which we compile is _not_ a declaration scope. This holds because
4063-
// in all normal cases, function declarations are fully hoisted to a
4064-
// declaration scope and compiled relative to that.
4065-
// - (2) is the case iff the current declaration scope is still the original
4066-
// one relative to the deserialized scope chain. Otherwise we must be
4067-
// compiling a function in an inner declaration scope in the eval, e.g. a
4068-
// nested function, and hoisting works normally relative to that.
4069-
Scope* declaration_scope = scope_->DeclarationScope();
4070-
Scope* original_declaration_scope = original_scope_->DeclarationScope();
4071-
Scope* scope = function_type == FunctionLiteral::kDeclaration &&
4072-
is_sloppy(language_mode) &&
4073-
!allow_harmony_sloppy_function() &&
4074-
(original_scope_ == original_declaration_scope ||
4075-
declaration_scope != original_declaration_scope)
4076-
? NewScope(declaration_scope, FUNCTION_SCOPE, kind)
4077-
: NewScope(scope_, FUNCTION_SCOPE, kind);
4000+
Scope* scope = NewScope(scope_, FUNCTION_SCOPE, kind);
40784001
SetLanguageMode(scope, language_mode);
40794002
ZoneList<Statement*>* body = NULL;
40804003
int arity = -1;
@@ -4249,7 +4172,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
42494172
CheckStrictOctalLiteral(scope->start_position(), scope->end_position(),
42504173
CHECK_OK);
42514174
}
4252-
if (is_sloppy(language_mode) && allow_harmony_sloppy_function()) {
4175+
if (is_sloppy(language_mode)) {
42534176
InsertSloppyBlockFunctionVarBindings(scope, CHECK_OK);
42544177
}
42554178
CheckConflictingVarDeclarations(scope, CHECK_OK);
@@ -4673,9 +4596,6 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
46734596
reusable_preparser_->set_allow_lazy(true);
46744597
#define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
46754598
SET_ALLOW(natives);
4676-
SET_ALLOW(harmony_sloppy);
4677-
SET_ALLOW(harmony_sloppy_function);
4678-
SET_ALLOW(harmony_sloppy_let);
46794599
SET_ALLOW(harmony_do_expressions);
46804600
SET_ALLOW(harmony_function_name);
46814601
SET_ALLOW(harmony_function_sent);

0 commit comments

Comments
 (0)