Revision: 3056
Author: [email protected]
Date: Tue Oct 13 03:56:13 2009
Log: X64: Fix bugs affecting Win64.

Increase stack space on Win64 sample and cctest executables.

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

http://code.google.com/p/v8/source/detail?r=3056

Modified:
  /branches/bleeding_edge/.gitignore
  /branches/bleeding_edge/SConstruct
  /branches/bleeding_edge/src/execution.cc
  /branches/bleeding_edge/src/execution.h
  /branches/bleeding_edge/src/platform-win32.cc
  /branches/bleeding_edge/test/cctest/test-api.cc
  /branches/bleeding_edge/test/cctest/test-assembler-x64.cc

=======================================
--- /branches/bleeding_edge/.gitignore  Wed Aug  5 04:52:59 2009
+++ /branches/bleeding_edge/.gitignore  Tue Oct 13 03:56:13 2009
@@ -10,6 +10,10 @@
  *.suo
  *.user
  *.xcodeproj
+*.idb
+*.pdb
+#*#
+*~
  d8
  d8_g
  shell
=======================================
--- /branches/bleeding_edge/SConstruct  Mon Oct 12 04:19:20 2009
+++ /branches/bleeding_edge/SConstruct  Tue Oct 13 03:56:13 2009
@@ -373,7 +373,8 @@
        'CPPDEFINES': ['V8_TARGET_ARCH_IA32']
      },
      'arch:x64': {
-      'CPPDEFINES':   ['V8_TARGET_ARCH_X64']
+      'CPPDEFINES':   ['V8_TARGET_ARCH_X64'],
+      'LINKFLAGS': ['/STACK:2091752']
      },
    }
  }
@@ -474,7 +475,7 @@
      },
      'arch:x64': {
        'CPPDEFINES': ['V8_TARGET_ARCH_X64'],
-      'LINKFLAGS': ['/MACHINE:X64']
+      'LINKFLAGS': ['/MACHINE:X64', '/STACK:2091752']
      },
      'mode:debug': {
        'CCFLAGS':   ['/Od'],
=======================================
--- /branches/bleeding_edge/src/execution.cc    Thu Oct  8 05:36:12 2009
+++ /branches/bleeding_edge/src/execution.cc    Tue Oct 13 03:56:13 2009
@@ -386,7 +386,8 @@
    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;
=======================================
--- /branches/bleeding_edge/src/execution.h     Thu Oct  1 03:33:05 2009
+++ /branches/bleeding_edge/src/execution.h     Tue Oct 13 03:56:13 2009
@@ -216,6 +216,7 @@
    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);
=======================================
--- /branches/bleeding_edge/src/platform-win32.cc       Thu Aug 27 04:48:37 2009
+++ /branches/bleeding_edge/src/platform-win32.cc       Tue Oct 13 03:56:13 2009
@@ -1794,7 +1794,6 @@
          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;
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc     Thu Oct  8 06:09:28 2009
+++ /branches/bleeding_edge/test/cctest/test-api.cc     Tue Oct 13 03:56:13 2009
@@ -728,7 +728,10 @@
    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);
=======================================
--- /branches/bleeding_edge/test/cctest/test-assembler-x64.cc   Mon Jun 29  
02:32:06 2009
+++ /branches/bleeding_edge/test/cctest/test-assembler-x64.cc   Tue Oct 13  
03:56:13 2009
@@ -44,6 +44,7 @@
  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::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 @@
    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 @@
    // 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 @@
    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 @@

    // 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 @@
    // 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 @@
    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);

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to