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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/parser.h" | 10 #include "src/parser.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 receiver_ = NULL; | 158 receiver_ = NULL; |
159 new_target_ = nullptr; | 159 new_target_ = nullptr; |
160 function_ = NULL; | 160 function_ = NULL; |
161 arguments_ = NULL; | 161 arguments_ = NULL; |
162 illegal_redecl_ = NULL; | 162 illegal_redecl_ = NULL; |
163 scope_inside_with_ = false; | 163 scope_inside_with_ = false; |
164 scope_contains_with_ = false; | 164 scope_contains_with_ = false; |
165 scope_calls_eval_ = false; | 165 scope_calls_eval_ = false; |
166 scope_uses_arguments_ = false; | 166 scope_uses_arguments_ = false; |
167 scope_uses_super_property_ = false; | 167 scope_uses_super_property_ = false; |
168 scope_uses_this_ = false; | |
169 asm_module_ = false; | 168 asm_module_ = false; |
170 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; | 169 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; |
171 // Inherit the language mode from the parent scope. | 170 // Inherit the language mode from the parent scope. |
172 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; | 171 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; |
173 outer_scope_calls_sloppy_eval_ = false; | 172 outer_scope_calls_sloppy_eval_ = false; |
174 inner_scope_calls_eval_ = false; | 173 inner_scope_calls_eval_ = false; |
175 inner_scope_uses_arguments_ = false; | 174 inner_scope_uses_arguments_ = false; |
176 inner_scope_uses_this_ = false; | |
177 inner_scope_uses_super_property_ = false; | 175 inner_scope_uses_super_property_ = false; |
178 force_eager_compilation_ = false; | 176 force_eager_compilation_ = false; |
179 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) | 177 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) |
180 ? outer_scope->has_forced_context_allocation() : false; | 178 ? outer_scope->has_forced_context_allocation() : false; |
181 num_var_or_const_ = 0; | 179 num_var_or_const_ = 0; |
182 num_stack_slots_ = 0; | 180 num_stack_slots_ = 0; |
183 num_heap_slots_ = 0; | 181 num_heap_slots_ = 0; |
184 num_modules_ = 0; | 182 num_modules_ = 0; |
185 module_var_ = NULL, | 183 module_var_ = NULL, |
186 rest_parameter_ = NULL; | 184 rest_parameter_ = NULL; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 DCHECK(!already_resolved()); | 300 DCHECK(!already_resolved()); |
303 | 301 |
304 // Add this scope as a new inner scope of the outer scope. | 302 // Add this scope as a new inner scope of the outer scope. |
305 if (outer_scope_ != NULL) { | 303 if (outer_scope_ != NULL) { |
306 outer_scope_->inner_scopes_.Add(this, zone()); | 304 outer_scope_->inner_scopes_.Add(this, zone()); |
307 scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope(); | 305 scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope(); |
308 } else { | 306 } else { |
309 scope_inside_with_ = is_with_scope(); | 307 scope_inside_with_ = is_with_scope(); |
310 } | 308 } |
311 | 309 |
312 // Declare convenience variables. | 310 // Declare convenience variables and the receiver. |
313 // Declare and allocate receiver (even for the script scope, and even | |
314 // if naccesses_ == 0). | |
315 // NOTE: When loading parameters in the script scope, we must take | |
316 // care not to access them as properties of the global object, but | |
317 // instead load them directly from the stack. Currently, the only | |
318 // such parameter is 'this' which is passed on the stack when | |
319 // invoking scripts | |
320 if (is_declaration_scope()) { | 311 if (is_declaration_scope()) { |
321 DCHECK(!subclass_constructor || is_function_scope()); | 312 DCHECK(!subclass_constructor || is_function_scope()); |
322 Variable* var = variables_.Declare( | 313 if (has_this_declaration()) { |
323 this, ast_value_factory_->this_string(), | 314 Variable* var = variables_.Declare( |
324 subclass_constructor ? CONST : VAR, Variable::THIS, | 315 this, ast_value_factory_->this_string(), |
325 subclass_constructor ? kNeedsInitialization : kCreatedInitialized); | 316 subclass_constructor ? CONST : VAR, Variable::THIS, |
326 var->AllocateTo(Variable::PARAMETER, -1); | 317 subclass_constructor ? kNeedsInitialization : kCreatedInitialized); |
327 receiver_ = var; | 318 receiver_ = var; |
| 319 } |
328 | 320 |
329 if (subclass_constructor) { | 321 if (subclass_constructor) { |
330 new_target_ = | 322 new_target_ = |
331 variables_.Declare(this, ast_value_factory_->new_target_string(), | 323 variables_.Declare(this, ast_value_factory_->new_target_string(), |
332 CONST, Variable::NEW_TARGET, kCreatedInitialized); | 324 CONST, Variable::NEW_TARGET, kCreatedInitialized); |
333 new_target_->AllocateTo(Variable::PARAMETER, -2); | 325 new_target_->AllocateTo(Variable::PARAMETER, -2); |
334 new_target_->set_is_used(); | 326 new_target_->set_is_used(); |
335 } | 327 } |
336 } else { | |
337 DCHECK(outer_scope() != NULL); | |
338 receiver_ = outer_scope()->receiver(); | |
339 } | 328 } |
340 | 329 |
341 if (is_function_scope() && !is_arrow_scope()) { | 330 if (is_function_scope() && !is_arrow_scope()) { |
342 // Declare 'arguments' variable which exists in all non arrow functions. | 331 // Declare 'arguments' variable which exists in all non arrow functions. |
343 // Note that it might never be accessed, in which case it won't be | 332 // Note that it might never be accessed, in which case it won't be |
344 // allocated during variable allocation. | 333 // allocated during variable allocation. |
345 variables_.Declare(this, | 334 variables_.Declare(this, |
346 ast_value_factory_->arguments_string(), | 335 ast_value_factory_->arguments_string(), |
347 VAR, | 336 VAR, |
348 Variable::ARGUMENTS, | 337 Variable::ARGUMENTS, |
(...skipping 24 matching lines...) Expand all Loading... |
373 } | 362 } |
374 | 363 |
375 // Move unresolved variables | 364 // Move unresolved variables |
376 for (int i = 0; i < unresolved_.length(); i++) { | 365 for (int i = 0; i < unresolved_.length(); i++) { |
377 outer_scope()->unresolved_.Add(unresolved_[i], zone()); | 366 outer_scope()->unresolved_.Add(unresolved_[i], zone()); |
378 } | 367 } |
379 | 368 |
380 // Propagate usage flags to outer scope. | 369 // Propagate usage flags to outer scope. |
381 if (uses_arguments()) outer_scope_->RecordArgumentsUsage(); | 370 if (uses_arguments()) outer_scope_->RecordArgumentsUsage(); |
382 if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage(); | 371 if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage(); |
383 if (uses_this()) outer_scope_->RecordThisUsage(); | |
384 if (scope_calls_eval_) outer_scope_->RecordEvalCall(); | 372 if (scope_calls_eval_) outer_scope_->RecordEvalCall(); |
385 | 373 |
386 return NULL; | 374 return NULL; |
387 } | 375 } |
388 | 376 |
389 | 377 |
390 Variable* Scope::LookupLocal(const AstRawString* name) { | 378 Variable* Scope::LookupLocal(const AstRawString* name) { |
391 Variable* result = variables_.Lookup(name); | 379 Variable* result = variables_.Lookup(name); |
392 if (result != NULL || scope_info_.is_null()) { | 380 if (result != NULL || scope_info_.is_null()) { |
393 return result; | 381 return result; |
(...skipping 20 matching lines...) Expand all Loading... |
414 | 402 |
415 mode = DYNAMIC; | 403 mode = DYNAMIC; |
416 location = Variable::LOOKUP; | 404 location = Variable::LOOKUP; |
417 init_flag = kCreatedInitialized; | 405 init_flag = kCreatedInitialized; |
418 // Be conservative and flag parameters as maybe assigned. Better information | 406 // Be conservative and flag parameters as maybe assigned. Better information |
419 // would require ScopeInfo to serialize the maybe_assigned bit also for | 407 // would require ScopeInfo to serialize the maybe_assigned bit also for |
420 // parameters. | 408 // parameters. |
421 maybe_assigned_flag = kMaybeAssigned; | 409 maybe_assigned_flag = kMaybeAssigned; |
422 } | 410 } |
423 | 411 |
424 // TODO(marja, rossberg): Declare variables of the right Kind. | 412 Variable::Kind kind = Variable::NORMAL; |
425 Variable* var = variables_.Declare(this, name, mode, Variable::NORMAL, | 413 if (location == Variable::CONTEXT && |
426 init_flag, maybe_assigned_flag); | 414 index == scope_info_->ReceiverContextSlotIndex()) { |
| 415 kind = Variable::THIS; |
| 416 } |
| 417 // TODO(marja, rossberg): Correctly declare FUNCTION, CLASS, NEW_TARGET, and |
| 418 // ARGUMENTS bindings as their corresponding Variable::Kind. |
| 419 |
| 420 Variable* var = variables_.Declare(this, name, mode, kind, init_flag, |
| 421 maybe_assigned_flag); |
427 var->AllocateTo(location, index); | 422 var->AllocateTo(location, index); |
428 return var; | 423 return var; |
429 } | 424 } |
430 | 425 |
431 | 426 |
432 Variable* Scope::LookupFunctionVar(const AstRawString* name, | 427 Variable* Scope::LookupFunctionVar(const AstRawString* name, |
433 AstNodeFactory* factory) { | 428 AstNodeFactory* factory) { |
434 if (function_ != NULL && function_->proxy()->raw_name() == name) { | 429 if (function_ != NULL && function_->proxy()->raw_name() == name) { |
435 return function_->proxy()->var(); | 430 return function_->proxy()->var(); |
436 } else if (!scope_info_.is_null()) { | 431 } else if (!scope_info_.is_null()) { |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 Indent(n1, "// strong mode scope\n"); | 919 Indent(n1, "// strong mode scope\n"); |
925 } else if (is_strict(language_mode())) { | 920 } else if (is_strict(language_mode())) { |
926 Indent(n1, "// strict mode scope\n"); | 921 Indent(n1, "// strict mode scope\n"); |
927 } | 922 } |
928 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); | 923 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); |
929 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); | 924 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); |
930 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); | 925 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); |
931 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); | 926 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); |
932 if (scope_uses_super_property_) | 927 if (scope_uses_super_property_) |
933 Indent(n1, "// scope uses 'super' property\n"); | 928 Indent(n1, "// scope uses 'super' property\n"); |
934 if (scope_uses_this_) Indent(n1, "// scope uses 'this'\n"); | |
935 if (inner_scope_uses_arguments_) { | 929 if (inner_scope_uses_arguments_) { |
936 Indent(n1, "// inner scope uses 'arguments'\n"); | 930 Indent(n1, "// inner scope uses 'arguments'\n"); |
937 } | 931 } |
938 if (inner_scope_uses_super_property_) | 932 if (inner_scope_uses_super_property_) |
939 Indent(n1, "// inner scope uses 'super' property\n"); | 933 Indent(n1, "// inner scope uses 'super' property\n"); |
940 if (inner_scope_uses_this_) Indent(n1, "// inner scope uses 'this'\n"); | |
941 if (outer_scope_calls_sloppy_eval_) { | 934 if (outer_scope_calls_sloppy_eval_) { |
942 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); | 935 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); |
943 } | 936 } |
944 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); | 937 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); |
945 if (num_stack_slots_ > 0) { Indent(n1, "// "); | 938 if (num_stack_slots_ > 0) { Indent(n1, "// "); |
946 PrintF("%d stack slots\n", num_stack_slots_); } | 939 PrintF("%d stack slots\n", num_stack_slots_); } |
947 if (num_heap_slots_ > 0) { Indent(n1, "// "); | 940 if (num_heap_slots_ > 0) { Indent(n1, "// "); |
948 PrintF("%d heap slots\n", num_heap_slots_); } | 941 PrintF("%d heap slots\n", num_heap_slots_); } |
949 | 942 |
950 // Print locals. | 943 // Print locals. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 *binding_kind = BOUND; | 1036 *binding_kind = BOUND; |
1044 } else if (outer_scope_ != NULL) { | 1037 } else if (outer_scope_ != NULL) { |
1045 var = outer_scope_->LookupRecursive(proxy, binding_kind, factory); | 1038 var = outer_scope_->LookupRecursive(proxy, binding_kind, factory); |
1046 if (*binding_kind == BOUND && (is_function_scope() || is_with_scope())) { | 1039 if (*binding_kind == BOUND && (is_function_scope() || is_with_scope())) { |
1047 var->ForceContextAllocation(); | 1040 var->ForceContextAllocation(); |
1048 } | 1041 } |
1049 } else { | 1042 } else { |
1050 DCHECK(is_script_scope()); | 1043 DCHECK(is_script_scope()); |
1051 } | 1044 } |
1052 | 1045 |
1053 if (is_with_scope()) { | 1046 // "this" can't be shadowed by "eval"-introduced bindings or by "with" scopes. |
| 1047 // TODO(wingo): There are other variables in this category; add them. |
| 1048 bool name_can_be_shadowed = var == nullptr || !var->is_this(); |
| 1049 |
| 1050 if (is_with_scope() && name_can_be_shadowed) { |
1054 DCHECK(!already_resolved()); | 1051 DCHECK(!already_resolved()); |
1055 // The current scope is a with scope, so the variable binding can not be | 1052 // The current scope is a with scope, so the variable binding can not be |
1056 // statically resolved. However, note that it was necessary to do a lookup | 1053 // statically resolved. However, note that it was necessary to do a lookup |
1057 // in the outer scope anyway, because if a binding exists in an outer scope, | 1054 // in the outer scope anyway, because if a binding exists in an outer scope, |
1058 // the associated variable has to be marked as potentially being accessed | 1055 // the associated variable has to be marked as potentially being accessed |
1059 // from inside of an inner with scope (the property may not be in the 'with' | 1056 // from inside of an inner with scope (the property may not be in the 'with' |
1060 // object). | 1057 // object). |
1061 if (var != NULL && proxy->is_assigned()) var->set_maybe_assigned(); | 1058 if (var != NULL && proxy->is_assigned()) var->set_maybe_assigned(); |
1062 *binding_kind = DYNAMIC_LOOKUP; | 1059 *binding_kind = DYNAMIC_LOOKUP; |
1063 return NULL; | 1060 return NULL; |
1064 } else if (calls_sloppy_eval()) { | 1061 } else if (calls_sloppy_eval() && name_can_be_shadowed) { |
1065 // A variable binding may have been found in an outer scope, but the current | 1062 // A variable binding may have been found in an outer scope, but the current |
1066 // scope makes a sloppy 'eval' call, so the found variable may not be | 1063 // scope makes a sloppy 'eval' call, so the found variable may not be |
1067 // the correct one (the 'eval' may introduce a binding with the same name). | 1064 // the correct one (the 'eval' may introduce a binding with the same name). |
1068 // In that case, change the lookup result to reflect this situation. | 1065 // In that case, change the lookup result to reflect this situation. |
1069 if (*binding_kind == BOUND) { | 1066 if (*binding_kind == BOUND) { |
1070 *binding_kind = BOUND_EVAL_SHADOWED; | 1067 *binding_kind = BOUND_EVAL_SHADOWED; |
1071 } else if (*binding_kind == UNBOUND) { | 1068 } else if (*binding_kind == UNBOUND) { |
1072 *binding_kind = UNBOUND_EVAL_SHADOWED; | 1069 *binding_kind = UNBOUND_EVAL_SHADOWED; |
1073 } | 1070 } |
1074 } | 1071 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 // usage of arguments/super/this, but do not propagate them out from normal | 1284 // usage of arguments/super/this, but do not propagate them out from normal |
1288 // functions. | 1285 // functions. |
1289 if (!inner->is_function_scope() || inner->is_arrow_scope()) { | 1286 if (!inner->is_function_scope() || inner->is_arrow_scope()) { |
1290 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) { | 1287 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) { |
1291 inner_scope_uses_arguments_ = true; | 1288 inner_scope_uses_arguments_ = true; |
1292 } | 1289 } |
1293 if (inner->scope_uses_super_property_ || | 1290 if (inner->scope_uses_super_property_ || |
1294 inner->inner_scope_uses_super_property_) { | 1291 inner->inner_scope_uses_super_property_) { |
1295 inner_scope_uses_super_property_ = true; | 1292 inner_scope_uses_super_property_ = true; |
1296 } | 1293 } |
1297 if (inner->scope_uses_this_ || inner->inner_scope_uses_this_) { | |
1298 inner_scope_uses_this_ = true; | |
1299 } | |
1300 } | 1294 } |
1301 if (inner->force_eager_compilation_) { | 1295 if (inner->force_eager_compilation_) { |
1302 force_eager_compilation_ = true; | 1296 force_eager_compilation_ = true; |
1303 } | 1297 } |
1304 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { | 1298 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { |
1305 inner->asm_function_ = true; | 1299 inner->asm_function_ = true; |
1306 } | 1300 } |
1307 } | 1301 } |
1308 } | 1302 } |
1309 | 1303 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 // order is relevant! | 1404 // order is relevant! |
1411 for (int i = params_.length() - 1; i >= 0; --i) { | 1405 for (int i = params_.length() - 1; i >= 0; --i) { |
1412 Variable* var = params_[i]; | 1406 Variable* var = params_[i]; |
1413 if (var == rest_parameter_) continue; | 1407 if (var == rest_parameter_) continue; |
1414 | 1408 |
1415 DCHECK(var->scope() == this); | 1409 DCHECK(var->scope() == this); |
1416 if (uses_sloppy_arguments || has_forced_context_allocation()) { | 1410 if (uses_sloppy_arguments || has_forced_context_allocation()) { |
1417 // Force context allocation of the parameter. | 1411 // Force context allocation of the parameter. |
1418 var->ForceContextAllocation(); | 1412 var->ForceContextAllocation(); |
1419 } | 1413 } |
| 1414 AllocateParameter(var, i); |
| 1415 } |
| 1416 } |
1420 | 1417 |
1421 if (MustAllocate(var)) { | 1418 |
1422 if (MustAllocateInContext(var)) { | 1419 void Scope::AllocateParameter(Variable* var, int index) { |
1423 DCHECK(var->IsUnallocated() || var->IsContextSlot()); | 1420 if (MustAllocate(var)) { |
1424 if (var->IsUnallocated()) { | 1421 if (MustAllocateInContext(var)) { |
1425 AllocateHeapSlot(var); | 1422 DCHECK(var->IsUnallocated() || var->IsContextSlot()); |
1426 } | 1423 if (var->IsUnallocated()) { |
1427 } else { | 1424 AllocateHeapSlot(var); |
1428 DCHECK(var->IsUnallocated() || var->IsParameter()); | 1425 } |
1429 if (var->IsUnallocated()) { | 1426 } else { |
1430 var->AllocateTo(Variable::PARAMETER, i); | 1427 DCHECK(var->IsUnallocated() || var->IsParameter()); |
1431 } | 1428 if (var->IsUnallocated()) { |
| 1429 var->AllocateTo(Variable::PARAMETER, index); |
1432 } | 1430 } |
1433 } | 1431 } |
1434 } | 1432 } |
1435 } | 1433 } |
1436 | 1434 |
1437 | 1435 |
| 1436 void Scope::AllocateReceiver() { |
| 1437 DCHECK_NOT_NULL(receiver()); |
| 1438 DCHECK_EQ(receiver()->scope(), this); |
| 1439 |
| 1440 if (has_forced_context_allocation()) { |
| 1441 // Force context allocation of the receiver. |
| 1442 receiver()->ForceContextAllocation(); |
| 1443 } |
| 1444 AllocateParameter(receiver(), -1); |
| 1445 } |
| 1446 |
| 1447 |
1438 void Scope::AllocateNonParameterLocal(Isolate* isolate, Variable* var) { | 1448 void Scope::AllocateNonParameterLocal(Isolate* isolate, Variable* var) { |
1439 DCHECK(var->scope() == this); | 1449 DCHECK(var->scope() == this); |
1440 DCHECK(!var->IsVariable(isolate->factory()->dot_result_string()) || | 1450 DCHECK(!var->IsVariable(isolate->factory()->dot_result_string()) || |
1441 !var->IsStackLocal()); | 1451 !var->IsStackLocal()); |
1442 if (var->IsUnallocated() && MustAllocate(var)) { | 1452 if (var->IsUnallocated() && MustAllocate(var)) { |
1443 if (MustAllocateInContext(var)) { | 1453 if (MustAllocateInContext(var)) { |
1444 AllocateHeapSlot(var); | 1454 AllocateHeapSlot(var); |
1445 } else { | 1455 } else { |
1446 AllocateStackSlot(var); | 1456 AllocateStackSlot(var); |
1447 } | 1457 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 | 1507 |
1498 // If scope is already resolved, we still need to allocate | 1508 // If scope is already resolved, we still need to allocate |
1499 // variables in inner scopes which might not had been resolved yet. | 1509 // variables in inner scopes which might not had been resolved yet. |
1500 if (already_resolved()) return; | 1510 if (already_resolved()) return; |
1501 // The number of slots required for variables. | 1511 // The number of slots required for variables. |
1502 num_heap_slots_ = Context::MIN_CONTEXT_SLOTS; | 1512 num_heap_slots_ = Context::MIN_CONTEXT_SLOTS; |
1503 | 1513 |
1504 // Allocate variables for this scope. | 1514 // Allocate variables for this scope. |
1505 // Parameters must be allocated first, if any. | 1515 // Parameters must be allocated first, if any. |
1506 if (is_function_scope()) AllocateParameterLocals(isolate); | 1516 if (is_function_scope()) AllocateParameterLocals(isolate); |
| 1517 if (has_this_declaration()) AllocateReceiver(); |
1507 AllocateNonParameterLocals(isolate); | 1518 AllocateNonParameterLocals(isolate); |
1508 | 1519 |
1509 // Force allocation of a context for this scope if necessary. For a 'with' | 1520 // Force allocation of a context for this scope if necessary. For a 'with' |
1510 // scope and for a function scope that makes an 'eval' call we need a context, | 1521 // scope and for a function scope that makes an 'eval' call we need a context, |
1511 // even if no local variables were statically allocated in the scope. | 1522 // even if no local variables were statically allocated in the scope. |
1512 // Likewise for modules. | 1523 // Likewise for modules. |
1513 bool must_have_context = is_with_scope() || is_module_scope() || | 1524 bool must_have_context = is_with_scope() || is_module_scope() || |
1514 (is_function_scope() && calls_sloppy_eval()); | 1525 (is_function_scope() && calls_sloppy_eval()); |
1515 | 1526 |
1516 // If we didn't allocate any locals in the local context, then we only | 1527 // If we didn't allocate any locals in the local context, then we only |
(...skipping 28 matching lines...) Expand all Loading... |
1545 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); | 1556 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); |
1546 } | 1557 } |
1547 | 1558 |
1548 | 1559 |
1549 int Scope::ContextLocalCount() const { | 1560 int Scope::ContextLocalCount() const { |
1550 if (num_heap_slots() == 0) return 0; | 1561 if (num_heap_slots() == 0) return 0; |
1551 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1562 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1552 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1563 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
1553 } | 1564 } |
1554 } } // namespace v8::internal | 1565 } } // namespace v8::internal |
OLD | NEW |