OLD | NEW |
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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 341 |
342 set_language_mode(SLOPPY); | 342 set_language_mode(SLOPPY); |
343 | 343 |
344 scope_calls_eval_ = false; | 344 scope_calls_eval_ = false; |
345 scope_nonlinear_ = false; | 345 scope_nonlinear_ = false; |
346 is_hidden_ = false; | 346 is_hidden_ = false; |
347 is_debug_evaluate_scope_ = false; | 347 is_debug_evaluate_scope_ = false; |
348 | 348 |
349 inner_scope_calls_eval_ = false; | 349 inner_scope_calls_eval_ = false; |
350 force_context_allocation_ = false; | 350 force_context_allocation_ = false; |
351 force_context_allocation_for_parameters_ = false; | |
352 | 351 |
353 is_declaration_scope_ = false; | 352 is_declaration_scope_ = false; |
354 | 353 |
355 must_use_preparsed_scope_data_ = false; | 354 must_use_preparsed_scope_data_ = false; |
356 } | 355 } |
357 | 356 |
358 bool Scope::HasSimpleParameters() { | 357 bool Scope::HasSimpleParameters() { |
359 DeclarationScope* scope = GetClosureScope(); | 358 DeclarationScope* scope = GetClosureScope(); |
360 return !scope->is_function_scope() || scope->has_simple_parameters(); | 359 return !scope->is_function_scope() || scope->has_simple_parameters(); |
361 } | 360 } |
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 var->set_is_used(); | 2186 var->set_is_used(); |
2188 var->set_maybe_assigned(); | 2187 var->set_maybe_assigned(); |
2189 var->ForceContextAllocation(); | 2188 var->ForceContextAllocation(); |
2190 } | 2189 } |
2191 AllocateParameter(var, i); | 2190 AllocateParameter(var, i); |
2192 } | 2191 } |
2193 } | 2192 } |
2194 | 2193 |
2195 void DeclarationScope::AllocateParameter(Variable* var, int index) { | 2194 void DeclarationScope::AllocateParameter(Variable* var, int index) { |
2196 if (MustAllocate(var)) { | 2195 if (MustAllocate(var)) { |
2197 if (has_forced_context_allocation_for_parameters() || | 2196 if (MustAllocateInContext(var)) { |
2198 MustAllocateInContext(var)) { | |
2199 DCHECK(var->IsUnallocated() || var->IsContextSlot()); | 2197 DCHECK(var->IsUnallocated() || var->IsContextSlot()); |
2200 if (var->IsUnallocated()) { | 2198 if (var->IsUnallocated()) { |
2201 AllocateHeapSlot(var); | 2199 AllocateHeapSlot(var); |
2202 } | 2200 } |
2203 } else { | 2201 } else { |
2204 DCHECK(var->IsUnallocated() || var->IsParameter()); | 2202 DCHECK(var->IsUnallocated() || var->IsParameter()); |
2205 if (var->IsUnallocated()) { | 2203 if (var->IsUnallocated()) { |
2206 var->AllocateTo(VariableLocation::PARAMETER, index); | 2204 var->AllocateTo(VariableLocation::PARAMETER, index); |
2207 } | 2205 } |
2208 } | 2206 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2364 Variable* function = | 2362 Variable* function = |
2365 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2363 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
2366 bool is_function_var_in_context = | 2364 bool is_function_var_in_context = |
2367 function != nullptr && function->IsContextSlot(); | 2365 function != nullptr && function->IsContextSlot(); |
2368 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2366 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
2369 (is_function_var_in_context ? 1 : 0); | 2367 (is_function_var_in_context ? 1 : 0); |
2370 } | 2368 } |
2371 | 2369 |
2372 } // namespace internal | 2370 } // namespace internal |
2373 } // namespace v8 | 2371 } // namespace v8 |
OLD | NEW |