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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/scopes.h" | 7 #include "src/scopes.h" |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 scope_inside_with_ = false; | 158 scope_inside_with_ = false; |
159 scope_contains_with_ = false; | 159 scope_contains_with_ = false; |
160 scope_calls_eval_ = false; | 160 scope_calls_eval_ = false; |
161 scope_uses_arguments_ = false; | 161 scope_uses_arguments_ = false; |
162 scope_uses_super_property_ = false; | 162 scope_uses_super_property_ = false; |
163 scope_uses_super_constructor_call_ = false; | 163 scope_uses_super_constructor_call_ = false; |
164 scope_uses_this_ = false; | 164 scope_uses_this_ = false; |
165 asm_module_ = false; | 165 asm_module_ = false; |
166 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; | 166 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; |
167 // Inherit the strict mode from the parent scope. | 167 // Inherit the strict mode from the parent scope. |
168 strict_mode_ = outer_scope != NULL ? outer_scope->strict_mode_ : SLOPPY; | 168 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; |
169 outer_scope_calls_sloppy_eval_ = false; | 169 outer_scope_calls_sloppy_eval_ = false; |
170 inner_scope_calls_eval_ = false; | 170 inner_scope_calls_eval_ = false; |
171 inner_scope_uses_arguments_ = false; | 171 inner_scope_uses_arguments_ = false; |
172 inner_scope_uses_this_ = false; | 172 inner_scope_uses_this_ = false; |
173 inner_scope_uses_super_property_ = false; | 173 inner_scope_uses_super_property_ = false; |
174 inner_scope_uses_super_constructor_call_ = false; | 174 inner_scope_uses_super_constructor_call_ = false; |
175 force_eager_compilation_ = false; | 175 force_eager_compilation_ = false; |
176 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) | 176 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) |
177 ? outer_scope->has_forced_context_allocation() : false; | 177 ? outer_scope->has_forced_context_allocation() : false; |
178 num_var_or_const_ = 0; | 178 num_var_or_const_ = 0; |
179 num_stack_slots_ = 0; | 179 num_stack_slots_ = 0; |
180 num_heap_slots_ = 0; | 180 num_heap_slots_ = 0; |
181 num_modules_ = 0; | 181 num_modules_ = 0; |
182 module_var_ = NULL, | 182 module_var_ = NULL, |
183 rest_parameter_ = NULL; | 183 rest_parameter_ = NULL; |
184 rest_index_ = -1; | 184 rest_index_ = -1; |
185 scope_info_ = scope_info; | 185 scope_info_ = scope_info; |
186 start_position_ = RelocInfo::kNoPosition; | 186 start_position_ = RelocInfo::kNoPosition; |
187 end_position_ = RelocInfo::kNoPosition; | 187 end_position_ = RelocInfo::kNoPosition; |
188 if (!scope_info.is_null()) { | 188 if (!scope_info.is_null()) { |
189 scope_calls_eval_ = scope_info->CallsEval(); | 189 scope_calls_eval_ = scope_info->CallsEval(); |
190 strict_mode_ = scope_info->strict_mode(); | 190 language_mode_ = scope_info->language_mode(); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 | 194 |
195 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, | 195 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, |
196 Context* context, Scope* script_scope) { | 196 Context* context, Scope* script_scope) { |
197 // Reconstruct the outer scope chain from a closure's context chain. | 197 // Reconstruct the outer scope chain from a closure's context chain. |
198 Scope* current_scope = NULL; | 198 Scope* current_scope = NULL; |
199 Scope* innermost_scope = NULL; | 199 Scope* innermost_scope = NULL; |
200 bool contains_with = false; | 200 bool contains_with = false; |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 if (function_ != NULL) { | 881 if (function_ != NULL) { |
882 Indent(n1, "// (local) function name: "); | 882 Indent(n1, "// (local) function name: "); |
883 PrintName(function_->proxy()->raw_name()); | 883 PrintName(function_->proxy()->raw_name()); |
884 PrintF("\n"); | 884 PrintF("\n"); |
885 } | 885 } |
886 | 886 |
887 // Scope info. | 887 // Scope info. |
888 if (HasTrivialOuterContext()) { | 888 if (HasTrivialOuterContext()) { |
889 Indent(n1, "// scope has trivial outer context\n"); | 889 Indent(n1, "// scope has trivial outer context\n"); |
890 } | 890 } |
891 if (strict_mode() == STRICT) { | 891 if (is_strict(language_mode())) { |
892 Indent(n1, "// strict mode scope\n"); | 892 Indent(n1, "// strict mode scope\n"); |
893 } | 893 } |
894 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); | 894 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); |
895 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); | 895 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); |
896 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); | 896 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); |
897 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); | 897 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); |
898 if (scope_uses_super_property_) | 898 if (scope_uses_super_property_) |
899 Indent(n1, "// scope uses 'super' property\n"); | 899 Indent(n1, "// scope uses 'super' property\n"); |
900 if (scope_uses_super_constructor_call_) | 900 if (scope_uses_super_constructor_call_) |
901 Indent(n1, "// scope uses 'super' constructor\n"); | 901 Indent(n1, "// scope uses 'super' constructor\n"); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 // parameters, which is why we don't need to allocate an arguments | 1283 // parameters, which is why we don't need to allocate an arguments |
1284 // object in that case. | 1284 // object in that case. |
1285 | 1285 |
1286 // We are using 'arguments'. Tell the code generator that is needs to | 1286 // We are using 'arguments'. Tell the code generator that is needs to |
1287 // allocate the arguments object by setting 'arguments_'. | 1287 // allocate the arguments object by setting 'arguments_'. |
1288 arguments_ = arguments; | 1288 arguments_ = arguments; |
1289 | 1289 |
1290 // In strict mode 'arguments' does not alias formal parameters. | 1290 // In strict mode 'arguments' does not alias formal parameters. |
1291 // Therefore in strict mode we allocate parameters as if 'arguments' | 1291 // Therefore in strict mode we allocate parameters as if 'arguments' |
1292 // were not used. | 1292 // were not used. |
1293 uses_sloppy_arguments = strict_mode() == SLOPPY; | 1293 uses_sloppy_arguments = is_sloppy(language_mode()); |
1294 } | 1294 } |
1295 | 1295 |
1296 if (rest_parameter_ && !MustAllocate(rest_parameter_)) { | 1296 if (rest_parameter_ && !MustAllocate(rest_parameter_)) { |
1297 rest_parameter_ = NULL; | 1297 rest_parameter_ = NULL; |
1298 } | 1298 } |
1299 | 1299 |
1300 // The same parameter may occur multiple times in the parameters_ list. | 1300 // The same parameter may occur multiple times in the parameters_ list. |
1301 // If it does, and if it is not copied into the context object, it must | 1301 // If it does, and if it is not copied into the context object, it must |
1302 // receive the highest parameter index for that parameter; thus iteration | 1302 // receive the highest parameter index for that parameter; thus iteration |
1303 // order is relevant! | 1303 // order is relevant! |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 } | 1438 } |
1439 | 1439 |
1440 | 1440 |
1441 int Scope::ContextLocalCount() const { | 1441 int Scope::ContextLocalCount() const { |
1442 if (num_heap_slots() == 0) return 0; | 1442 if (num_heap_slots() == 0) return 0; |
1443 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1443 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1444 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1444 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
1445 } | 1445 } |
1446 | 1446 |
1447 } } // namespace v8::internal | 1447 } } // namespace v8::internal |
OLD | NEW |