Bug 673854 - (TypeInference)Fix TI for Solaris x86. r=bhackett.
authorGinn Chen <ginn.chen@oracle.com>
Thu, 28 Jul 2011 09:24:56 +0800
changeset 76078 c7a7d9ff99da33f98d56bff5b673df3d97116de3
parent 76077 058032661e2f2a7755e7b63fc7bbab0231992540
child 76079 235a8bfe2665082640941e8247c119c8cde3fed6
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersbhackett
bugs673854
milestone8.0a1
Bug 673854 - (TypeInference)Fix TI for Solaris x86. r=bhackett.
js/src/jsinfer.cpp
js/src/jsval.h
js/src/methodjit/MethodJIT.h
js/src/methodjit/Retcon.cpp
js/src/methodjit/TrampolineSUNWX64.s
js/src/methodjit/TrampolineSUNWX86.s
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -66,16 +66,20 @@
 #include "jsobjinlines.h"
 #include "jsscriptinlines.h"
 #include "vm/Stack-inl.h"
 
 #ifdef JS_HAS_XML_SUPPORT
 #include "jsxml.h"
 #endif
 
+#ifdef __SUNPRO_CC
+#include <alloca.h>
+#endif
+
 using namespace js;
 using namespace js::types;
 using namespace js::analyze;
 
 static inline jsid
 id_prototype(JSContext *cx) {
     return ATOM_TO_JSID(cx->runtime->atomState.classPrototypeAtom);
 }
--- a/js/src/jsval.h
+++ b/js/src/jsval.h
@@ -173,16 +173,17 @@ typedef uint8 JSValueType;
 #define JSVAL_TYPE_DOUBLE            ((uint8)0x00)
 #define JSVAL_TYPE_INT32             ((uint8)0x01)
 #define JSVAL_TYPE_UNDEFINED         ((uint8)0x02)
 #define JSVAL_TYPE_BOOLEAN           ((uint8)0x03)
 #define JSVAL_TYPE_MAGIC             ((uint8)0x04)
 #define JSVAL_TYPE_STRING            ((uint8)0x05)
 #define JSVAL_TYPE_NULL              ((uint8)0x06)
 #define JSVAL_TYPE_OBJECT            ((uint8)0x07)
+#define JSVAL_TYPE_UNKNOWN           ((uint8)0x20)
 #define JSVAL_TYPE_NONFUNOBJ         ((uint8)0x57)
 #define JSVAL_TYPE_FUNOBJ            ((uint8)0x67)
 #define JSVAL_TYPE_STRORNULL         ((uint8)0x97)
 #define JSVAL_TYPE_OBJORNULL         ((uint8)0x98)
 #define JSVAL_TYPE_BOXED             ((uint8)0x99)
 #define JSVAL_TYPE_UNINITIALIZED     ((uint8)0xcd)
 
 #if JS_BITS_PER_WORD == 32
--- a/js/src/methodjit/MethodJIT.h
+++ b/js/src/methodjit/MethodJIT.h
@@ -793,14 +793,14 @@ extern "C" void JaegerInterpoline();
 extern "C" void JaegerInterpolineScripted();
 
 #if defined(_MSC_VER) || defined(_WIN64)
 extern "C" void *JaegerThrowpoline(js::VMFrame *vmFrame);
 #else
 extern "C" void JaegerThrowpoline();
 #endif
 
-#if defined(_WIN64)
+#if (defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)) || defined(_WIN64)
 extern "C" void JaegerInterpolinePatched();
 #endif
 
 #endif /* jsjaeger_h__ */
 
--- a/js/src/methodjit/Retcon.cpp
+++ b/js/src/methodjit/Retcon.cpp
@@ -159,17 +159,17 @@ Recompiler::patchNative(JSCompartment *c
 
     if (!pool) {
         /* Already stole this stub. */
         return;
     }
 
     /* Patch the native fallthrough to go to the interpoline. */
     {
-#ifdef _WIN64
+#if (defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)) || defined(_WIN64)
         /* Win64 needs stack adjustment */
         void *interpoline = JS_FUNC_TO_DATA_PTR(void *, JaegerInterpolinePatched);
 #else
         void *interpoline = JS_FUNC_TO_DATA_PTR(void *, JaegerInterpoline);
 #endif
         uint8 *start = (uint8 *)ic.nativeJump.executableAddress();
         JSC::RepatchBuffer repatch(JSC::JITCode(start - 32, 64));
 #ifdef JS_CPU_X64
@@ -249,17 +249,17 @@ Recompiler::expandInlineFrameChain(Stack
  * into JIT code.
  */
 static inline bool
 JITCodeReturnAddress(void *data)
 {
     return data != NULL  /* frame is interpreted */
         && data != JS_FUNC_TO_DATA_PTR(void *, JaegerTrampolineReturn)
         && data != JS_FUNC_TO_DATA_PTR(void *, JaegerInterpoline)
-#ifdef _WIN64
+#if (defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)) || defined(_WIN64)
         && data != JS_FUNC_TO_DATA_PTR(void *, JaegerInterpolinePatched)
 #endif
         && data != JS_FUNC_TO_DATA_PTR(void *, JaegerInterpolineScripted);
 }
 
 /*
  * Expand all inlined frames within fp per 'inlined' and update next and regs
  * to refer to the new innermost frame.
--- a/js/src/methodjit/TrampolineSUNWX64.s
+++ b/js/src/methodjit/TrampolineSUNWX64.s
@@ -33,17 +33,17 @@
 / the provisions above, a recipient may use your version of this file under
 / the terms of any one of the MPL, the GPL or the LGPL.
 /
 / ***** END LICENSE BLOCK *****
 
 .text
 
 / JSBool JaegerTrampoline(JSContext *cx, StackFrame *fp, void *code,
-/                         FrameRegs *regs, uintptr_t inlineCallCount)
+/                         Value *stackLimit)
 .global JaegerTrampoline
 .type   JaegerTrampoline, @function
 JaegerTrampoline:
     /* Prologue. */
     pushq %rbp
     movq %rsp, %rbp
     /* Save non-volatile registers. */
     pushq %r12
@@ -57,17 +57,19 @@ JaegerTrampoline:
     movq $0x00007FFFFFFFFFFF, %r14
 
     /* Build the JIT frame.
      * rdi = cx
      * rsi = fp
      * rcx = inlineCallCount
      * fp must go into rbx
      */
-    pushq %rsi        /* entryFp */
+    pushq $0x0        /* stubRejoin */
+    pushq %rsi        /* entryncode */
+    pushq %rsi        /* entryfp */
     pushq %rcx        /* inlineCallCount */
     pushq %rdi        /* cx */
     pushq %rsi        /* fp */
     movq  %rsi, %rbx
 
     /* Space for the rest of the VMFrame. */
     subq  $0x28, %rsp
 
@@ -84,22 +86,22 @@ JaegerTrampoline:
     /* Jump into into the JIT'd code. */
     jmp *0(%rsp)
 .size   JaegerTrampoline, . - JaegerTrampoline
 
 / void JaegerTrampolineReturn()
 .global JaegerTrampolineReturn
 .type   JaegerTrampolineReturn, @function
 JaegerTrampolineReturn:
-    or   %rsi, %rdi
-    movq %rcx, 0x30(%rbx)
+    or   %rdi, %rsi
+    movq %rsx, 0x30(%rbx)
     movq %rsp, %rdi
     call PopActiveVMFrame
 
-    addq $0x58, %rsp
+    addq $0x68, %rsp
     popq %rbx
     popq %r15
     popq %r14
     popq %r13
     popq %r12
     popq %rbp
     movq $1, %rax
     ret
@@ -113,19 +115,57 @@ JaegerThrowpoline:
     movq %rsp, %rdi
     call js_InternalThrow
     testq %rax, %rax
     je   throwpoline_exit
     jmp  *%rax
   throwpoline_exit:
     movq %rsp, %rdi
     call PopActiveVMFrame
-    addq $0x58, %rsp
+    addq $0x68, %rsp
     popq %rbx
     popq %r15
     popq %r14
     popq %r13
     popq %r12
     popq %rbp
     xorq %rax,%rax
     ret
 .size   JaegerThrowpoline, . - JaegerThrowpoline
 
+/ void JaegerInterpoline()
+.global JaegerInterpoline
+.type   JaegerInterpoline, @function
+JaegerInterpoline:
+    movq %rsp, %rcx
+    movq %rax, %rdx
+    call js_InternalInterpret
+    movq 0x38(%rsp), %rbx             /* Load frame */
+    movq 0x30(%rbx), %rsi             /* Load rval payload */
+    and %r14, %rsi                    /* Mask rval payload */
+    movq 0x30(%rbx), %rdi             /* Load rval type */
+    and %r13, %rdi                    /* Mask rval type */
+    movq 0x18(%rsp), %rcx             /* Load scratch -> argc */
+    testq %rax, %rax
+    je   interpoline_exit
+    jmp  *%rax
+  interpoline_exit:
+    movq %rsp, %rdi
+    call PopActiveVMFrame
+    addq $0x68, %rsp
+    popq %rbx
+    popq %r15
+    popq %r14
+    popq %r13
+    popq %r12
+    popq %rbp
+    xorq %rax,%rax
+    ret
+.size   JaegerInterpoline, . - JaegerInterpoline
+
+/ void JaegerInterpolineScripted()
+.global JaegerInterpolineScripted
+.type   JaegerInterpolineScripted, @function
+JaegerInterpolineScripted:
+    movq 0x20(%rbx), %rbx             /* load prev */
+    movq %rbx, 0x38(%rsp)
+    jmp JaegerInterpoline
+.size   JaegerInterpolineScripted, . - JaegerInterpolineScripted
--- a/js/src/methodjit/TrampolineSUNWX86.s
+++ b/js/src/methodjit/TrampolineSUNWX86.s
@@ -33,60 +33,64 @@
 / the provisions above, a recipient may use your version of this file under
 / the terms of any one of the MPL, the GPL or the LGPL.
 /
 / ***** END LICENSE BLOCK *****
 
 .text
 
 / JSBool JaegerTrampoline(JSContext *cx, StackFrame *fp, void *code,
-/                         FrameRegs *regs, uintptr_t inlineCallCount)
+/                         Value *stackLimit)
 .global JaegerTrampoline
 .type   JaegerTrampoline, @function
 JaegerTrampoline:
     /* Prologue. */
     pushl %ebp
     movl %esp, %ebp
     /* Save non-volatile registers. */
     pushl %esi
     pushl %edi
     pushl %ebx
 
     /* Build the JIT frame. Push fields in order, */
     /* then align the stack to form esp == VMFrame. */
-    movl  12(%ebp), %ebx                       /* fp */
-    pushl %ebx                                 /* entryFp */
+    movl  12(%ebp), %ebx                       /* load fp */
+    pushl %ebx                                 /* unused1 */
+    pushl %ebx                                 /* unused0 */
+    pushl $0x0                                 /* stubRejoin */
+    pushl %ebx                                 /* entryncode */
+    pushl %ebx                                 /* entryfp */
     pushl 20(%ebp)                             /* stackLimit */
     pushl 8(%ebp)                              /* cx */
     pushl %ebx                                 /* fp */
     subl $0x1C, %esp
 
     /* Jump into the JIT'd code. */
     /* No fastcall for sunstudio. */
     pushl %esp
     call SetVMFrameRegs
     call PushActiveVMFrame
     popl  %edx
 
-    movl 28(%esp), %ebp
-    jmp  *72(%esp)
+    movl 28(%esp), %ebp                       /* load fp for JIT code */
+    jmp  *88(%esp)
 .size   JaegerTrampoline, . - JaegerTrampoline
 
 / void JaegerTrampolineReturn()
 .global JaegerTrampolineReturn
 .type   JaegerTrampolineReturn, @function
 JaegerTrampolineReturn:
     movl  %esi, 0x18(%ebp)
     movl  %edi, 0x1C(%ebp)
     movl  %esp, %ebp
-    addl  $0x38, %ebp
+    addl  $0x48, %ebp
     pushl %esp
     call PopActiveVMFrame
 
-    addl $0x30, %esp
+    addl $0x40, %esp
     popl %ebx
     popl %edi
     popl %esi
     popl %ebp
     movl $1, %eax
     ret
 .size   JaegerTrampolineReturn, . - JaegerTrampolineReturn
 
@@ -109,18 +113,67 @@ JaegerThrowpoline:
     /* and another to balance the alignment above. */
     addl $0x10, %esp
     testl %eax, %eax
     je   throwpoline_exit
     jmp  *%eax
 throwpoline_exit:
     pushl %esp
     call PopActiveVMFrame
-    popl %ebx
-    addl $0x2C, %esp
+    addl $0x40, %esp
     popl %ebx
     popl %edi
     popl %esi
     popl %ebp
     xorl %eax, %eax
     ret
 .size   JaegerThrowpoline, . - JaegerThrowpoline
 
+/ void JaegerInterpoline()
+.global JaegerInterpoline
+.type   JaegerInterpoline, @function
+JaegerInterpoline:
+    /* For Sun Studio there is no fast call. */
+    /* We add the stack by 16 before. */
+    addl $0x10, %esp
+    /* Align the stack to 16 bytes. */
+    pushl %esp
+    pushl %eax
+    pushl %edi
+    pushl %esi
+    call js_InternalInterpret
+    addl $0x10, %esp
+    movl 0x1C(%esp), %ebp    /* Load frame */
+    movl 0x18(%ebp), %esi    /* Load rval payload */
+    movl 0x1C(%ebp), %edi    /* Load rval type */
+    movl 0xC(%esp), %ecx     /* Load scratch -> argc, for any scripted call */
+    testl %eax, %eax
+    je   interpoline_exit
+    jmp  *%eax
+interpoline_exit:
+    pushl %esp
+    call PopActiveVMFrame
+    addl $0x40, %esp
+    popl %ebx
+    popl %edi
+    popl %esi
+    popl %ebp
+    xorl %eax, %eax
+    ret
+.size   JaegerInterpoline, . - JaegerInterpoline
+
+/ void JaegerInterpolineScripted()
+.global JaegerInterpolineScripted
+.type   JaegerInterpolineScripted, @function
+JaegerInterpolineScripted:
+    movl 0x10(%ebp), %ebp
+    movl %ebp, 0x1C(%esp)
+    subl $0x10, %esp
+    jmp JaegerInterpoline
+.size   JaegerInterpolineScripted, . - JaegerInterpolineScripted
+
+/ void JaegerInterpolinePatched()
+.global JaegerInterpolinePatched
+.type   JaegerInterpolinePatched, @function
+JaegerInterpolinePatched:
+    subl $0x10, %esp
+    jmp JaegerInterpoline
+.size   JaegerInterpolinePatched, . - JaegerInterpolinePatched