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 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2051 if (is_function_scope()) { | 2051 if (is_function_scope()) { |
2052 AsDeclarationScope()->AllocateParameterLocals(); | 2052 AsDeclarationScope()->AllocateParameterLocals(); |
2053 } | 2053 } |
2054 AsDeclarationScope()->AllocateReceiver(); | 2054 AsDeclarationScope()->AllocateReceiver(); |
2055 } | 2055 } |
2056 AllocateNonParameterLocalsAndDeclaredGlobals(); | 2056 AllocateNonParameterLocalsAndDeclaredGlobals(); |
2057 | 2057 |
2058 // Force allocation of a context for this scope if necessary. For a 'with' | 2058 // Force allocation of a context for this scope if necessary. For a 'with' |
2059 // scope and for a function scope that makes an 'eval' call we need a context, | 2059 // scope and for a function scope that makes an 'eval' call we need a context, |
2060 // even if no local variables were statically allocated in the scope. | 2060 // even if no local variables were statically allocated in the scope. |
2061 // Likewise for modules. | 2061 // Likewise for modules and function scopes representing asm.js modules. |
2062 bool must_have_context = | 2062 bool must_have_context = |
2063 is_with_scope() || is_module_scope() || | 2063 is_with_scope() || is_module_scope() || IsAsmModule() || |
2064 (is_function_scope() && calls_sloppy_eval()) || | 2064 (is_function_scope() && calls_sloppy_eval()) || |
2065 (is_block_scope() && is_declaration_scope() && calls_sloppy_eval()); | 2065 (is_block_scope() && is_declaration_scope() && calls_sloppy_eval()); |
2066 | 2066 |
2067 // If we didn't allocate any locals in the local context, then we only | 2067 // If we didn't allocate any locals in the local context, then we only |
2068 // need the minimal number of slots if we must have a context. | 2068 // need the minimal number of slots if we must have a context. |
2069 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && !must_have_context) { | 2069 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && !must_have_context) { |
2070 num_heap_slots_ = 0; | 2070 num_heap_slots_ = 0; |
2071 } | 2071 } |
2072 | 2072 |
2073 // Allocation done. | 2073 // Allocation done. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2120 Variable* function = | 2120 Variable* function = |
2121 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2121 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
2122 bool is_function_var_in_context = | 2122 bool is_function_var_in_context = |
2123 function != nullptr && function->IsContextSlot(); | 2123 function != nullptr && function->IsContextSlot(); |
2124 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2124 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
2125 (is_function_var_in_context ? 1 : 0); | 2125 (is_function_var_in_context ? 1 : 0); |
2126 } | 2126 } |
2127 | 2127 |
2128 } // namespace internal | 2128 } // namespace internal |
2129 } // namespace v8 | 2129 } // namespace v8 |
OLD | NEW |