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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 DCHECK_EQ(outer_scope_info->scope_type(), SCRIPT_SCOPE); | 535 DCHECK_EQ(outer_scope_info->scope_type(), SCRIPT_SCOPE); |
536 scope->SetScriptScopeInfo(outer_scope_info); | 536 scope->SetScriptScopeInfo(outer_scope_info); |
537 } | 537 } |
538 } | 538 } |
539 | 539 |
540 if (scope->is_eval_scope() && is_sloppy(scope->language_mode())) { | 540 if (scope->is_eval_scope() && is_sloppy(scope->language_mode())) { |
541 AstNodeFactory factory(info->ast_value_factory()); | 541 AstNodeFactory factory(info->ast_value_factory()); |
542 scope->HoistSloppyBlockFunctions(&factory); | 542 scope->HoistSloppyBlockFunctions(&factory); |
543 } | 543 } |
544 | 544 |
545 // We are compiling one of three cases: | 545 // We are compiling one of four cases: |
546 // 1) top-level code, | 546 // 1) top-level code, |
547 // 2) a function/eval/module on the top-level | 547 // 2) a function/eval/module on the top-level |
548 // 3) a function/eval in a scope that was already resolved. | 548 // 3) a function/eval in a scope that was already resolved. |
| 549 // 4) an asm.js function |
549 DCHECK(scope->scope_type() == SCRIPT_SCOPE || | 550 DCHECK(scope->scope_type() == SCRIPT_SCOPE || |
550 scope->outer_scope()->scope_type() == SCRIPT_SCOPE || | 551 scope->outer_scope()->scope_type() == SCRIPT_SCOPE || |
551 scope->outer_scope()->already_resolved_); | 552 scope->outer_scope()->already_resolved_ || |
| 553 (info->asm_function_scope() && scope->is_function_scope())); |
552 | 554 |
553 // The outer scope is never lazy. | 555 // The outer scope is never lazy. |
554 scope->set_should_eager_compile(); | 556 scope->set_should_eager_compile(); |
555 | 557 |
556 scope->AllocateVariables(info, mode); | 558 scope->AllocateVariables(info, mode); |
557 | 559 |
558 // Ensuring that the outer script scope has a scope info avoids having | 560 // Ensuring that the outer script scope has a scope info avoids having |
559 // special case for native contexts vs other contexts. | 561 // special case for native contexts vs other contexts. |
560 if (info->script_scope()->scope_info_.is_null()) { | 562 if (info->script_scope()->scope_info_.is_null()) { |
561 info->script_scope()->scope_info_ = | 563 info->script_scope()->scope_info_ = |
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 Variable* function = | 2073 Variable* function = |
2072 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2074 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
2073 bool is_function_var_in_context = | 2075 bool is_function_var_in_context = |
2074 function != nullptr && function->IsContextSlot(); | 2076 function != nullptr && function->IsContextSlot(); |
2075 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2077 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
2076 (is_function_var_in_context ? 1 : 0); | 2078 (is_function_var_in_context ? 1 : 0); |
2077 } | 2079 } |
2078 | 2080 |
2079 } // namespace internal | 2081 } // namespace internal |
2080 } // namespace v8 | 2082 } // namespace v8 |
OLD | NEW |