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/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/interpreter/bytecode-register-allocator.h" | 9 #include "src/interpreter/bytecode-register-allocator.h" |
10 #include "src/interpreter/control-flow-builders.h" | 10 #include "src/interpreter/control-flow-builders.h" |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 BytecodeLabel subject_null_label, subject_undefined_label, not_object_label; | 814 BytecodeLabel subject_null_label, subject_undefined_label, not_object_label; |
815 | 815 |
816 // Prepare the state for executing ForIn. | 816 // Prepare the state for executing ForIn. |
817 VisitForAccumulatorValue(stmt->subject()); | 817 VisitForAccumulatorValue(stmt->subject()); |
818 builder()->JumpIfUndefined(&subject_undefined_label); | 818 builder()->JumpIfUndefined(&subject_undefined_label); |
819 builder()->JumpIfNull(&subject_null_label); | 819 builder()->JumpIfNull(&subject_null_label); |
820 Register receiver = register_allocator()->NewRegister(); | 820 Register receiver = register_allocator()->NewRegister(); |
821 builder()->CastAccumulatorToJSObject(); | 821 builder()->CastAccumulatorToJSObject(); |
822 builder()->JumpIfNull(¬_object_label); | 822 builder()->JumpIfNull(¬_object_label); |
823 builder()->StoreAccumulatorInRegister(receiver); | 823 builder()->StoreAccumulatorInRegister(receiver); |
824 Register cache_type = register_allocator()->NewRegister(); | 824 |
825 Register cache_array = register_allocator()->NewRegister(); | 825 register_allocator()->PrepareForConsecutiveAllocations(3); |
826 Register cache_length = register_allocator()->NewRegister(); | 826 Register cache_type = register_allocator()->NextConsecutiveRegister(); |
827 builder()->ForInPrepare(cache_type, cache_array, cache_length); | 827 Register cache_array = register_allocator()->NextConsecutiveRegister(); |
| 828 Register cache_length = register_allocator()->NextConsecutiveRegister(); |
| 829 // Used as kRegTriple8 and kRegPair8 in ForInPrepare and ForInNext. |
| 830 USE(cache_array); |
| 831 builder()->ForInPrepare(cache_type); |
828 | 832 |
829 // Set up loop counter | 833 // Set up loop counter |
830 Register index = register_allocator()->NewRegister(); | 834 Register index = register_allocator()->NewRegister(); |
831 builder()->LoadLiteral(Smi::FromInt(0)); | 835 builder()->LoadLiteral(Smi::FromInt(0)); |
832 builder()->StoreAccumulatorInRegister(index); | 836 builder()->StoreAccumulatorInRegister(index); |
833 | 837 |
834 // The loop | 838 // The loop |
835 loop_builder.LoopHeader(); | 839 loop_builder.LoopHeader(); |
836 loop_builder.Condition(); | 840 loop_builder.Condition(); |
837 builder()->ForInDone(index, cache_length); | 841 builder()->ForInDone(index, cache_length); |
838 loop_builder.BreakIfTrue(); | 842 loop_builder.BreakIfTrue(); |
839 builder()->ForInNext(receiver, cache_type, cache_array, index); | 843 DCHECK(Register::AreContiguous(cache_type, cache_array)); |
| 844 builder()->ForInNext(receiver, index, cache_type); |
840 loop_builder.ContinueIfUndefined(); | 845 loop_builder.ContinueIfUndefined(); |
841 VisitForInAssignment(stmt->each(), stmt->EachFeedbackSlot()); | 846 VisitForInAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
842 Visit(stmt->body()); | 847 Visit(stmt->body()); |
843 loop_builder.Next(); | 848 loop_builder.Next(); |
844 builder()->ForInStep(index); | 849 builder()->ForInStep(index); |
845 builder()->StoreAccumulatorInRegister(index); | 850 builder()->StoreAccumulatorInRegister(index); |
846 loop_builder.JumpToHeader(); | 851 loop_builder.JumpToHeader(); |
847 loop_builder.EndLoop(); | 852 loop_builder.EndLoop(); |
848 builder()->Bind(¬_object_label); | 853 builder()->Bind(¬_object_label); |
849 builder()->Bind(&subject_null_label); | 854 builder()->Bind(&subject_null_label); |
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 } | 2178 } |
2174 | 2179 |
2175 | 2180 |
2176 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 2181 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
2177 return info()->feedback_vector()->GetIndex(slot); | 2182 return info()->feedback_vector()->GetIndex(slot); |
2178 } | 2183 } |
2179 | 2184 |
2180 } // namespace interpreter | 2185 } // namespace interpreter |
2181 } // namespace internal | 2186 } // namespace internal |
2182 } // namespace v8 | 2187 } // namespace v8 |
OLD | NEW |