From 970874ad627f07491528a2e4407e26a78e009947 Mon Sep 17 00:00:00 2001 From: "whesse@chromium.org" Date: Tue, 1 Sep 2009 10:40:00 +0000 Subject: [PATCH] X64: Obey WIN64 ABI more exactly, in WIN64 build. Review URL: http://codereview.chromium.org/182027 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2791 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/codegen-x64.cc | 8 ++++---- src/x64/macro-assembler-x64.cc | 17 +++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index 3f33122d83..ea6b90a3f2 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -6953,11 +6953,11 @@ void CEntryStub::GenerateCore(MacroAssembler* masm, // Call C function. #ifdef _WIN64 // Windows 64-bit ABI passes arguments in rcx, rdx, r8, r9 - // Store Arguments object on stack - __ movq(Operand(rsp, 1 * kPointerSize), r14); // argc. - __ movq(Operand(rsp, 2 * kPointerSize), r15); // argv. + // Store Arguments object on stack, below the 4 WIN64 ABI parameter slots. + __ movq(Operand(rsp, 4 * kPointerSize), r14); // argc. + __ movq(Operand(rsp, 5 * kPointerSize), r15); // argv. // Pass a pointer to the Arguments object as the first argument. - __ lea(rcx, Operand(rsp, 1 * kPointerSize)); + __ lea(rcx, Operand(rsp, 4 * kPointerSize)); #else // ! defined(_WIN64) // GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9. __ movq(rdi, r14); // argc. diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index b29fd033cc..5fd48da75c 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -1010,12 +1010,6 @@ void MacroAssembler::EnterExitFrame(StackFrame::Type type) { } #endif - // Reserve space for the Arguments object. The Windows 64-bit ABI - // requires us to pass this structure as a pointer to its location on - // the stack. We also need backing space for the pointer, even though - // it is passed in a register. - subq(rsp, Immediate(3 * kPointerSize)); - // Get the required frame alignment for the OS. static const int kFrameAlignment = OS::ActivationFrameAlignment(); if (kFrameAlignment > 0) { @@ -1024,6 +1018,17 @@ void MacroAssembler::EnterExitFrame(StackFrame::Type type) { and_(rsp, kScratchRegister); } +#ifdef _WIN64 + // Reserve space for the Arguments object. The Windows 64-bit ABI + // requires us to pass this structure as a pointer to its location on + // the stack. The structure contains 2 pointers. + // The structure on the stack must be 16-byte aligned. + // We also need backing space for 4 parameters, even though + // we only pass one parameter, and it is in a register. + subq(rsp, Immediate(6 * kPointerSize)); + ASSERT(kFrameAlignment == 2 * kPointerSize); // Change the padding if needed. +#endif + // Patch the saved entry sp. movq(Operand(rbp, ExitFrameConstants::kSPOffset), rsp); }