| 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 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 | 1109 |
| 1110 | 1110 |
| 1111 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { | 1111 void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| 1112 TryCatchBuilder try_control_builder(builder()); | 1112 TryCatchBuilder try_control_builder(builder()); |
| 1113 Register no_reg; | 1113 Register no_reg; |
| 1114 | 1114 |
| 1115 // Preserve the context in a dedicated register, so that it can be restored | 1115 // Preserve the context in a dedicated register, so that it can be restored |
| 1116 // when the handler is entered by the stack-unwinding machinery. | 1116 // when the handler is entered by the stack-unwinding machinery. |
| 1117 // TODO(mstarzinger): Be smarter about register allocation. | 1117 // TODO(mstarzinger): Be smarter about register allocation. |
| 1118 Register context = register_allocator()->NewRegister(); | 1118 Register context = register_allocator()->NewRegister(); |
| 1119 builder()->MoveRegister(Register::current_context(), context); |
| 1119 | 1120 |
| 1120 // Evaluate the try-block inside a control scope. This simulates a handler | 1121 // Evaluate the try-block inside a control scope. This simulates a handler |
| 1121 // that is intercepting 'throw' control commands. | 1122 // that is intercepting 'throw' control commands. |
| 1122 try_control_builder.BeginTry(context); | 1123 try_control_builder.BeginTry(context); |
| 1123 { | 1124 { |
| 1124 ControlScopeForTryCatch scope(this, &try_control_builder); | 1125 ControlScopeForTryCatch scope(this, &try_control_builder); |
| 1125 Visit(stmt->try_block()); | 1126 Visit(stmt->try_block()); |
| 1126 } | 1127 } |
| 1127 try_control_builder.EndTry(); | 1128 try_control_builder.EndTry(); |
| 1128 | 1129 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 // - BreakStatement/ContinueStatement: Undefined and not used. | 1163 // - BreakStatement/ContinueStatement: Undefined and not used. |
| 1163 // - Falling through into finally-block: Undefined and not used. | 1164 // - Falling through into finally-block: Undefined and not used. |
| 1164 Register token = register_allocator()->NewRegister(); | 1165 Register token = register_allocator()->NewRegister(); |
| 1165 Register result = register_allocator()->NewRegister(); | 1166 Register result = register_allocator()->NewRegister(); |
| 1166 ControlScope::DeferredCommands commands(this, token, result); | 1167 ControlScope::DeferredCommands commands(this, token, result); |
| 1167 | 1168 |
| 1168 // Preserve the context in a dedicated register, so that it can be restored | 1169 // Preserve the context in a dedicated register, so that it can be restored |
| 1169 // when the handler is entered by the stack-unwinding machinery. | 1170 // when the handler is entered by the stack-unwinding machinery. |
| 1170 // TODO(mstarzinger): Be smarter about register allocation. | 1171 // TODO(mstarzinger): Be smarter about register allocation. |
| 1171 Register context = register_allocator()->NewRegister(); | 1172 Register context = register_allocator()->NewRegister(); |
| 1173 builder()->MoveRegister(Register::current_context(), context); |
| 1172 | 1174 |
| 1173 // Evaluate the try-block inside a control scope. This simulates a handler | 1175 // Evaluate the try-block inside a control scope. This simulates a handler |
| 1174 // that is intercepting all control commands. | 1176 // that is intercepting all control commands. |
| 1175 try_control_builder.BeginTry(context); | 1177 try_control_builder.BeginTry(context); |
| 1176 { | 1178 { |
| 1177 ControlScopeForTryFinally scope(this, &try_control_builder, &commands); | 1179 ControlScopeForTryFinally scope(this, &try_control_builder, &commands); |
| 1178 Visit(stmt->try_block()); | 1180 Visit(stmt->try_block()); |
| 1179 } | 1181 } |
| 1180 try_control_builder.EndTry(); | 1182 try_control_builder.EndTry(); |
| 1181 | 1183 |
| (...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2548 } | 2550 } |
| 2549 | 2551 |
| 2550 | 2552 |
| 2551 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 2553 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 2552 return info()->feedback_vector()->GetIndex(slot); | 2554 return info()->feedback_vector()->GetIndex(slot); |
| 2553 } | 2555 } |
| 2554 | 2556 |
| 2555 } // namespace interpreter | 2557 } // namespace interpreter |
| 2556 } // namespace internal | 2558 } // namespace internal |
| 2557 } // namespace v8 | 2559 } // namespace v8 |
| OLD | NEW |