From 267879e92c34feb7037145e4ebe3c48ac595cb96 Mon Sep 17 00:00:00 2001 From: "ulan@chromium.org" Date: Mon, 16 Apr 2012 09:22:12 +0000 Subject: [PATCH] Fix fast API call for MinGW-w64 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 . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11325 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/macro-assembler-x64.cc | 4 ++-- src/x64/stub-cache-x64.cc | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index f7db250..12e653c 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -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 diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc index 86b4aff..8edda73 100644 --- a/src/x64/stub-cache-x64.cc +++ b/src/x64/stub-cache-x64.cc @@ -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 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; -- 2.7.4