Chromium Code Reviews| Index: src/interpreter/bytecode-generator.cc |
| diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
| index 4ef0506a12388cf0f534058b33b98e21f3689169..b236f355033ad81d1b5fc4aed08f781d88455ee8 100644 |
| --- a/src/interpreter/bytecode-generator.cc |
| +++ b/src/interpreter/bytecode-generator.cc |
| @@ -1107,6 +1107,7 @@ void BytecodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { |
| void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| TryCatchBuilder try_control_builder(builder()); |
| + Register no_reg; |
| // Preserve the context in a dedicated register, so that it can be restored |
| // when the handler is entered by the stack-unwinding machinery. |
| @@ -1122,11 +1123,15 @@ void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| } |
| try_control_builder.EndTry(); |
| - // Clear message object as we enter the catch block. |
| - // TODO(mstarzinger): Implement this! |
| - |
| // Create a catch scope that binds the exception. |
| VisitNewLocalCatchContext(stmt->variable()); |
| + builder()->StoreAccumulatorInRegister(context); |
| + |
| + // Clear message object as we enter the catch block. |
| + builder()->CallRuntime(Runtime::kInterpreterClearPendingMessage, no_reg, 0); |
| + |
| + // Load the catch context into the accumulator. |
| + builder()->LoadAccumulatorWithRegister(context); |
| // Evaluate the catch-block. |
| VisitInScope(stmt->catch_block(), stmt->scope()); |
| @@ -1136,6 +1141,7 @@ void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { |
| TryFinallyBuilder try_control_builder(builder()); |
| + Register no_reg; |
| // We keep a record of all paths that enter the finally-block to be able to |
| // dispatch to the correct continuation point after the statements in the |
| @@ -1176,15 +1182,23 @@ void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { |
| try_control_builder.BeginHandler(); |
| commands.RecordHandlerReThrowPath(); |
| + // Pending message object is saved on entry. |
| try_control_builder.BeginFinally(); |
| + Register message = context; // Reuse register. |
| + builder() |
| + ->CallRuntime(Runtime::kInterpreterGetPendingMessage, no_reg, 0) |
| + .StoreAccumulatorInRegister(message); |
| // Clear message object as we enter the finally block. |
| - // TODO(mstarzinger): Implement this! |
| + builder()->CallRuntime(Runtime::kInterpreterClearPendingMessage, no_reg, 0); |
|
rmcilroy
2016/02/01 20:57:14
Could we make InterpreterGetPendingMessage also cl
Michael Starzinger
2016/02/02 09:41:43
Done. I made kInterpreterClearPendingMessage retur
|
| // Evaluate the finally-block. |
| Visit(stmt->finally_block()); |
| try_control_builder.EndFinally(); |
| + // Pending message object is restored on exit. |
| + builder()->CallRuntime(Runtime::kInterpreterSetPendingMessage, message, 1); |
| + |
| // Dynamic dispatch after the finally-block. |
| commands.ApplyDeferredCommands(); |
| } |