| 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 VariableDeclaration* declaration) { | 713 VariableDeclaration* declaration) { |
| 714 // If it was not possible to allocate the variable at compile time, we | 714 // If it was not possible to allocate the variable at compile time, we |
| 715 // need to "declare" it at runtime to make sure it actually exists in the | 715 // need to "declare" it at runtime to make sure it actually exists in the |
| 716 // local context. | 716 // local context. |
| 717 VariableProxy* proxy = declaration->proxy(); | 717 VariableProxy* proxy = declaration->proxy(); |
| 718 VariableMode mode = declaration->mode(); | 718 VariableMode mode = declaration->mode(); |
| 719 Variable* variable = proxy->var(); | 719 Variable* variable = proxy->var(); |
| 720 bool hole_init = mode == LET || mode == CONST; | 720 bool hole_init = mode == LET || mode == CONST; |
| 721 switch (variable->location()) { | 721 switch (variable->location()) { |
| 722 case VariableLocation::GLOBAL: | 722 case VariableLocation::GLOBAL: |
| 723 case VariableLocation::UNALLOCATED: | 723 case VariableLocation::UNALLOCATED: { |
| 724 DCHECK(!variable->binding_needs_init()); | 724 DCHECK(!variable->binding_needs_init()); |
| 725 globals_->Add(variable->name(), zone()); | 725 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); |
| 726 DCHECK(!slot.IsInvalid()); |
| 727 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); |
| 726 globals_->Add(isolate()->factory()->undefined_value(), zone()); | 728 globals_->Add(isolate()->factory()->undefined_value(), zone()); |
| 727 break; | 729 break; |
| 728 | 730 } |
| 729 case VariableLocation::PARAMETER: | 731 case VariableLocation::PARAMETER: |
| 730 case VariableLocation::LOCAL: | 732 case VariableLocation::LOCAL: |
| 731 if (hole_init) { | 733 if (hole_init) { |
| 732 Comment cmnt(masm_, "[ VariableDeclaration"); | 734 Comment cmnt(masm_, "[ VariableDeclaration"); |
| 733 __ mov(StackOperand(variable), | 735 __ mov(StackOperand(variable), |
| 734 Immediate(isolate()->factory()->the_hole_value())); | 736 Immediate(isolate()->factory()->the_hole_value())); |
| 735 } | 737 } |
| 736 break; | 738 break; |
| 737 | 739 |
| 738 case VariableLocation::CONTEXT: | 740 case VariableLocation::CONTEXT: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 759 } | 761 } |
| 760 | 762 |
| 761 | 763 |
| 762 void FullCodeGenerator::VisitFunctionDeclaration( | 764 void FullCodeGenerator::VisitFunctionDeclaration( |
| 763 FunctionDeclaration* declaration) { | 765 FunctionDeclaration* declaration) { |
| 764 VariableProxy* proxy = declaration->proxy(); | 766 VariableProxy* proxy = declaration->proxy(); |
| 765 Variable* variable = proxy->var(); | 767 Variable* variable = proxy->var(); |
| 766 switch (variable->location()) { | 768 switch (variable->location()) { |
| 767 case VariableLocation::GLOBAL: | 769 case VariableLocation::GLOBAL: |
| 768 case VariableLocation::UNALLOCATED: { | 770 case VariableLocation::UNALLOCATED: { |
| 769 globals_->Add(variable->name(), zone()); | 771 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); |
| 772 DCHECK(!slot.IsInvalid()); |
| 773 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); |
| 770 Handle<SharedFunctionInfo> function = | 774 Handle<SharedFunctionInfo> function = |
| 771 Compiler::GetSharedFunctionInfo(declaration->fun(), script(), info_); | 775 Compiler::GetSharedFunctionInfo(declaration->fun(), script(), info_); |
| 772 // Check for stack-overflow exception. | 776 // Check for stack-overflow exception. |
| 773 if (function.is_null()) return SetStackOverflow(); | 777 if (function.is_null()) return SetStackOverflow(); |
| 774 globals_->Add(function, zone()); | 778 globals_->Add(function, zone()); |
| 775 break; | 779 break; |
| 776 } | 780 } |
| 777 | 781 |
| 778 case VariableLocation::PARAMETER: | 782 case VariableLocation::PARAMETER: |
| 779 case VariableLocation::LOCAL: { | 783 case VariableLocation::LOCAL: { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 809 break; | 813 break; |
| 810 } | 814 } |
| 811 } | 815 } |
| 812 } | 816 } |
| 813 | 817 |
| 814 | 818 |
| 815 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 819 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
| 816 // Call the runtime to declare the globals. | 820 // Call the runtime to declare the globals. |
| 817 __ Push(pairs); | 821 __ Push(pairs); |
| 818 __ Push(Smi::FromInt(DeclareGlobalsFlags())); | 822 __ Push(Smi::FromInt(DeclareGlobalsFlags())); |
| 823 __ EmitLoadTypeFeedbackVector(eax); |
| 824 __ Push(eax); |
| 819 __ CallRuntime(Runtime::kDeclareGlobals); | 825 __ CallRuntime(Runtime::kDeclareGlobals); |
| 820 // Return value is ignored. | 826 // Return value is ignored. |
| 821 } | 827 } |
| 822 | 828 |
| 823 | 829 |
| 824 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { | 830 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
| 825 Comment cmnt(masm_, "[ SwitchStatement"); | 831 Comment cmnt(masm_, "[ SwitchStatement"); |
| 826 Breakable nested_statement(this, stmt); | 832 Breakable nested_statement(this, stmt); |
| 827 SetStatementPosition(stmt); | 833 SetStatementPosition(stmt); |
| 828 | 834 |
| (...skipping 2856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3685 isolate->builtins()->OnStackReplacement()->entry(), | 3691 isolate->builtins()->OnStackReplacement()->entry(), |
| 3686 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3692 Assembler::target_address_at(call_target_address, unoptimized_code)); |
| 3687 return ON_STACK_REPLACEMENT; | 3693 return ON_STACK_REPLACEMENT; |
| 3688 } | 3694 } |
| 3689 | 3695 |
| 3690 | 3696 |
| 3691 } // namespace internal | 3697 } // namespace internal |
| 3692 } // namespace v8 | 3698 } // namespace v8 |
| 3693 | 3699 |
| 3694 #endif // V8_TARGET_ARCH_IA32 | 3700 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |