Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(890)

Unified Diff: src/parser.cc

Issue 1085263003: Eagerly declare eval scopes, even for sloppy scopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Rebase Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/runtime/runtime-scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 23d9aa864ebdb5b16c8106b6ddbf982ce2102519..fa47a98c6afdbe7aa2cf904b38fc8ad342e0a78d 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -977,9 +977,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
}
original_scope_ = scope;
if (info->is_eval()) {
- if (!scope->is_script_scope() || is_strict(info->language_mode())) {
- scope = NewScope(scope, EVAL_SCOPE);
- }
+ scope = NewScope(scope, EVAL_SCOPE);
} else if (info->is_module()) {
scope = NewScope(scope, MODULE_SCOPE);
}
@@ -1006,10 +1004,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
DCHECK(allow_harmony_modules());
ParseModuleItemList(body, &ok);
} else {
- Scope* eval_scope = nullptr;
- ParseStatementList(body, Token::EOS, info->is_eval(), &eval_scope, &ok);
- if (eval_scope != nullptr)
- eval_scope->set_end_position(scanner()->peek_location().beg_pos);
+ ParseStatementList(body, Token::EOS, &ok);
}
// The parser will peek but not consume EOS. Our scope logically goes all
@@ -1195,7 +1190,7 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info,
void* Parser::ParseStatementList(ZoneList<Statement*>* body, int end_token,
- bool is_eval, Scope** eval_scope, bool* ok) {
+ bool* ok) {
// StatementList ::
// (StatementListItem)* <end_token>
@@ -1267,23 +1262,6 @@ void* Parser::ParseStatementList(ZoneList<Statement*>* body, int end_token,
// Strong mode implies strict mode. If there are several "use strict"
// / "use strong" directives, do the strict mode changes only once.
if (is_sloppy(scope_->language_mode())) {
- // TODO(mstarzinger): Global strict eval calls, need their own scope
- // as specified in ES5 10.4.2(3). The correct fix would be to always
- // add this scope in DoParseProgram(), but that requires adaptations
- // all over the code base, so we go with a quick-fix for now.
- // In the same manner, we have to patch the parsing mode.
- if (is_eval && !scope_->is_eval_scope()) {
- DCHECK(scope_->is_script_scope());
- Scope* scope = NewScope(scope_, EVAL_SCOPE);
- scope->set_start_position(scope_->start_position());
- scope->set_end_position(scope_->end_position());
- scope_ = scope;
- if (eval_scope != NULL) {
- // Caller will correct the positions of the ad hoc eval scope.
- *eval_scope = scope;
- }
- mode_ = PARSE_EAGERLY;
- }
scope_->SetLanguageMode(static_cast<LanguageMode>(
scope_->language_mode() | STRICT_BIT));
}
@@ -4244,7 +4222,7 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
yield, RelocInfo::kNoPosition), zone());
}
- ParseStatementList(body, Token::RBRACE, false, NULL, CHECK_OK);
+ ParseStatementList(body, Token::RBRACE, CHECK_OK);
if (IsGeneratorFunction(kind)) {
VariableProxy* get_proxy = factory()->NewVariableProxy(
« no previous file with comments | « src/parser.h ('k') | src/runtime/runtime-scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698