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

Unified Diff: src/ia32/fast-codegen-ia32.cc

Issue 492002: Fast-codegen: Implementing try/finally on top of nesting context. (Closed)
Patch Set: Updated to be based on latest release. Created 11 years 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
Index: src/ia32/fast-codegen-ia32.cc
diff --git a/src/ia32/fast-codegen-ia32.cc b/src/ia32/fast-codegen-ia32.cc
index b6e16f3229b6f88536517a376671d0d1f23563fc..4e179c59c2a4b0c434382ed4f2ed6725a0dd4749 100644
--- a/src/ia32/fast-codegen-ia32.cc
+++ b/src/ia32/fast-codegen-ia32.cc
@@ -1625,14 +1625,49 @@ void FastCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
// Convert current context to test context: End post-test code.
}
-Register FastCodeGenerator::result_register() { return eax; }
void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
__ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
Move(expr->context(), eax);
}
-#undef __
+Register FastCodeGenerator::result_register() { return eax; }
+
+// ----------------------------------------------------------------------------
+// Non-local control flow support.
+
+void FastCodeGenerator::EnterFinallyBlock() {
+ // Cook return address on top of stack (smi encoded Code* delta)
+ __ mov(edx, Operand(esp, 0));
Kevin Millikin (Chromium) 2009/12/10 13:51:12 Assert result_register is not edx?
Lasse Reichstein 2009/12/16 08:43:30 Good idea. Done.
+ __ sub(Operand(edx), Immediate(masm_->CodeObject()));
+ ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize);
+ ASSERT_EQ(0, kSmiTag);
+ __ add(edx, Operand(edx)); // Convert to smi.
+ __ mov(Operand(esp, 0), edx);
+ // Store result register while executing finally block.
+ __ push(eax);
Kevin Millikin (Chromium) 2009/12/10 13:51:12 __ push(result_register())
Lasse Reichstein 2009/12/16 08:43:30 Indeed. Half an abstractions is ... useless.
+}
+
+
+void FastCodeGenerator::ReturnFromFinallyBlock() {
+ // Restore result register from stack.
+ __ pop(eax);
+ // Uncook return address.
+ __ mov(edx, Operand(esp, 0));
Kevin Millikin (Chromium) 2009/12/10 13:51:12 Is this really better than: __ pop(edx); __ sar(e
Lasse Reichstein 2009/12/16 08:43:30 The CPU has a call/return stack that expects calls
+ __ sar(edx, 1); // Convert smi to int.
+ __ add(Operand(edx), Immediate(masm_->CodeObject()));
+ __ mov(Operand(esp, 0), edx);
+ // And return.
+ __ ret(0);
+}
+
+
+void FastCodeGenerator::ThrowException() {
+ __ push(eax);
+ __ CallRuntime(Runtime::kThrow, 1);
+}
+
+#undef __
} } // namespace v8::internal
« src/fast-codegen.cc ('K') | « src/fast-codegen.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698