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