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

Unified Diff: vm/stub_code_x64.cc

Issue 10542123: Add support for leaf runtime calls (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 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
Index: vm/stub_code_x64.cc
===================================================================
--- vm/stub_code_x64.cc (revision 8520)
+++ vm/stub_code_x64.cc (working copy)
@@ -90,6 +90,49 @@
}
+// Input parameters:
+// RSP : points to return address.
+// RSP + 8 : address of last argument in argument array.
+// RSP + 8*R10 : address of first argument in argument array.
+// RSP + 8*R10 + 8 : address of return value.
+// RBX : address of the runtime function to call.
+// R10 : number of arguments to the call.
+// Must preserve callee saved registers R12 and R13.
+void StubCode::GenerateCallToLeafRuntimeStub(Assembler* assembler) {
+ ASSERT((R12 != CTX) && (R13 != CTX));
+ const intptr_t isolate_offset = NativeArguments::isolate_offset();
+ const intptr_t argc_offset = NativeArguments::argc_offset();
+ const intptr_t argv_offset = NativeArguments::argv_offset();
+
+ __ EnterFrame(0);
+
+ // Reserve space for arguments and align frame before entering C++ world.
+ __ AddImmediate(RSP, Immediate(-sizeof(NativeArguments)));
+ if (OS::ActivationFrameAlignment() > 0) {
+ __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1)));
+ }
+
+ // Pass NativeArguments structure by value.
+ // NOTE: the retvalue area in the NativeArguments structure is not setup
+ // as leaf routines return the value in RAX.
+ __ movq(Address(RSP, isolate_offset), CTX); // Set isolate in NativeArgs.
+ __ movq(Address(RSP, argc_offset), R10); // Set argc in NativeArguments.
+ __ leaq(RAX, Address(RBP, R10, TIMES_8, 1 * kWordSize)); // Compute argv.
+ __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments.
+
+ // Make call to leaf runtime entry.
+ __ call(RBX);
+
+ // Set return value in caller's frame.
+ __ movq(RBX, Address(RSP, argv_offset));
+ __ addq(RBX, Immediate(1 * kWordSize)); // Retval is next to 1st argument.
+ __ movq(Address(RBX, 0), RAX);
+
+ __ LeaveFrame();
+ __ ret();
+}
+
+
// Print the stop message.
static void PrintStopMessage(const char* message) {
OS::Print("Stop message: %s\n", message);
« vm/stub_code_ia32.cc ('K') | « vm/stub_code_ia32_test.cc ('k') | vm/stub_code_x64_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698