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

Unified Diff: src/ast/scopes.cc

Issue 2367483003: Remove ARGUMENTS_VARIABLE and fix crankshaft to properly detect the arguments object and keep it al… (Closed)
Patch Set: Rebaseline more Created 4 years, 3 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 | « no previous file | src/ast/variables.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 9c5395a0c32f8d0cf60cbdef436704398e803d03..cd0c1eacd4d8199e8e4879601d275dc680878419 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -586,21 +586,17 @@ void DeclarationScope::DeclareArguments(AstValueFactory* ast_value_factory) {
DCHECK(is_function_scope());
DCHECK(!is_arrow_scope());
- // Check if there's lexically declared variable named arguments to avoid
- // redeclaration. See ES#sec-functiondeclarationinstantiation, step 20.
- Variable* arg_variable = LookupLocal(ast_value_factory->arguments_string());
- if (arg_variable != nullptr && IsLexicalVariableMode(arg_variable->mode())) {
- return;
- }
-
- // Declare 'arguments' variable which exists in all non arrow functions.
- // Note that it might never be accessed, in which case it won't be
- // allocated during variable allocation.
- if (arg_variable == nullptr) {
+ arguments_ = LookupLocal(ast_value_factory->arguments_string());
+ if (arguments_ == nullptr) {
+ // Declare 'arguments' variable which exists in all non arrow functions.
+ // Note that it might never be accessed, in which case it won't be
+ // allocated during variable allocation.
arguments_ = Declare(zone(), this, ast_value_factory->arguments_string(),
- VAR, ARGUMENTS_VARIABLE, kCreatedInitialized);
- } else {
- arguments_ = arg_variable;
+ VAR, NORMAL_VARIABLE, kCreatedInitialized);
+ } else if (IsLexicalVariableMode(arguments_->mode())) {
+ // Check if there's lexically declared variable named arguments to avoid
+ // redeclaration. See ES#sec-functiondeclarationinstantiation, step 20.
+ arguments_ = nullptr;
}
}
« no previous file with comments | « no previous file | src/ast/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698