Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(781)

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 1605633003: [interpreter] First implementation of stack unwinding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_int-5
Patch Set: Rebase and skip one more test. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/isolate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 596f718ead8d5c13bca9d23a8d6cee130f1ea79b..5f640854f751764938498f4fe2b33a00fc4c9543 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -917,20 +917,10 @@ 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());
// Evaluate the catch-block.
- Visit(stmt->catch_block());
+ VisitInScope(stmt->catch_block(), stmt->scope());
try_control_builder.EndCatch();
}
@@ -2128,6 +2118,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();
@@ -2232,6 +2243,13 @@ Register BytecodeGenerator::VisitForRegisterValue(Expression* expr) {
}
+void BytecodeGenerator::VisitInScope(Statement* stmt, Scope* scope) {
+ ContextScope context_scope(this, scope);
+ DCHECK(scope->declarations()->is_empty());
+ Visit(stmt);
+}
+
+
Register BytecodeGenerator::NextContextRegister() const {
if (execution_context() == nullptr) {
// Return the incoming function context for the outermost execution context.
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698