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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/ast/variables.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/ast/scopes.h" 5 #include "src/ast/scopes.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 zone(), this, ast_value_factory->this_string(), 579 zone(), this, ast_value_factory->this_string(),
580 subclass_constructor ? CONST : VAR, THIS_VARIABLE, 580 subclass_constructor ? CONST : VAR, THIS_VARIABLE,
581 subclass_constructor ? kNeedsInitialization : kCreatedInitialized); 581 subclass_constructor ? kNeedsInitialization : kCreatedInitialized);
582 receiver_ = var; 582 receiver_ = var;
583 } 583 }
584 584
585 void DeclarationScope::DeclareArguments(AstValueFactory* ast_value_factory) { 585 void DeclarationScope::DeclareArguments(AstValueFactory* ast_value_factory) {
586 DCHECK(is_function_scope()); 586 DCHECK(is_function_scope());
587 DCHECK(!is_arrow_scope()); 587 DCHECK(!is_arrow_scope());
588 588
589 // Check if there's lexically declared variable named arguments to avoid 589 arguments_ = LookupLocal(ast_value_factory->arguments_string());
590 // redeclaration. See ES#sec-functiondeclarationinstantiation, step 20. 590 if (arguments_ == nullptr) {
591 Variable* arg_variable = LookupLocal(ast_value_factory->arguments_string()); 591 // Declare 'arguments' variable which exists in all non arrow functions.
592 if (arg_variable != nullptr && IsLexicalVariableMode(arg_variable->mode())) { 592 // Note that it might never be accessed, in which case it won't be
593 return; 593 // allocated during variable allocation.
594 }
595
596 // Declare 'arguments' variable which exists in all non arrow functions.
597 // Note that it might never be accessed, in which case it won't be
598 // allocated during variable allocation.
599 if (arg_variable == nullptr) {
600 arguments_ = Declare(zone(), this, ast_value_factory->arguments_string(), 594 arguments_ = Declare(zone(), this, ast_value_factory->arguments_string(),
601 VAR, ARGUMENTS_VARIABLE, kCreatedInitialized); 595 VAR, NORMAL_VARIABLE, kCreatedInitialized);
602 } else { 596 } else if (IsLexicalVariableMode(arguments_->mode())) {
603 arguments_ = arg_variable; 597 // Check if there's lexically declared variable named arguments to avoid
598 // redeclaration. See ES#sec-functiondeclarationinstantiation, step 20.
599 arguments_ = nullptr;
604 } 600 }
605 } 601 }
606 602
607 void DeclarationScope::DeclareDefaultFunctionVariables( 603 void DeclarationScope::DeclareDefaultFunctionVariables(
608 AstValueFactory* ast_value_factory) { 604 AstValueFactory* ast_value_factory) {
609 DCHECK(is_function_scope()); 605 DCHECK(is_function_scope());
610 DCHECK(!is_arrow_scope()); 606 DCHECK(!is_arrow_scope());
611 607
612 new_target_ = Declare(zone(), this, ast_value_factory->new_target_string(), 608 new_target_ = Declare(zone(), this, ast_value_factory->new_target_string(),
613 CONST, NORMAL_VARIABLE, kCreatedInitialized); 609 CONST, NORMAL_VARIABLE, kCreatedInitialized);
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 Variable* function = 1827 Variable* function =
1832 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 1828 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
1833 bool is_function_var_in_context = 1829 bool is_function_var_in_context =
1834 function != nullptr && function->IsContextSlot(); 1830 function != nullptr && function->IsContextSlot();
1835 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1831 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1836 (is_function_var_in_context ? 1 : 0); 1832 (is_function_var_in_context ? 1 : 0);
1837 } 1833 }
1838 1834
1839 } // namespace internal 1835 } // namespace internal
1840 } // namespace v8 1836 } // namespace v8
OLDNEW
« 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