Chromium Code Reviews| Index: src/ast/scopes.cc |
| diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
| index f003f8c37a148a9d56b74507a925a9ea7b610a70..5249d6f519f4927976ea559c469a503f61b6e21e 100644 |
| --- a/src/ast/scopes.cc |
| +++ b/src/ast/scopes.cc |
| @@ -172,6 +172,7 @@ void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope, |
| scope_inside_with_ = false; |
| scope_calls_eval_ = false; |
| scope_uses_arguments_ = false; |
| + has_arguments_parameter_ = false; |
| scope_uses_super_property_ = false; |
| asm_module_ = false; |
| asm_function_ = outer_scope != NULL && outer_scope->asm_module_; |
| @@ -508,6 +509,9 @@ Variable* Scope::DeclareParameter( |
| rest_index_ = num_parameters(); |
| } |
| params_.Add(var, zone()); |
| + if (name == ast_value_factory_->arguments_string()) { |
| + has_arguments_parameter_ = true; |
| + } |
| return var; |
| } |
| @@ -722,7 +726,7 @@ bool Scope::AllocateVariables(ParseInfo* info, AstNodeFactory* factory) { |
| if (!ResolveVariablesRecursively(info, factory)) return false; |
| // 3) Allocate variables. |
| - AllocateVariablesRecursively(info->isolate()); |
| + AllocateVariablesRecursively(); |
| return true; |
| } |
| @@ -1305,17 +1309,6 @@ bool Scope::MustAllocateInContext(Variable* var) { |
| } |
| -bool Scope::HasArgumentsParameter(Isolate* isolate) { |
| - for (int i = 0; i < params_.length(); i++) { |
| - if (params_[i]->name().is_identical_to( |
| - isolate->factory()->arguments_string())) { |
| - return true; |
| - } |
| - } |
| - return false; |
| -} |
| - |
| - |
| void Scope::AllocateStackSlot(Variable* var) { |
| if (is_block_scope()) { |
| outer_scope()->DeclarationScope()->AllocateStackSlot(var); |
| @@ -1329,8 +1322,7 @@ void Scope::AllocateHeapSlot(Variable* var) { |
| var->AllocateTo(VariableLocation::CONTEXT, num_heap_slots_++); |
| } |
| - |
| -void Scope::AllocateParameterLocals(Isolate* isolate) { |
| +void Scope::AllocateParameterLocals() { |
| DCHECK(is_function_scope()); |
| Variable* arguments = LookupLocal(ast_value_factory_->arguments_string()); |
| // Functions have 'arguments' declared implicitly in all non arrow functions. |
| @@ -1339,7 +1331,7 @@ void Scope::AllocateParameterLocals(Isolate* isolate) { |
| bool uses_sloppy_arguments = false; |
| if (arguments != nullptr && MustAllocate(arguments) && |
| - !HasArgumentsParameter(isolate)) { |
| + !has_arguments_parameter_) { |
| // 'arguments' is used. Unless there is also a parameter called |
| // 'arguments', we must be conservative and allocate all parameters to |
| // the context assuming they will be captured by the arguments object. |
| @@ -1413,11 +1405,10 @@ void Scope::AllocateReceiver() { |
| AllocateParameter(receiver(), -1); |
| } |
| - |
| -void Scope::AllocateNonParameterLocal(Isolate* isolate, Variable* var) { |
| +void Scope::AllocateNonParameterLocal(Variable* var) { |
| DCHECK(var->scope() == this); |
| - DCHECK(!var->IsVariable(isolate->factory()->dot_result_string()) || |
| - !var->IsStackLocal()); |
| + // DCHECK(!var->IsVariable(isolate->factory()->dot_result_string()) || |
| + // !var->IsStackLocal()); |
|
Toon Verwaest
2016/07/19 11:49:42
We shouldn't leave old code around in comments. Ei
marja
2016/07/19 11:53:08
Oops, this was unintentional, will fix
|
| if (var->IsUnallocated() && MustAllocate(var)) { |
| if (MustAllocateInContext(var)) { |
| AllocateHeapSlot(var); |
| @@ -1427,11 +1418,10 @@ void Scope::AllocateNonParameterLocal(Isolate* isolate, Variable* var) { |
| } |
| } |
| - |
| -void Scope::AllocateDeclaredGlobal(Isolate* isolate, Variable* var) { |
| +void Scope::AllocateDeclaredGlobal(Variable* var) { |
| DCHECK(var->scope() == this); |
| - DCHECK(!var->IsVariable(isolate->factory()->dot_result_string()) || |
| - !var->IsStackLocal()); |
| + // DCHECK(!var->IsVariable(isolate->factory()->dot_result_string()) || |
| + // !var->IsStackLocal()); |
| if (var->IsUnallocated()) { |
| if (var->IsStaticGlobalObjectProperty()) { |
| DCHECK_EQ(-1, var->index()); |
| @@ -1445,12 +1435,11 @@ void Scope::AllocateDeclaredGlobal(Isolate* isolate, Variable* var) { |
| } |
| } |
| - |
| -void Scope::AllocateNonParameterLocalsAndDeclaredGlobals(Isolate* isolate) { |
| +void Scope::AllocateNonParameterLocalsAndDeclaredGlobals() { |
| // All variables that have no rewrite yet are non-parameter locals. |
| for (int i = 0; i < temps_.length(); i++) { |
| if (temps_[i] == nullptr) continue; |
| - AllocateNonParameterLocal(isolate, temps_[i]); |
| + AllocateNonParameterLocal(temps_[i]); |
| } |
| ZoneList<VarAndOrder> vars(variables_.occupancy(), zone()); |
| @@ -1463,12 +1452,12 @@ void Scope::AllocateNonParameterLocalsAndDeclaredGlobals(Isolate* isolate) { |
| vars.Sort(VarAndOrder::Compare); |
| int var_count = vars.length(); |
| for (int i = 0; i < var_count; i++) { |
| - AllocateNonParameterLocal(isolate, vars[i].var()); |
| + AllocateNonParameterLocal(vars[i].var()); |
| } |
| if (FLAG_global_var_shortcuts) { |
| for (int i = 0; i < var_count; i++) { |
| - AllocateDeclaredGlobal(isolate, vars[i].var()); |
| + AllocateDeclaredGlobal(vars[i].var()); |
| } |
| } |
| @@ -1477,11 +1466,11 @@ void Scope::AllocateNonParameterLocalsAndDeclaredGlobals(Isolate* isolate) { |
| // because of the current ScopeInfo implementation (see |
| // ScopeInfo::ScopeInfo(FunctionScope* scope) constructor). |
| if (function_ != nullptr) { |
| - AllocateNonParameterLocal(isolate, function_->proxy()->var()); |
| + AllocateNonParameterLocal(function_->proxy()->var()); |
| } |
| if (rest_parameter_ != nullptr) { |
| - AllocateNonParameterLocal(isolate, rest_parameter_); |
| + AllocateNonParameterLocal(rest_parameter_); |
| } |
| Variable* new_target_var = |
| @@ -1497,14 +1486,13 @@ void Scope::AllocateNonParameterLocalsAndDeclaredGlobals(Isolate* isolate) { |
| } |
| } |
| - |
| -void Scope::AllocateVariablesRecursively(Isolate* isolate) { |
| +void Scope::AllocateVariablesRecursively() { |
| if (!already_resolved()) { |
| num_stack_slots_ = 0; |
| } |
| // Allocate variables for inner scopes. |
| for (int i = 0; i < inner_scopes_.length(); i++) { |
| - inner_scopes_[i]->AllocateVariablesRecursively(isolate); |
| + inner_scopes_[i]->AllocateVariablesRecursively(); |
| } |
| // If scope is already resolved, we still need to allocate |
| @@ -1515,9 +1503,9 @@ void Scope::AllocateVariablesRecursively(Isolate* isolate) { |
| // Allocate variables for this scope. |
| // Parameters must be allocated first, if any. |
| - if (is_function_scope()) AllocateParameterLocals(isolate); |
| + if (is_function_scope()) AllocateParameterLocals(); |
| if (has_this_declaration()) AllocateReceiver(); |
| - AllocateNonParameterLocalsAndDeclaredGlobals(isolate); |
| + AllocateNonParameterLocalsAndDeclaredGlobals(); |
| // Force allocation of a context for this scope if necessary. For a 'with' |
| // scope and for a function scope that makes an 'eval' call we need a context, |