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

Unified Diff: src/x64/fast-codegen-x64.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/x64/fast-codegen-x64.cc
diff --git a/src/x64/fast-codegen-x64.cc b/src/x64/fast-codegen-x64.cc
index 69a2ff3af66cd18823ca3a43748dae976fece66f..7e3d2fb74b39638d7858ef12feb0a0a311f598eb 100644
--- a/src/x64/fast-codegen-x64.cc
+++ b/src/x64/fast-codegen-x64.cc
@@ -1638,6 +1638,41 @@ void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
Register FastCodeGenerator::result_register() { return rax; }
+// ----------------------------------------------------------------------------
+// Non-local control flow support.
+
+
+void FastCodeGenerator::EnterFinallyBlock() {
+ // Cook return address on top of stack (smi encoded Code* delta)
+ __ movq(rdx, Operand(rsp, 0));
+ __ Move(rcx, masm_->CodeObject());
+ __ subq(rdx, rcx);
+ __ Integer32ToSmi(rdx, rdx);
+ __ movq(Operand(rsp, 0), rdx);
+ // Store result register while executing finally block.
+ __ push(rax);
+}
+
+
+void FastCodeGenerator::ReturnFromFinallyBlock() {
+ // Restore result register from stack.
+ __ pop(rax);
+ // Uncook return address.
+ __ movq(rdx, Operand(rsp, 0));
+ __ SmiToInteger32(rdx, rdx);
+ __ Move(rcx, masm_->CodeObject());
+ __ addq(rdx, rcx);
+ __ movq(Operand(rsp, 0), rdx);
+ // And return.
+ __ ret(0);
+}
+
+
+void FastCodeGenerator::ThrowException() {
+ __ push(rax);
+ __ CallRuntime(Runtime::kThrow, 1);
+}
+
#undef __

Powered by Google App Engine
This is Rietveld 408576698