Bug 609222 - JM: Fix call mechanism and recompilation. r=dvander. Patch to make Sun Studio on X86 work (typedef int32).
authorLeon Sha <leon.sha@oracle.com>
Tue, 30 Nov 2010 11:19:17 +0800
changeset 58684 3ba055c38b39d9bd3a5eda6adbd2fda737bbd703
parent 58683 e0318d0c228221cf42ef7b3cbf9f4dac7daf0ec8
child 58685 aaf7a1efa84832a0fd14dd9811772bc452cf1833
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersdvander
bugs609222
milestone2.0b8pre
Bug 609222 - JM: Fix call mechanism and recompilation. r=dvander. Patch to make Sun Studio on X86 work (typedef int32).
js/src/jsotypes.h
js/src/methodjit/MethodJIT.h
js/src/methodjit/TrampolineCompiler.cpp
js/src/methodjit/TrampolineSUNWX86.s
--- a/js/src/jsotypes.h
+++ b/js/src/jsotypes.h
@@ -86,16 +86,24 @@ typedef JSIntn intn;
 /*
  * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h, a very
  * common header file) defines the types int8, int16, int32, and int64.
  * So we don't define these four types here to avoid conflicts in case
  * the code also includes sys/types.h.
  */
 #if defined(AIX) && defined(HAVE_SYS_INTTYPES_H)
 #include <sys/inttypes.h>
+#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+typedef JSInt64 int64;
+
+/* Explicit signed keyword for bitfield types is required. */
+/* Some compilers may treat them as unsigned without it. */
+typedef signed int int32;
+typedef signed short int16;
+typedef signed char int8;
 #else
 typedef JSInt64 int64;
 
 /* /usr/include/model.h on HP-UX defines int8, int16, and int32 */
 typedef JSInt32 int32;
 typedef JSInt16 int16;
 typedef JSInt8 int8;
 #endif /* AIX && HAVE_SYS_INTTYPES_H */
--- a/js/src/methodjit/MethodJIT.h
+++ b/js/src/methodjit/MethodJIT.h
@@ -82,17 +82,17 @@ struct VMFrame
     void *savedEBX;
     void *savedEDI;
     void *savedESI;
     void *savedEBP;
     void *savedEIP;
 
 # ifdef JS_NO_FASTCALL
     inline void** returnAddressLocation() {
-        return reinterpret_cast<void**>(this) - 3;
+        return reinterpret_cast<void**>(this) - 5;
     }
 # else
     inline void** returnAddressLocation() {
         return reinterpret_cast<void**>(this) - 1;
     }
 # endif
 #elif defined(JS_CPU_X64)
     void *savedRBX;
--- a/js/src/methodjit/TrampolineCompiler.cpp
+++ b/js/src/methodjit/TrampolineCompiler.cpp
@@ -141,17 +141,17 @@ TrampolineCompiler::generateForceReturn(
 bool
 TrampolineCompiler::generateForceReturnFast(Assembler &masm)
 {
 #ifdef _WIN64
     masm.addPtr(Imm32(32), Registers::StackPointer);
 #else
     // In case of no fast call, when we change the return address,
     // we need to make sure add esp by 8.
-    masm.addPtr(Imm32(8), Registers::StackPointer);
+    masm.addPtr(Imm32(16), Registers::StackPointer);
 #endif
     return generateForceReturn(masm);
 }
 #endif
 
 } /* namespace mjit */
 } /* namespace js */
 
--- a/js/src/methodjit/TrampolineSUNWX86.s
+++ b/js/src/methodjit/TrampolineSUNWX86.s
@@ -1,9 +1,9 @@
-/ -*- Mode: C++/ tab-width: 4/ indent-tabs-mode: nil/ c-basic-offset: 4 -*-
+/ -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 / ***** BEGIN LICENSE BLOCK *****
 / Version: MPL 1.1/GPL 2.0/LGPL 2.1
 /
 / The contents of this file are subject to the Mozilla Public License Version
 / 1.1 (the "License")/ you may not use this file except in compliance with
 / the License. You may obtain a copy of the License at
 / http://www.mozilla.org/MPL/
 /
@@ -87,18 +87,18 @@ JaegerTrampolineReturn:
 .size   JaegerTrampolineReturn, . - JaegerTrampolineReturn
 
 
 / void *JaegerThrowpoline(js::VMFrame *vmFrame)
 .global JaegerThrowpoline
 .type   JaegerThrowpoline, @function
 JaegerThrowpoline:
     /* For Sun Studio there is no fast call. */
-    /* We add the stack by 8 before. */
-    addl $0x8, %esp
+    /* We add the stack by 16 before. */
+    addl $0x10, %esp
     /* Align the stack to 16 bytes. */
     pushl %esp 
     pushl (%esp)
     pushl (%esp)
     pushl (%esp)
     call js_InternalThrow
     /* Bump the stack by 0x2c, as in the basic trampoline, but */
     /* also one more word to clean up the stack for jsl_InternalThrow,*/
@@ -122,14 +122,14 @@ throwpoline_exit:
 
 .global InjectJaegerReturn
 .type   InjectJaegerReturn, @function
 InjectJaegerReturn:
     movl 0x18(%ebx), %edx                        /* fp->rval_ data */
     movl 0x1C(%ebx), %ecx                        /* fp->rval_ type */
     movl 0x14(%ebx), %eax                        /* fp->ncode_ */
     /* For Sun Studio there is no fast call. */
-    /* We add the stack by 8 before. */
-    addl $0x8, %esp
+    /* We add the stack by 16 before. */
+    addl $0x10, %esp
     /* Restore frame regs. */
     movl 0x1C(%esp), %ebx                        /* f.fp */
     jmp *%eax
 .size   InjectJaegerReturn, . - InjectJaegerReturn