OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/interpreter/bytecode-register-allocator.h" | 10 #include "src/interpreter/bytecode-register-allocator.h" |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
753 case VariableLocation::CONTEXT: | 753 case VariableLocation::CONTEXT: |
754 if (hole_init) { | 754 if (hole_init) { |
755 builder()->LoadTheHole().StoreContextSlot(execution_context()->reg(), | 755 builder()->LoadTheHole().StoreContextSlot(execution_context()->reg(), |
756 variable->index()); | 756 variable->index()); |
757 } | 757 } |
758 break; | 758 break; |
759 case VariableLocation::LOOKUP: { | 759 case VariableLocation::LOOKUP: { |
760 DCHECK(IsDeclaredVariableMode(mode)); | 760 DCHECK(IsDeclaredVariableMode(mode)); |
761 DCHECK(!hole_init); | 761 DCHECK(!hole_init); |
762 | 762 |
763 register_allocator()->PrepareForConsecutiveAllocations(3); | 763 register_allocator()->PrepareForConsecutiveAllocations(3); |
Michael Starzinger
2016/06/14 11:11:37
nit: s/3/2/ here, only two consecutive register ne
adamk
2016/06/14 11:23:07
Done.
| |
764 Register name = register_allocator()->NextConsecutiveRegister(); | 764 Register name = register_allocator()->NextConsecutiveRegister(); |
765 Register init_value = register_allocator()->NextConsecutiveRegister(); | 765 Register init_value = register_allocator()->NextConsecutiveRegister(); |
766 Register attributes = register_allocator()->NextConsecutiveRegister(); | |
767 | 766 |
768 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); | 767 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); |
769 builder() | 768 builder() |
770 ->LoadLiteral(Smi::FromInt(0)) | 769 ->LoadLiteral(Smi::FromInt(0)) |
771 .StoreAccumulatorInRegister(init_value); | 770 .StoreAccumulatorInRegister(init_value) |
772 builder() | 771 .CallRuntime(Runtime::kDeclareLookupSlot, name, 2); |
773 ->LoadLiteral(Smi::FromInt(variable->DeclarationPropertyAttributes())) | |
774 .StoreAccumulatorInRegister(attributes) | |
775 .CallRuntime(Runtime::kDeclareLookupSlot, name, 3); | |
776 break; | 772 break; |
777 } | 773 } |
778 } | 774 } |
779 } | 775 } |
780 | 776 |
781 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 777 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
782 Variable* variable = decl->proxy()->var(); | 778 Variable* variable = decl->proxy()->var(); |
783 switch (variable->location()) { | 779 switch (variable->location()) { |
784 case VariableLocation::GLOBAL: | 780 case VariableLocation::GLOBAL: |
785 case VariableLocation::UNALLOCATED: { | 781 case VariableLocation::UNALLOCATED: { |
(...skipping 15 matching lines...) Expand all Loading... | |
801 break; | 797 break; |
802 } | 798 } |
803 case VariableLocation::CONTEXT: { | 799 case VariableLocation::CONTEXT: { |
804 DCHECK_EQ(0, execution_context()->ContextChainDepth(variable->scope())); | 800 DCHECK_EQ(0, execution_context()->ContextChainDepth(variable->scope())); |
805 VisitForAccumulatorValue(decl->fun()); | 801 VisitForAccumulatorValue(decl->fun()); |
806 builder()->StoreContextSlot(execution_context()->reg(), | 802 builder()->StoreContextSlot(execution_context()->reg(), |
807 variable->index()); | 803 variable->index()); |
808 break; | 804 break; |
809 } | 805 } |
810 case VariableLocation::LOOKUP: { | 806 case VariableLocation::LOOKUP: { |
811 register_allocator()->PrepareForConsecutiveAllocations(3); | 807 register_allocator()->PrepareForConsecutiveAllocations(3); |
Michael Starzinger
2016/06/14 11:11:37
nit: Likewise s/3/2/ here.
adamk
2016/06/14 11:23:07
Done.
| |
812 Register name = register_allocator()->NextConsecutiveRegister(); | 808 Register name = register_allocator()->NextConsecutiveRegister(); |
813 Register literal = register_allocator()->NextConsecutiveRegister(); | 809 Register literal = register_allocator()->NextConsecutiveRegister(); |
814 Register attributes = register_allocator()->NextConsecutiveRegister(); | |
815 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); | 810 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); |
816 | 811 |
817 VisitForAccumulatorValue(decl->fun()); | 812 VisitForAccumulatorValue(decl->fun()); |
818 builder() | 813 builder()->StoreAccumulatorInRegister(literal).CallRuntime( |
819 ->StoreAccumulatorInRegister(literal) | 814 Runtime::kDeclareLookupSlot, name, 2); |
820 .LoadLiteral(Smi::FromInt(variable->DeclarationPropertyAttributes())) | |
821 .StoreAccumulatorInRegister(attributes) | |
822 .CallRuntime(Runtime::kDeclareLookupSlot, name, 3); | |
823 } | 815 } |
824 } | 816 } |
825 } | 817 } |
826 | 818 |
827 void BytecodeGenerator::VisitImportDeclaration(ImportDeclaration* decl) { | 819 void BytecodeGenerator::VisitImportDeclaration(ImportDeclaration* decl) { |
828 UNIMPLEMENTED(); | 820 UNIMPLEMENTED(); |
829 } | 821 } |
830 | 822 |
831 void BytecodeGenerator::VisitExportDeclaration(ExportDeclaration* decl) { | 823 void BytecodeGenerator::VisitExportDeclaration(ExportDeclaration* decl) { |
832 UNIMPLEMENTED(); | 824 UNIMPLEMENTED(); |
(...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3190 return execution_context()->scope()->language_mode(); | 3182 return execution_context()->scope()->language_mode(); |
3191 } | 3183 } |
3192 | 3184 |
3193 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3185 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3194 return TypeFeedbackVector::GetIndex(slot); | 3186 return TypeFeedbackVector::GetIndex(slot); |
3195 } | 3187 } |
3196 | 3188 |
3197 } // namespace interpreter | 3189 } // namespace interpreter |
3198 } // namespace internal | 3190 } // namespace internal |
3199 } // namespace v8 | 3191 } // namespace v8 |
OLD | NEW |