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/control-flow-builders.h" | 9 #include "src/interpreter/control-flow-builders.h" |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 BytecodeLabel subject_null_label, subject_undefined_label, not_object_label; | 887 BytecodeLabel subject_null_label, subject_undefined_label, not_object_label; |
888 | 888 |
889 // Prepare the state for executing ForIn. | 889 // Prepare the state for executing ForIn. |
890 VisitForAccumulatorValue(stmt->subject()); | 890 VisitForAccumulatorValue(stmt->subject()); |
891 builder()->JumpIfUndefined(&subject_undefined_label); | 891 builder()->JumpIfUndefined(&subject_undefined_label); |
892 builder()->JumpIfNull(&subject_null_label); | 892 builder()->JumpIfNull(&subject_null_label); |
893 Register receiver = execution_result()->NewRegister(); | 893 Register receiver = execution_result()->NewRegister(); |
894 builder()->CastAccumulatorToJSObject(); | 894 builder()->CastAccumulatorToJSObject(); |
895 builder()->JumpIfNull(¬_object_label); | 895 builder()->JumpIfNull(¬_object_label); |
896 builder()->StoreAccumulatorInRegister(receiver); | 896 builder()->StoreAccumulatorInRegister(receiver); |
897 Register cache_type = execution_result()->NewRegister(); | 897 |
898 Register cache_array = execution_result()->NewRegister(); | 898 execution_result()->PrepareForConsecutiveAllocations(3); |
899 Register cache_length = execution_result()->NewRegister(); | 899 Register cache_type = execution_result()->NextConsecutiveRegister(); |
900 builder()->ForInPrepare(cache_type, cache_array, cache_length); | 900 Register cache_array = execution_result()->NextConsecutiveRegister(); |
| 901 Register cache_length = execution_result()->NextConsecutiveRegister(); |
| 902 builder()->ForInPrepare(cache_type); |
901 | 903 |
902 // Set up loop counter | 904 // Set up loop counter |
903 Register index = execution_result()->NewRegister(); | 905 Register index = execution_result()->NewRegister(); |
904 builder()->LoadLiteral(Smi::FromInt(0)); | 906 builder()->LoadLiteral(Smi::FromInt(0)); |
905 builder()->StoreAccumulatorInRegister(index); | 907 builder()->StoreAccumulatorInRegister(index); |
906 | 908 |
907 // The loop | 909 // The loop |
908 loop_builder.LoopHeader(); | 910 loop_builder.LoopHeader(); |
909 loop_builder.Condition(); | 911 loop_builder.Condition(); |
910 builder()->ForInDone(index, cache_length); | 912 builder()->ForInDone(index, cache_length); |
911 loop_builder.BreakIfTrue(); | 913 loop_builder.BreakIfTrue(); |
912 builder()->ForInNext(receiver, cache_type, cache_array, index); | 914 DCHECK(Register::AreContiguous(cache_type, cache_array)); |
| 915 builder()->ForInNext(receiver, index, cache_type); |
913 loop_builder.ContinueIfUndefined(); | 916 loop_builder.ContinueIfUndefined(); |
914 VisitForInAssignment(stmt->each(), stmt->EachFeedbackSlot()); | 917 VisitForInAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
915 Visit(stmt->body()); | 918 Visit(stmt->body()); |
916 loop_builder.Next(); | 919 loop_builder.Next(); |
917 builder()->ForInStep(index); | 920 builder()->ForInStep(index); |
918 builder()->StoreAccumulatorInRegister(index); | 921 builder()->StoreAccumulatorInRegister(index); |
919 loop_builder.JumpToHeader(); | 922 loop_builder.JumpToHeader(); |
920 loop_builder.EndLoop(); | 923 loop_builder.EndLoop(); |
921 builder()->Bind(¬_object_label); | 924 builder()->Bind(¬_object_label); |
922 builder()->Bind(&subject_null_label); | 925 builder()->Bind(&subject_null_label); |
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 } | 2289 } |
2287 | 2290 |
2288 | 2291 |
2289 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 2292 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
2290 return info()->feedback_vector()->GetIndex(slot); | 2293 return info()->feedback_vector()->GetIndex(slot); |
2291 } | 2294 } |
2292 | 2295 |
2293 } // namespace interpreter | 2296 } // namespace interpreter |
2294 } // namespace internal | 2297 } // namespace internal |
2295 } // namespace v8 | 2298 } // namespace v8 |
OLD | NEW |