Chromium Code Reviews| 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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 750 builder()->LoadTheHole().StoreAccumulatorInRegister(destination); | 750 builder()->LoadTheHole().StoreAccumulatorInRegister(destination); |
| 751 } | 751 } |
| 752 break; | 752 break; |
| 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_EQ(VAR, mode); |
| 761 DCHECK(!hole_init); | 761 DCHECK(!hole_init); |
| 762 | 762 |
| 763 register_allocator()->PrepareForConsecutiveAllocations(3); | 763 register_allocator()->PrepareForConsecutiveAllocations(1); |
|
Michael Starzinger
2016/06/14 14:47:32
nit: For a single register, there is no need to pr
adamk
2016/06/14 14:59:43
Done.
| |
| 764 Register name = register_allocator()->NextConsecutiveRegister(); | 764 Register name = register_allocator()->NextConsecutiveRegister(); |
|
Michael Starzinger
2016/06/14 14:47:32
nit: This can be just register_allocator()->NewReg
adamk
2016/06/14 14:59:43
Done.
| |
| 765 Register init_value = register_allocator()->NextConsecutiveRegister(); | |
| 766 Register attributes = register_allocator()->NextConsecutiveRegister(); | |
| 767 | 765 |
| 768 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); | |
| 769 builder() | 766 builder() |
| 770 ->LoadLiteral(Smi::FromInt(0)) | 767 ->LoadLiteral(variable->name()) |
| 771 .StoreAccumulatorInRegister(init_value); | 768 .StoreAccumulatorInRegister(name) |
| 772 builder() | 769 .CallRuntime(Runtime::kDeclareEvalVar, name, 1); |
| 773 ->LoadLiteral(Smi::FromInt(variable->DeclarationPropertyAttributes())) | |
| 774 .StoreAccumulatorInRegister(attributes) | |
| 775 .CallRuntime(Runtime::kDeclareLookupSlot, name, 3); | |
| 776 break; | 770 break; |
| 777 } | 771 } |
| 778 } | 772 } |
| 779 } | 773 } |
| 780 | 774 |
| 781 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 775 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
| 782 Variable* variable = decl->proxy()->var(); | 776 Variable* variable = decl->proxy()->var(); |
| 783 switch (variable->location()) { | 777 switch (variable->location()) { |
| 784 case VariableLocation::GLOBAL: | 778 case VariableLocation::GLOBAL: |
| 785 case VariableLocation::UNALLOCATED: { | 779 case VariableLocation::UNALLOCATED: { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 801 break; | 795 break; |
| 802 } | 796 } |
| 803 case VariableLocation::CONTEXT: { | 797 case VariableLocation::CONTEXT: { |
| 804 DCHECK_EQ(0, execution_context()->ContextChainDepth(variable->scope())); | 798 DCHECK_EQ(0, execution_context()->ContextChainDepth(variable->scope())); |
| 805 VisitForAccumulatorValue(decl->fun()); | 799 VisitForAccumulatorValue(decl->fun()); |
| 806 builder()->StoreContextSlot(execution_context()->reg(), | 800 builder()->StoreContextSlot(execution_context()->reg(), |
| 807 variable->index()); | 801 variable->index()); |
| 808 break; | 802 break; |
| 809 } | 803 } |
| 810 case VariableLocation::LOOKUP: { | 804 case VariableLocation::LOOKUP: { |
| 811 register_allocator()->PrepareForConsecutiveAllocations(3); | 805 register_allocator()->PrepareForConsecutiveAllocations(2); |
| 812 Register name = register_allocator()->NextConsecutiveRegister(); | 806 Register name = register_allocator()->NextConsecutiveRegister(); |
| 813 Register literal = register_allocator()->NextConsecutiveRegister(); | 807 Register literal = register_allocator()->NextConsecutiveRegister(); |
| 814 Register attributes = register_allocator()->NextConsecutiveRegister(); | |
| 815 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); | 808 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); |
| 816 | 809 |
| 817 VisitForAccumulatorValue(decl->fun()); | 810 VisitForAccumulatorValue(decl->fun()); |
| 818 builder() | 811 builder()->StoreAccumulatorInRegister(literal).CallRuntime( |
| 819 ->StoreAccumulatorInRegister(literal) | 812 Runtime::kDeclareEvalFunction, name, 2); |
| 820 .LoadLiteral(Smi::FromInt(variable->DeclarationPropertyAttributes())) | |
| 821 .StoreAccumulatorInRegister(attributes) | |
| 822 .CallRuntime(Runtime::kDeclareLookupSlot, name, 3); | |
| 823 } | 813 } |
| 824 } | 814 } |
| 825 } | 815 } |
| 826 | 816 |
| 827 void BytecodeGenerator::VisitImportDeclaration(ImportDeclaration* decl) { | 817 void BytecodeGenerator::VisitImportDeclaration(ImportDeclaration* decl) { |
| 828 UNIMPLEMENTED(); | 818 UNIMPLEMENTED(); |
| 829 } | 819 } |
| 830 | 820 |
| 831 void BytecodeGenerator::VisitExportDeclaration(ExportDeclaration* decl) { | 821 void BytecodeGenerator::VisitExportDeclaration(ExportDeclaration* decl) { |
| 832 UNIMPLEMENTED(); | 822 UNIMPLEMENTED(); |
| (...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3190 return execution_context()->scope()->language_mode(); | 3180 return execution_context()->scope()->language_mode(); |
| 3191 } | 3181 } |
| 3192 | 3182 |
| 3193 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3183 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3194 return TypeFeedbackVector::GetIndex(slot); | 3184 return TypeFeedbackVector::GetIndex(slot); |
| 3195 } | 3185 } |
| 3196 | 3186 |
| 3197 } // namespace interpreter | 3187 } // namespace interpreter |
| 3198 } // namespace internal | 3188 } // namespace internal |
| 3199 } // namespace v8 | 3189 } // namespace v8 |
| OLD | NEW |