Fix fast API call for MinGW-w64
authorulan@chromium.org <ulan@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 16 Apr 2012 09:22:12 +0000 (09:22 +0000)
committerulan@chromium.org <ulan@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 16 Apr 2012 09:22:12 +0000 (09:22 +0000)
MinGW-w64 uses the rcx register for the first argument. Unlike MSVC, it does not require preparing a slot for the result handle on the stack and putting a pointer to it in the rcx register.

BUGS=v8:2026
TEST=cctest/test-api

Review URL: https://chromiumcodereview.appspot.com/9959050
Patch from Jonathan Liu <net147@gmail.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11325 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/x64/macro-assembler-x64.cc
src/x64/stub-cache-x64.cc

index f7db250..12e653c 100644 (file)
@@ -657,7 +657,7 @@ static int Offset(ExternalReference ref0, ExternalReference ref1) {
 
 
 void MacroAssembler::PrepareCallApiFunction(int arg_stack_space) {
-#ifdef _WIN64
+#if defined(_WIN64) && !defined(__MINGW64__)
   // We need to prepare a slot for result handle on stack and put
   // a pointer to it into 1st arg register.
   EnterApiExitFrame(arg_stack_space + 1);
@@ -705,7 +705,7 @@ void MacroAssembler::CallApiFunctionAndReturn(Address function_address,
        RelocInfo::RUNTIME_ENTRY);
   call(rax);
 
-#ifdef _WIN64
+#if defined(_WIN64) && !defined(__MINGW64__)
   // rax keeps a pointer to v8::Handle, unpack it.
   movq(rax, Operand(rax, 0));
 #endif
index 86b4aff..8edda73 100644 (file)
@@ -482,7 +482,9 @@ static void GenerateFastApiCall(MacroAssembler* masm,
   // Prepare arguments.
   __ lea(rbx, Operand(rsp, 4 * kPointerSize));
 
-#ifdef _WIN64
+#if defined(__MINGW64__)
+  Register arguments_arg = rcx;
+#elif defined(_WIN64)
   // Win64 uses first register--rcx--for returned value.
   Register arguments_arg = rdx;
 #else
@@ -1016,7 +1018,10 @@ void StubCompiler::GenerateLoadCallback(Handle<JSObject> object,
   // Save a pointer to where we pushed the arguments pointer.
   // This will be passed as the const AccessorInfo& to the C++ callback.
 
-#ifdef _WIN64
+#if defined(__MINGW64__)
+  Register accessor_info_arg = rdx;
+  Register name_arg = rcx;
+#elif defined(_WIN64)
   // Win64 uses first register--rcx--for returned value.
   Register accessor_info_arg = r8;
   Register name_arg = rdx;