Chromium Code Reviews| Index: runtime/vm/stub_code_x64.cc |
| =================================================================== |
| --- runtime/vm/stub_code_x64.cc (revision 3058) |
| +++ runtime/vm/stub_code_x64.cc (working copy) |
| @@ -115,6 +115,61 @@ |
| // Input parameters: |
|
Ivan Posva
2012/01/09 17:26:42
Same concerns as in the ia32 code.
regis
2012/01/10 00:09:16
Done.
|
| // 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 leaf function to call. |
| +// R10 : number of arguments to the call. |
| +// Must preserve callee saved registers R12 and R13. |
| +static void GenerateCallLeafStub(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(); |
| + const intptr_t retval_offset = NativeArguments::retval_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 and call runtime. |
| + __ movq(Address(RSP, isolate_offset), Immediate(0)); // Set null isolate. |
| + __ 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. |
| + __ addq(RAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. |
| + __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. |
| + __ call(RBX); |
| + |
| + __ LeaveFrame(); |
| + __ ret(); |
| +} |
| + |
| + |
| +// Print the stop message. |
| +static void PrintStopMessage(NativeArguments arguments) { |
| + ASSERT(arguments.Count() == 1); |
| + const char* message = reinterpret_cast<const char*>(arguments.At(0)); |
| + OS::Print("Stop message: %s\n", message); |
| +} |
| + |
| + |
| +// Input parameters: |
| +// RSP : points to return address. |
| +// RSP + 8 : stop message (const char*). |
| +void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { |
| + __ movq(RBX, Immediate(reinterpret_cast<uword>(&PrintStopMessage))); |
| + __ movq(R10, Immediate(1)); // One argument. |
| + GenerateCallLeafStub(assembler); |
| +} |
| + |
| + |
| +// Input parameters: |
| +// RSP : points to return address. |
| // RSP + 8 : address of return value. |
| // RAX : address of first argument in argument array. |
| // RAX - 8*R10 + 8 : address of last argument in argument array. |
| @@ -1033,11 +1088,11 @@ |
| // Called for inline allocation of closures. |
| // Input parameters: |
| // If the signature class is not parameterized, the receiver, if any, will be |
| -// at RSP + 4 instead of RSP + 8, since no type arguments are passed. |
| -// RSP + 8 (or RSP + 4): receiver (only if implicit instance closure). |
| -// RSP + 4 : type arguments object (only if signature class is parameterized). |
| +// at RSP + 8 instead of RSP + 16, since no type arguments are passed. |
|
Ivan Posva
2012/01/09 17:26:42
Thanks!
regis
2012/01/10 00:09:16
Welcome.
|
| +// RSP + 16 (or RSP + 8): receiver (only if implicit instance closure). |
| +// RSP + 8 : type arguments object (only if signature class is parameterized). |
| // RSP : points to return address. |
| -// Uses RAX, RBX, RCX, RDX as temporary registers. |
| +// Uses RAX, RCX as temporary registers. |
| void StubCode::GenerateAllocationStubForClosure(Assembler* assembler, |
| const Function& func) { |
| const Immediate raw_null = |