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-flags.h" | 10 #include "src/interpreter/bytecode-flags.h" |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 VisitForAccumulatorValue(stmt->result_done()); | 1177 VisitForAccumulatorValue(stmt->result_done()); |
1178 loop_builder.BreakIfTrue(); | 1178 loop_builder.BreakIfTrue(); |
1179 | 1179 |
1180 VisitForEffect(stmt->assign_each()); | 1180 VisitForEffect(stmt->assign_each()); |
1181 VisitIterationBody(stmt, &loop_builder); | 1181 VisitIterationBody(stmt, &loop_builder); |
1182 loop_builder.JumpToHeader(); | 1182 loop_builder.JumpToHeader(); |
1183 loop_builder.EndLoop(); | 1183 loop_builder.EndLoop(); |
1184 } | 1184 } |
1185 | 1185 |
1186 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { | 1186 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
1187 TryCatchBuilder try_control_builder(builder(), stmt->catch_predicted()); | 1187 TryCatchBuilder try_control_builder(builder(), stmt->catch_prediction()); |
1188 Register no_reg; | 1188 Register no_reg; |
1189 | 1189 |
1190 // Preserve the context in a dedicated register, so that it can be restored | 1190 // Preserve the context in a dedicated register, so that it can be restored |
1191 // when the handler is entered by the stack-unwinding machinery. | 1191 // when the handler is entered by the stack-unwinding machinery. |
1192 // TODO(mstarzinger): Be smarter about register allocation. | 1192 // TODO(mstarzinger): Be smarter about register allocation. |
1193 Register context = register_allocator()->NewRegister(); | 1193 Register context = register_allocator()->NewRegister(); |
1194 builder()->MoveRegister(Register::current_context(), context); | 1194 builder()->MoveRegister(Register::current_context(), context); |
1195 | 1195 |
1196 // Evaluate the try-block inside a control scope. This simulates a handler | 1196 // Evaluate the try-block inside a control scope. This simulates a handler |
1197 // that is intercepting 'throw' control commands. | 1197 // that is intercepting 'throw' control commands. |
(...skipping 15 matching lines...) Expand all Loading... |
1213 | 1213 |
1214 // Load the catch context into the accumulator. | 1214 // Load the catch context into the accumulator. |
1215 builder()->LoadAccumulatorWithRegister(context); | 1215 builder()->LoadAccumulatorWithRegister(context); |
1216 | 1216 |
1217 // Evaluate the catch-block. | 1217 // Evaluate the catch-block. |
1218 VisitInScope(stmt->catch_block(), stmt->scope()); | 1218 VisitInScope(stmt->catch_block(), stmt->scope()); |
1219 try_control_builder.EndCatch(); | 1219 try_control_builder.EndCatch(); |
1220 } | 1220 } |
1221 | 1221 |
1222 void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { | 1222 void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { |
1223 TryFinallyBuilder try_control_builder(builder(), stmt->catch_predicted()); | 1223 TryFinallyBuilder try_control_builder(builder(), stmt->catch_prediction()); |
1224 Register no_reg; | 1224 Register no_reg; |
1225 | 1225 |
1226 // We keep a record of all paths that enter the finally-block to be able to | 1226 // We keep a record of all paths that enter the finally-block to be able to |
1227 // dispatch to the correct continuation point after the statements in the | 1227 // dispatch to the correct continuation point after the statements in the |
1228 // finally-block have been evaluated. | 1228 // finally-block have been evaluated. |
1229 // | 1229 // |
1230 // The try-finally construct can enter the finally-block in three ways: | 1230 // The try-finally construct can enter the finally-block in three ways: |
1231 // 1. By exiting the try-block normally, falling through at the end. | 1231 // 1. By exiting the try-block normally, falling through at the end. |
1232 // 2. By exiting the try-block with a function-local control flow transfer | 1232 // 2. By exiting the try-block with a function-local control flow transfer |
1233 // (i.e. through break/continue/return statements). | 1233 // (i.e. through break/continue/return statements). |
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3178 return execution_context()->scope()->language_mode(); | 3178 return execution_context()->scope()->language_mode(); |
3179 } | 3179 } |
3180 | 3180 |
3181 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3181 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3182 return TypeFeedbackVector::GetIndex(slot); | 3182 return TypeFeedbackVector::GetIndex(slot); |
3183 } | 3183 } |
3184 | 3184 |
3185 } // namespace interpreter | 3185 } // namespace interpreter |
3186 } // namespace internal | 3186 } // namespace internal |
3187 } // namespace v8 | 3187 } // namespace v8 |
OLD | NEW |