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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 740 |
741 | 741 |
742 void BytecodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) { | 742 void BytecodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) { |
743 Variable* variable = decl->proxy()->var(); | 743 Variable* variable = decl->proxy()->var(); |
744 VariableMode mode = decl->mode(); | 744 VariableMode mode = decl->mode(); |
745 // Const and let variables are initialized with the hole so that we can | 745 // Const and let variables are initialized with the hole so that we can |
746 // check that they are only assigned once. | 746 // check that they are only assigned once. |
747 bool hole_init = mode == CONST || mode == LET; | 747 bool hole_init = mode == CONST || mode == LET; |
748 switch (variable->location()) { | 748 switch (variable->location()) { |
749 case VariableLocation::GLOBAL: | 749 case VariableLocation::GLOBAL: |
750 case VariableLocation::UNALLOCATED: { | 750 case VariableLocation::UNALLOCATED: |
751 Handle<Oddball> value = variable->binding_needs_init() | 751 DCHECK(!variable->binding_needs_init()); |
752 ? isolate()->factory()->the_hole_value() | |
753 : isolate()->factory()->undefined_value(); | |
754 globals()->push_back(variable->name()); | 752 globals()->push_back(variable->name()); |
755 globals()->push_back(value); | 753 globals()->push_back(isolate()->factory()->undefined_value()); |
756 break; | 754 break; |
757 } | |
758 case VariableLocation::LOCAL: | 755 case VariableLocation::LOCAL: |
759 if (hole_init) { | 756 if (hole_init) { |
760 Register destination(variable->index()); | 757 Register destination(variable->index()); |
761 builder()->LoadTheHole().StoreAccumulatorInRegister(destination); | 758 builder()->LoadTheHole().StoreAccumulatorInRegister(destination); |
762 } | 759 } |
763 break; | 760 break; |
764 case VariableLocation::PARAMETER: | 761 case VariableLocation::PARAMETER: |
765 if (hole_init) { | 762 if (hole_init) { |
766 // The parameter indices are shifted by 1 (receiver is variable | 763 // The parameter indices are shifted by 1 (receiver is variable |
767 // index -1 but is parameter index 0 in BytecodeArrayBuilder). | 764 // index -1 but is parameter index 0 in BytecodeArrayBuilder). |
(...skipping 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3270 } | 3267 } |
3271 | 3268 |
3272 | 3269 |
3273 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3270 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3274 return info()->shared_info()->feedback_vector()->GetIndex(slot); | 3271 return info()->shared_info()->feedback_vector()->GetIndex(slot); |
3275 } | 3272 } |
3276 | 3273 |
3277 } // namespace interpreter | 3274 } // namespace interpreter |
3278 } // namespace internal | 3275 } // namespace internal |
3279 } // namespace v8 | 3276 } // namespace v8 |
OLD | NEW |