Commit 046b4020 authored by whesse@chromium.org's avatar whesse@chromium.org

X64: Small changes to let WIN64 platform compile.

Review URL: http://codereview.chromium.org/174394

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2755 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3fdbc084
......@@ -756,7 +756,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// an internal frame and the pushed function and receiver, and
// register rax and rbx holds the argument count and argument array,
// while rdi holds the function pointer and rsi the context.
#ifdef __MSVC__
#ifdef _WIN64
// MSVC parameters in:
// rcx : entry (ignored)
// rdx : function
......@@ -766,7 +766,6 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// Clear the context before we push it when entering the JS frame.
__ xor_(rsi, rsi);
// Enter an internal frame.
__ EnterInternalFrame();
// Load the function context into rsi.
......@@ -783,7 +782,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
__ movq(rbx, Operand(kScratchRegister, EntryFrameConstants::kArgvOffset));
// Load the function pointer into rdi.
__ movq(rdi, rdx);
#else // !defined(__MSVC__)
#else // !defined(_WIN64)
// GCC parameters in:
// rdi : entry (ignored)
// rsi : function
......@@ -807,7 +806,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// Load the number of arguments and setup pointer to the arguments.
__ movq(rax, rcx);
__ movq(rbx, r8);
#endif // __MSVC__
#endif // _WIN64
// Current stack contents:
// [rsp + 2 * kPointerSize ... ]: Internal frame
// [rsp + kPointerSize] : function
......
......@@ -3564,7 +3564,7 @@ void CodeGenerator::GenerateFastCharCodeAt(ZoneList<Expression*>* args) {
// If the index is negative or non-smi trigger the slow case.
ASSERT(kSmiTag == 0);
__ testl(index.reg(),
Immediate(static_cast<int32_t>(kSmiTagMask | 0x80000000U)));
Immediate(static_cast<uint32_t>(kSmiTagMask | 0x80000000U)));
__ j(not_zero, &slow_case);
// Untag the index.
__ sarl(index.reg(), Immediate(kSmiTagSize));
......@@ -5354,7 +5354,7 @@ void CodeGenerator::ConstantSmiBinaryOperation(Token::Value op,
overwrite_mode);
// Check for negative or non-Smi left hand side.
__ testl(operand->reg(),
Immediate(static_cast<int32_t>(kSmiTagMask | 0x80000000)));
Immediate(static_cast<uint32_t>(kSmiTagMask | 0x80000000)));
deferred->Branch(not_zero);
if (int_value < 0) int_value = -int_value;
if (int_value == 1) {
......@@ -5894,7 +5894,7 @@ void Reference::GetValue(TypeofState typeof_state) {
// Check that the key is a non-negative smi.
__ testl(key.reg(),
Immediate(static_cast<int32_t>(kSmiTagMask | 0x80000000u)));
Immediate(static_cast<uint32_t>(kSmiTagMask | 0x80000000u)));
deferred->Branch(not_zero);
// Get the elements array from the receiver and check that it
......@@ -6763,10 +6763,10 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
if (do_gc) {
// Pass failure code returned from last attempt as first argument to GC.
#ifdef __MSVC__
__ movq(rcx, rax); // argc.
#else // ! defined(__MSVC__)
__ movq(rdi, rax); // argv.
#ifdef _WIN64
__ movq(rcx, rax);
#else // ! defined(_WIN64)
__ movq(rdi, rax);
#endif
__ movq(kScratchRegister,
FUNCTION_ADDR(Runtime::PerformGC),
......@@ -6782,11 +6782,14 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
}
// Call C function.
#ifdef __MSVC__
// MSVC passes arguments in rcx, rdx, r8, r9
__ movq(rcx, r14); // argc.
__ movq(rdx, r15); // argv.
#else // ! defined(__MSVC__)
#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.
// Pass a pointer to the Arguments object as the first argument.
__ lea(rcx, Operand(rsp, 1 * kPointerSize));
#else // ! defined(_WIN64)
// GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9.
__ movq(rdi, r14); // argc.
__ movq(rsi, r15); // argv.
......
......@@ -60,6 +60,8 @@ class StackHandlerConstants : public AllStatic {
class EntryFrameConstants : public AllStatic {
public:
static const int kCallerFPOffset = -10 * kPointerSize;
// TODO(X64): Add unit test for kArgvOffset.
static const int kArgvOffset = 5 * kPointerSize;
};
......
......@@ -994,8 +994,11 @@ void MacroAssembler::EnterExitFrame(StackFrame::Type type) {
}
#endif
// Reserve space for two arguments: argc and argv
subq(rsp, Immediate(2 * kPointerSize));
// 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();
......
......@@ -319,7 +319,7 @@ void RegExpMacroAssemblerX64::CheckNotBackReferenceIgnoreCase(
} else {
ASSERT(mode_ == UC16);
// Save important/volatile registers before calling C function.
#ifndef __MSVC__
#ifndef _WIN64
// Callee save on Win64
__ push(rsi);
__ push(rdi);
......@@ -333,7 +333,7 @@ void RegExpMacroAssemblerX64::CheckNotBackReferenceIgnoreCase(
// Address byte_offset1 - Address captured substring's start.
// Address byte_offset2 - Address of current character position.
// size_t byte_length - length of capture in bytes(!)
#ifdef __MSVC__
#ifdef _WIN64
// Compute and set byte_offset1 (start of capture).
__ lea(rcx, Operand(rsi, rdx, times_1, 0));
// Set byte_offset2.
......@@ -356,7 +356,7 @@ void RegExpMacroAssemblerX64::CheckNotBackReferenceIgnoreCase(
// Restore original values before reacting on result value.
__ Move(code_object_pointer(), masm_->CodeObject());
__ pop(backtrack_stackpointer());
#ifndef __MSVC__
#ifndef _WIN64
__ pop(rdi);
__ pop(rsi);
#endif
......@@ -604,7 +604,7 @@ Handle<Object> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
__ movq(rbp, rsp);
// Save parameters and callee-save registers. Order here should correspond
// to order of kBackup_ebx etc.
#ifdef __MSVC__
#ifdef _WIN64
// MSVC passes arguments in rcx, rdx, r8, r9, with backing stack slots.
// Store register parameters in pre-allocated stack slots,
__ movq(Operand(rbp, kInputString), rcx);
......@@ -740,7 +740,7 @@ Handle<Object> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
// Exit and return rax
__ bind(&exit_label_);
#ifdef __MSVC__
#ifdef _WIN64
// Restore callee save registers.
__ lea(rsp, Operand(rbp, kLastCalleeSaveRegister));
__ pop(rbx);
......@@ -794,7 +794,7 @@ Handle<Object> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
Label grow_failed;
// Save registers before calling C function
#ifndef __MSVC__
#ifndef _WIN64
// Callee-save in Microsoft 64-bit ABI, but not in AMD64 ABI.
__ push(rsi);
__ push(rdi);
......@@ -803,7 +803,7 @@ Handle<Object> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
// Call GrowStack(backtrack_stackpointer())
int num_arguments = 2;
FrameAlign(num_arguments);
#ifdef __MSVC__
#ifdef _WIN64
// Microsoft passes parameters in rcx, rdx.
// First argument, backtrack stackpointer, is already in rcx.
__ lea(rdx, Operand(rbp, kStackHighEnd)); // Second argument
......@@ -821,7 +821,7 @@ Handle<Object> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
__ movq(backtrack_stackpointer(), rax);
// Restore saved registers and continue.
__ Move(code_object_pointer(), masm_->CodeObject());
#ifndef __MSVC__
#ifndef _WIN64
__ pop(rdi);
__ pop(rsi);
#endif
......@@ -980,7 +980,7 @@ void RegExpMacroAssemblerX64::CallCheckStackGuardState() {
// store anything volatile in a C call or overwritten by this function.
int num_arguments = 3;
FrameAlign(num_arguments);
#ifdef __MSVC__
#ifdef _WIN64
// Second argument: Code* of self. (Do this before overwriting r8).
__ movq(rdx, code_object_pointer());
// Third argument: RegExp code frame pointer.
......@@ -1242,10 +1242,10 @@ void RegExpMacroAssemblerX64::FrameAlign(int num_arguments) {
// (on Win64 only) and the original value of rsp.
__ movq(kScratchRegister, rsp);
ASSERT(IsPowerOf2(frameAlignment));
#ifdef __MSVC__
#ifdef _WIN64
// Allocate space for parameters and old rsp.
__ subq(rsp, Immediate((num_arguments + 1) * kPointerSize));
__ and_(rsp, -frameAlignment);
__ and_(rsp, Immediate(-frameAlignment));
__ movq(Operand(rsp, num_arguments * kPointerSize), kScratchRegister);
#else
// Allocate space for old rsp.
......@@ -1264,7 +1264,7 @@ void RegExpMacroAssemblerX64::CallCFunction(Address function_address,
__ movq(rax, reinterpret_cast<intptr_t>(function_address), RelocInfo::NONE);
__ call(rax);
ASSERT(OS::ActivationFrameAlignment() != 0);
#ifdef __MSVC__
#ifdef _WIN64
__ movq(rsp, Operand(rsp, num_arguments * kPointerSize));
#else
__ pop(rsp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment