| 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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 VariableDeclaration* declaration) { | 725 VariableDeclaration* declaration) { |
| 726 // If it was not possible to allocate the variable at compile time, we | 726 // If it was not possible to allocate the variable at compile time, we |
| 727 // need to "declare" it at runtime to make sure it actually exists in the | 727 // need to "declare" it at runtime to make sure it actually exists in the |
| 728 // local context. | 728 // local context. |
| 729 VariableProxy* proxy = declaration->proxy(); | 729 VariableProxy* proxy = declaration->proxy(); |
| 730 VariableMode mode = declaration->mode(); | 730 VariableMode mode = declaration->mode(); |
| 731 Variable* variable = proxy->var(); | 731 Variable* variable = proxy->var(); |
| 732 bool hole_init = mode == LET || mode == CONST; | 732 bool hole_init = mode == LET || mode == CONST; |
| 733 switch (variable->location()) { | 733 switch (variable->location()) { |
| 734 case VariableLocation::GLOBAL: | 734 case VariableLocation::GLOBAL: |
| 735 case VariableLocation::UNALLOCATED: | 735 case VariableLocation::UNALLOCATED: { |
| 736 DCHECK(!variable->binding_needs_init()); | 736 DCHECK(!variable->binding_needs_init()); |
| 737 globals_->Add(variable->name(), zone()); | 737 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); |
| 738 DCHECK(!slot.IsInvalid()); |
| 739 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); |
| 738 globals_->Add(isolate()->factory()->undefined_value(), zone()); | 740 globals_->Add(isolate()->factory()->undefined_value(), zone()); |
| 739 break; | 741 break; |
| 740 | 742 } |
| 741 case VariableLocation::PARAMETER: | 743 case VariableLocation::PARAMETER: |
| 742 case VariableLocation::LOCAL: | 744 case VariableLocation::LOCAL: |
| 743 if (hole_init) { | 745 if (hole_init) { |
| 744 Comment cmnt(masm_, "[ VariableDeclaration"); | 746 Comment cmnt(masm_, "[ VariableDeclaration"); |
| 745 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); | 747 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); |
| 746 __ movp(StackOperand(variable), kScratchRegister); | 748 __ movp(StackOperand(variable), kScratchRegister); |
| 747 } | 749 } |
| 748 break; | 750 break; |
| 749 | 751 |
| 750 case VariableLocation::CONTEXT: | 752 case VariableLocation::CONTEXT: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 771 } | 773 } |
| 772 | 774 |
| 773 | 775 |
| 774 void FullCodeGenerator::VisitFunctionDeclaration( | 776 void FullCodeGenerator::VisitFunctionDeclaration( |
| 775 FunctionDeclaration* declaration) { | 777 FunctionDeclaration* declaration) { |
| 776 VariableProxy* proxy = declaration->proxy(); | 778 VariableProxy* proxy = declaration->proxy(); |
| 777 Variable* variable = proxy->var(); | 779 Variable* variable = proxy->var(); |
| 778 switch (variable->location()) { | 780 switch (variable->location()) { |
| 779 case VariableLocation::GLOBAL: | 781 case VariableLocation::GLOBAL: |
| 780 case VariableLocation::UNALLOCATED: { | 782 case VariableLocation::UNALLOCATED: { |
| 781 globals_->Add(variable->name(), zone()); | 783 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); |
| 784 DCHECK(!slot.IsInvalid()); |
| 785 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); |
| 782 Handle<SharedFunctionInfo> function = | 786 Handle<SharedFunctionInfo> function = |
| 783 Compiler::GetSharedFunctionInfo(declaration->fun(), script(), info_); | 787 Compiler::GetSharedFunctionInfo(declaration->fun(), script(), info_); |
| 784 // Check for stack-overflow exception. | 788 // Check for stack-overflow exception. |
| 785 if (function.is_null()) return SetStackOverflow(); | 789 if (function.is_null()) return SetStackOverflow(); |
| 786 globals_->Add(function, zone()); | 790 globals_->Add(function, zone()); |
| 787 break; | 791 break; |
| 788 } | 792 } |
| 789 | 793 |
| 790 case VariableLocation::PARAMETER: | 794 case VariableLocation::PARAMETER: |
| 791 case VariableLocation::LOCAL: { | 795 case VariableLocation::LOCAL: { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 822 break; | 826 break; |
| 823 } | 827 } |
| 824 } | 828 } |
| 825 } | 829 } |
| 826 | 830 |
| 827 | 831 |
| 828 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 832 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
| 829 // Call the runtime to declare the globals. | 833 // Call the runtime to declare the globals. |
| 830 __ Push(pairs); | 834 __ Push(pairs); |
| 831 __ Push(Smi::FromInt(DeclareGlobalsFlags())); | 835 __ Push(Smi::FromInt(DeclareGlobalsFlags())); |
| 836 __ EmitLoadTypeFeedbackVector(rax); |
| 837 __ Push(rax); |
| 832 __ CallRuntime(Runtime::kDeclareGlobals); | 838 __ CallRuntime(Runtime::kDeclareGlobals); |
| 833 // Return value is ignored. | 839 // Return value is ignored. |
| 834 } | 840 } |
| 835 | 841 |
| 836 | 842 |
| 837 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { | 843 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
| 838 Comment cmnt(masm_, "[ SwitchStatement"); | 844 Comment cmnt(masm_, "[ SwitchStatement"); |
| 839 Breakable nested_statement(this, stmt); | 845 Breakable nested_statement(this, stmt); |
| 840 SetStatementPosition(stmt); | 846 SetStatementPosition(stmt); |
| 841 | 847 |
| (...skipping 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3675 DCHECK_EQ( | 3681 DCHECK_EQ( |
| 3676 isolate->builtins()->OnStackReplacement()->entry(), | 3682 isolate->builtins()->OnStackReplacement()->entry(), |
| 3677 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3683 Assembler::target_address_at(call_target_address, unoptimized_code)); |
| 3678 return ON_STACK_REPLACEMENT; | 3684 return ON_STACK_REPLACEMENT; |
| 3679 } | 3685 } |
| 3680 | 3686 |
| 3681 } // namespace internal | 3687 } // namespace internal |
| 3682 } // namespace v8 | 3688 } // namespace v8 |
| 3683 | 3689 |
| 3684 #endif // V8_TARGET_ARCH_X64 | 3690 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |