Commit 292323b3 authored by lrn@chromium.org's avatar lrn@chromium.org

X64: Fix bugs affecting Win64.

Increase stack space on Win64 sample and cctest executables.

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


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3056 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ac731896
......@@ -10,6 +10,10 @@
*.suo
*.user
*.xcodeproj
*.idb
*.pdb
#*#
*~
d8
d8_g
shell
......
......@@ -373,7 +373,8 @@ CCTEST_EXTRA_FLAGS = {
'CPPDEFINES': ['V8_TARGET_ARCH_IA32']
},
'arch:x64': {
'CPPDEFINES': ['V8_TARGET_ARCH_X64']
'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
'LINKFLAGS': ['/STACK:2091752']
},
}
}
......@@ -474,7 +475,7 @@ SAMPLE_FLAGS = {
},
'arch:x64': {
'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
'LINKFLAGS': ['/MACHINE:X64']
'LINKFLAGS': ['/MACHINE:X64', '/STACK:2091752']
},
'mode:debug': {
'CCFLAGS': ['/Od'],
......
......@@ -386,7 +386,8 @@ void StackGuard::ThreadLocal::Initialize() {
if (initial_climit_ == kIllegalLimit) {
// Takes the address of the limit variable in order to find out where
// the top of stack is right now.
intptr_t limit = reinterpret_cast<intptr_t>(&limit) - kLimitSize;
uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - kLimitSize;
ASSERT(reinterpret_cast<uintptr_t>(&limit) > kLimitSize);
initial_jslimit_ = SimulatorStack::JsLimitFromCLimit(limit);
jslimit_ = SimulatorStack::JsLimitFromCLimit(limit);
initial_climit_ = limit;
......
......@@ -216,6 +216,7 @@ class StackGuard : public AllStatic {
static void DisableInterrupts();
static const uintptr_t kLimitSize = kPointerSize * 128 * KB;
#ifdef V8_TARGET_ARCH_X64
static const uintptr_t kInterruptLimit = V8_UINT64_C(0xfffffffffffffffe);
static const uintptr_t kIllegalLimit = V8_UINT64_C(0xfffffffffffffff8);
......
......@@ -1794,7 +1794,6 @@ class Sampler::PlatformData : public Malloced {
context.ContextFlags = CONTEXT_FULL;
if (GetThreadContext(profiled_thread_, &context) != 0) {
#if V8_HOST_ARCH_X64
UNIMPLEMENTED();
sample.pc = context.Rip;
sample.sp = context.Rsp;
sample.fp = context.Rbp;
......
......@@ -728,7 +728,10 @@ THREADED_TEST(BigInteger) {
LocalContext env;
// We cannot add one to a Smi::kMaxValue without wrapping.
if (i::kSmiValueSize < 32) {
int32_t value = i::Smi::kMaxValue + 1;
// The casts allow this to compile, even if Smi::kMaxValue is 2^31-1.
// The code will not be run in that case, due to the "if" guard.
int32_t value =
static_cast<int32_t>(static_cast<uint32_t>(i::Smi::kMaxValue) + 1);
CHECK(value > i::Smi::kMaxValue);
CHECK(!i::Smi::IsValid(value));
Local<v8::Integer> value_obj = v8::Integer::New(value);
......
......@@ -44,6 +44,7 @@ using v8::internal::Label;
using v8::internal::rax;
using v8::internal::rsi;
using v8::internal::rdi;
using v8::internal::rcx;
using v8::internal::rdx;
using v8::internal::rbp;
using v8::internal::rsp;
......@@ -53,20 +54,28 @@ using v8::internal::less_equal;
using v8::internal::not_equal;
using v8::internal::greater;
// Test the x64 assembler by compiling some simple functions into
// a buffer and executing them. These tests do not initialize the
// V8 library, create a context, or use any V8 objects.
// The AMD64 calling convention is used, with the first five arguments
// in RSI, RDI, RDX, RCX, R8, and R9, and floating point arguments in
// The AMD64 calling convention is used, with the first six arguments
// in RDI, RSI, RDX, RCX, R8, and R9, and floating point arguments in
// the XMM registers. The return value is in RAX.
// This calling convention is used on Linux, with GCC, and on Mac OS,
// with GCC. A different convention is used on 64-bit windows.
// with GCC. A different convention is used on 64-bit windows,
// where the first four integer arguments are passed in RCX, RDX, R8 and R9.
typedef int (*F0)();
typedef int (*F1)(int64_t x);
typedef int (*F2)(int64_t x, int64_t y);
#ifdef _WIN64
static const v8::internal::Register arg1 = rcx;
static const v8::internal::Register arg2 = rdx;
#else
static const v8::internal::Register arg1 = rdi;
static const v8::internal::Register arg2 = rsi;
#endif
#define __ assm.
......@@ -80,7 +89,7 @@ TEST(AssemblerX64ReturnOperation) {
Assembler assm(buffer, actual_size);
// Assemble a simple function that copies argument 2 and returns it.
__ movq(rax, rsi);
__ movq(rax, arg2);
__ nop();
__ ret(0);
......@@ -105,9 +114,9 @@ TEST(AssemblerX64StackOperations) {
// incorrect stack frames when debugging this function (which has them).
__ push(rbp);
__ movq(rbp, rsp);
__ push(rsi); // Value at (rbp - 8)
__ push(rsi); // Value at (rbp - 16)
__ push(rdi); // Value at (rbp - 24)
__ push(arg2); // Value at (rbp - 8)
__ push(arg2); // Value at (rbp - 16)
__ push(arg1); // Value at (rbp - 24)
__ pop(rax);
__ pop(rax);
__ pop(rax);
......@@ -132,8 +141,8 @@ TEST(AssemblerX64ArithmeticOperations) {
Assembler assm(buffer, actual_size);
// Assemble a simple function that adds arguments returning the sum.
__ movq(rax, rsi);
__ addq(rax, rdi);
__ movq(rax, arg2);
__ addq(rax, arg1);
__ ret(0);
CodeDesc desc;
......@@ -154,8 +163,8 @@ TEST(AssemblerX64ImulOperation) {
// Assemble a simple function that multiplies arguments returning the high
// word.
__ movq(rax, rsi);
__ imul(rdi);
__ movq(rax, arg2);
__ imul(arg1);
__ movq(rax, rdx);
__ ret(0);
......@@ -182,14 +191,16 @@ TEST(AssemblerX64MemoryOperands) {
// Assemble a simple function that copies argument 2 and returns it.
__ push(rbp);
__ movq(rbp, rsp);
__ push(rsi); // Value at (rbp - 8)
__ push(rsi); // Value at (rbp - 16)
__ push(rdi); // Value at (rbp - 24)
__ push(arg2); // Value at (rbp - 8)
__ push(arg2); // Value at (rbp - 16)
__ push(arg1); // Value at (rbp - 24)
const int kStackElementSize = 8;
__ movq(rax, Operand(rbp, -3 * kStackElementSize));
__ pop(rsi);
__ pop(rsi);
__ pop(rsi);
__ pop(arg2);
__ pop(arg2);
__ pop(arg2);
__ pop(rbp);
__ nop();
__ ret(0);
......@@ -210,13 +221,14 @@ TEST(AssemblerX64ControlFlow) {
CHECK(buffer);
Assembler assm(buffer, actual_size);
// Assemble a simple function that copies argument 2 and returns it.
// Assemble a simple function that copies argument 1 and returns it.
__ push(rbp);
__ movq(rbp, rsp);
__ movq(rax, rdi);
__ movq(rax, arg1);
Label target;
__ jmp(&target);
__ movq(rax, rsi);
__ movq(rax, arg2);
__ bind(&target);
__ pop(rbp);
__ ret(0);
......
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