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

Unified Diff: vm/stub_code_ia32.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_ia32.cc
===================================================================
--- vm/stub_code_ia32.cc (revision 8520)
+++ vm/stub_code_ia32.cc (working copy)
@@ -88,6 +88,49 @@
}
+// Input parameters:
+// ESP : points to return address.
+// ESP + 4 : address of last argument in argument array.
+// ESP + 4*EDX : address of first argument in argument array.
+// ESP + 4*EDX + 4 : address of return value.
+// ECX : address of the runtime function to call.
+// EDX : number of arguments to the call.
+// Must preserve callee saved registers EDI and EBX.
+void StubCode::GenerateCallToLeafRuntimeStub(Assembler* assembler) {
+ 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(ESP, Immediate(-sizeof(NativeArguments)));
+ if (OS::ActivationFrameAlignment() > 0) {
+ __ andl(ESP, 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 EAX.
+ __ movl(EAX, FieldAddress(CTX, Context::isolate_offset()));
+ __ movl(Address(ESP, isolate_offset), EAX); // Set isolate in NativeArgs.
+ __ movl(Address(ESP, argc_offset), EDX); // Set argc in NativeArguments.
+ __ leal(EAX, Address(EBP, EDX, TIMES_4, 1 * kWordSize)); // Compute argv.
+ __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments.
+
+ // Make call to leaf runtime entry.
+ __ call(ECX);
+
+ // Set return value in caller's frame.
+ __ movl(ECX, Address(ESP, argv_offset));
+ __ addl(ECX, Immediate(1 * kWordSize)); // Retval is next to 1st argument.
+ __ movl(Address(ECX, 0), EAX);
+
+ __ LeaveFrame();
+ __ ret();
+}
+
+
// Print the stop message.
static void PrintStopMessage(const char* message) {
OS::Print("Stop message: %s\n", message);
« vm/runtime_entry_test.cc ('K') | « vm/stub_code.h ('k') | vm/stub_code_ia32_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698