diff --git a/.gitignore b/.gitignore index 685e9a2f9d..e5687e730e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,10 @@ *.suo *.user *.xcodeproj +*.idb +*.pdb +#*# +*~ d8 d8_g shell diff --git a/SConstruct b/SConstruct index b5aa7abadb..2b2ce1d0f1 100755 --- a/SConstruct +++ b/SConstruct @@ -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'], diff --git a/src/execution.cc b/src/execution.cc index 50bbafc59a..229b8df970 100644 --- a/src/execution.cc +++ b/src/execution.cc @@ -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(&limit) - kLimitSize; + uintptr_t limit = reinterpret_cast(&limit) - kLimitSize; + ASSERT(reinterpret_cast(&limit) > kLimitSize); initial_jslimit_ = SimulatorStack::JsLimitFromCLimit(limit); jslimit_ = SimulatorStack::JsLimitFromCLimit(limit); initial_climit_ = limit; diff --git a/src/execution.h b/src/execution.h index 55307f71fd..ac00aa46fd 100644 --- a/src/execution.h +++ b/src/execution.h @@ -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); diff --git a/src/platform-win32.cc b/src/platform-win32.cc index d4a183d948..26e5ce5246 100644 --- a/src/platform-win32.cc +++ b/src/platform-win32.cc @@ -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; diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 2a35014aa8..1d1874c4f9 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -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(static_cast(i::Smi::kMaxValue) + 1); CHECK(value > i::Smi::kMaxValue); CHECK(!i::Smi::IsValid(value)); Local value_obj = v8::Integer::New(value); diff --git a/test/cctest/test-assembler-x64.cc b/test/cctest/test-assembler-x64.cc index cd750c5dfa..81aa973db4 100644 --- a/test/cctest/test-assembler-x64.cc +++ b/test/cctest/test-assembler-x64.cc @@ -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);