Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 0b74a8dd3b8a100a40ea16598c06858f1b8aad42..db6acc2505a3f2c32718cbea7ca90812372b6318 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -917,17 +917,8 @@ void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
// TODO(mstarzinger): Implement this! |
// Create a catch scope that binds the exception. |
- register_allocator()->PrepareForConsecutiveAllocations(3); |
- Register name = register_allocator()->NextConsecutiveRegister(); |
- Register exception = register_allocator()->NextConsecutiveRegister(); |
- Register closure = register_allocator()->NextConsecutiveRegister(); |
- builder() |
- ->StoreAccumulatorInRegister(exception) |
- .LoadLiteral(stmt->variable()->name()) |
- .StoreAccumulatorInRegister(name); |
- VisitFunctionClosureForContext(); |
- builder()->StoreAccumulatorInRegister(closure).CallRuntime( |
- Runtime::kPushCatchContext, name, 3); |
+ VisitNewLocalCatchContext(stmt->variable()); |
+ ContextScope scope(this, stmt->scope()); |
// Evaluate the catch-block. |
Visit(stmt->catch_block()); |
@@ -2123,6 +2114,27 @@ void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) { |
} |
+void BytecodeGenerator::VisitNewLocalCatchContext(Variable* variable) { |
+ AccumulatorResultScope accumulator_execution_result(this); |
+ DCHECK(variable->IsContextSlot()); |
+ |
+ // Allocate a new local block context. |
+ register_allocator()->PrepareForConsecutiveAllocations(3); |
+ Register name = register_allocator()->NextConsecutiveRegister(); |
+ Register exception = register_allocator()->NextConsecutiveRegister(); |
+ Register closure = register_allocator()->NextConsecutiveRegister(); |
+ |
+ builder() |
+ ->StoreAccumulatorInRegister(exception) |
+ .LoadLiteral(variable->name()) |
+ .StoreAccumulatorInRegister(name); |
+ VisitFunctionClosureForContext(); |
+ builder()->StoreAccumulatorInRegister(closure).CallRuntime( |
+ Runtime::kPushCatchContext, name, 3); |
+ execution_result()->SetResultInAccumulator(); |
+} |
+ |
+ |
void BytecodeGenerator::VisitObjectLiteralAccessor( |
Register home_object, ObjectLiteralProperty* property, Register value_out) { |
// TODO(rmcilroy): Replace value_out with VisitForRegister(); |