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