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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 builder()->StoreAccumulatorInRegister(index); | 887 builder()->StoreAccumulatorInRegister(index); |
888 loop_builder.JumpToHeader(); | 888 loop_builder.JumpToHeader(); |
889 loop_builder.EndLoop(); | 889 loop_builder.EndLoop(); |
890 builder()->Bind(¬_object_label); | 890 builder()->Bind(¬_object_label); |
891 builder()->Bind(&subject_null_label); | 891 builder()->Bind(&subject_null_label); |
892 builder()->Bind(&subject_undefined_label); | 892 builder()->Bind(&subject_undefined_label); |
893 } | 893 } |
894 | 894 |
895 | 895 |
896 void BytecodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { | 896 void BytecodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { |
897 UNIMPLEMENTED(); | 897 LoopBuilder loop_builder(builder()); |
| 898 ControlScopeForIteration control_scope(this, stmt, &loop_builder); |
| 899 |
| 900 VisitForEffect(stmt->assign_iterator()); |
| 901 |
| 902 loop_builder.LoopHeader(); |
| 903 loop_builder.Next(); |
| 904 VisitForEffect(stmt->next_result()); |
| 905 VisitForAccumulatorValue(stmt->result_done()); |
| 906 loop_builder.BreakIfTrue(); |
| 907 |
| 908 VisitForEffect(stmt->assign_each()); |
| 909 Visit(stmt->body()); |
| 910 loop_builder.JumpToHeader(); |
| 911 loop_builder.EndLoop(); |
898 } | 912 } |
899 | 913 |
900 | 914 |
901 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { | 915 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
902 TryCatchBuilder try_control_builder(builder()); | 916 TryCatchBuilder try_control_builder(builder()); |
903 | 917 |
904 // Preserve the context in a dedicated register, so that it can be restored | 918 // Preserve the context in a dedicated register, so that it can be restored |
905 // when the handler is entered by the stack-unwinding machinery. | 919 // when the handler is entered by the stack-unwinding machinery. |
906 // TODO(mstarzinger): Be smarter about register allocation. | 920 // TODO(mstarzinger): Be smarter about register allocation. |
907 Register context = register_allocator()->NewRegister(); | 921 Register context = register_allocator()->NewRegister(); |
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 } | 2292 } |
2279 | 2293 |
2280 | 2294 |
2281 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 2295 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
2282 return info()->feedback_vector()->GetIndex(slot); | 2296 return info()->feedback_vector()->GetIndex(slot); |
2283 } | 2297 } |
2284 | 2298 |
2285 } // namespace interpreter | 2299 } // namespace interpreter |
2286 } // namespace internal | 2300 } // namespace internal |
2287 } // namespace v8 | 2301 } // namespace v8 |
OLD | NEW |