Bug 710055 - Merge SetVMFrameRegs into PushActiveVMFrame. r=bhackett
authorSteve Fink <sfink@mozilla.com>
Mon, 21 Nov 2011 16:17:49 -0800
changeset 84755 136c73b6457cc8a917d0fdaff58b22582850248b
parent 84754 23936f5667810507e18f0429abba3fa8075bcc3b
child 84756 5884234f1b3028694c31899e95c8528d0f7a96f3
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs710055
milestone12.0a1
Bug 710055 - Merge SetVMFrameRegs into PushActiveVMFrame. r=bhackett
js/src/methodjit/MethodJIT.cpp
js/src/methodjit/TrampolineMasmX64.asm
js/src/methodjit/TrampolineMingwX64.s
js/src/methodjit/TrampolineSUNWX64.s
js/src/methodjit/TrampolineSUNWX86.s
js/src/methodjit/TrampolineSparc.s
--- a/js/src/methodjit/MethodJIT.cpp
+++ b/js/src/methodjit/MethodJIT.cpp
@@ -135,37 +135,33 @@ StackFrame::methodjitStaticAsserts()
  *    stub call ABI.
  */
 
 #ifdef JS_METHODJIT_PROFILE_STUBS
 static const size_t STUB_CALLS_FOR_OP_COUNT = 255;
 static uint32_t StubCallsForOp[STUB_CALLS_FOR_OP_COUNT];
 #endif
 
+// Called from JaegerTrampoline only
 extern "C" void JS_FASTCALL
 PushActiveVMFrame(VMFrame &f)
 {
+    f.oldregs = &f.cx->stack.regs();
+    f.cx->stack.repointRegs(&f.regs);
     f.entryfp->script()->compartment()->jaegerCompartment()->pushActiveFrame(&f);
     f.entryfp->setNativeReturnAddress(JS_FUNC_TO_DATA_PTR(void*, JaegerTrampolineReturn));
     f.regs.clearInlined();
 }
 
+// Called from JaegerTrampolineReturn, JaegerThrowpoline, JaegerInterpoline
 extern "C" void JS_FASTCALL
 PopActiveVMFrame(VMFrame &f)
 {
     f.entryfp->script()->compartment()->jaegerCompartment()->popActiveFrame();
-}
-
-extern "C" void JS_FASTCALL
-SetVMFrameRegs(VMFrame &f)
-{
-    f.oldregs = &f.cx->stack.regs();
-
-    /* Restored on exit from EnterMethodJIT. */
-    f.cx->stack.repointRegs(&f.regs);
+    f.cx->stack.repointRegs(f.oldregs);
 }
 
 #if defined(__APPLE__) || (defined(XP_WIN) && !defined(JS_CPU_X64)) || defined(XP_OS2)
 # define SYMBOL_STRING(name) "_" #name
 #else
 # define SYMBOL_STRING(name) #name
 #endif
 
@@ -323,18 +319,16 @@ SYMBOL_STRING(JaegerTrampoline) ":"     
     "subq  $0x28, %rsp"                  "\n"
 
     /* This is actually part of the VMFrame. */
     "pushq %r8"                          "\n"
 
     /* Set cx->regs and set the active frame. Save rdx and align frame in one. */
     "pushq %rdx"                         "\n"
     "movq  %rsp, %rdi"                   "\n"
-    "call " SYMBOL_STRING_VMFRAME(SetVMFrameRegs) "\n"
-    "movq  %rsp, %rdi"                   "\n"
     "call " SYMBOL_STRING_VMFRAME(PushActiveVMFrame) "\n"
 
     /* Jump into the JIT'd code. */
     "jmp *0(%rsp)"                      "\n"
     CFI(".cfi_endproc"                  "\n")
 );
 
 asm (
@@ -509,18 +503,16 @@ SYMBOL_STRING(JaegerTrampoline) ":"     
     "pushl %ebx"                         "\n"   /* entryfp */
     "pushl 20(%ebp)"                     "\n"   /* stackLimit */
     "pushl 8(%ebp)"                      "\n"   /* cx */
     "pushl %ebx"                         "\n"   /* fp */
     "subl $0x1C, %esp"                   "\n"
 
     /* Jump into the JIT'd code. */
     "movl  %esp, %ecx"                   "\n"
-    "call " SYMBOL_STRING_VMFRAME(SetVMFrameRegs) "\n"
-    "movl  %esp, %ecx"                   "\n"
     "call " SYMBOL_STRING_VMFRAME(PushActiveVMFrame) "\n"
 
     "movl 28(%esp), %ebp"                "\n"   /* load fp for JIT code */
     "jmp *88(%esp)"                      "\n"
     CFI(".cfi_endproc"                   "\n")
 );
 
 asm (
@@ -726,18 +718,16 @@ SYMBOL_STRING(JaegerTrampoline) ":"     
 "   sub     sp, sp, #(4*7)"                     "\n"
 
     /* Preserve 'code' (r2) in an arbitrary callee-saved register. */
 "   mov     r4, r2"                             "\n"
     /* Preserve 'fp' (r1) in r10 (JSFrameReg). */
 "   mov     r10, r1"                            "\n"
 
 "   mov     r0, sp"                             "\n"
-"   blx  " SYMBOL_STRING_VMFRAME(SetVMFrameRegs)   "\n"
-"   mov     r0, sp"                             "\n"
 "   blx  " SYMBOL_STRING_VMFRAME(PushActiveVMFrame)"\n"
 
     /* Call the compiled JavaScript function. */
 "   bx     r4"                                  "\n"
 );
 
 asm (
 ".text\n"
@@ -872,18 +862,16 @@ extern "C" {
             push ebx;
             push [ebp + 20];
             push [ebp + 8];
             push ebx;
             sub  esp, 0x1C;
 
             /* Jump into into the JIT'd code. */
             mov  ecx, esp;
-            call SetVMFrameRegs;
-            mov  ecx, esp;
             call PushActiveVMFrame;
 
             mov ebp, [esp + 28];  /* load fp for JIT code */
             jmp dword ptr [esp + 88];
         }
     }
 
     __declspec(naked) void JaegerTrampolineReturn()
@@ -1050,33 +1038,29 @@ mjit::EnterMethodJIT(JSContext *cx, Stac
     JSScript *script = fp->script();
 
     JaegerSpew(JSpew_Prof, "%s jaeger script, line %d\n",
                script->filename, script->lineno);
     prof.start();
 #endif
 
     JS_ASSERT(cx->fp() == fp);
-    FrameRegs &oldRegs = cx->regs();
 
     JSBool ok;
     {
         AssertCompartmentUnchanged pcc(cx);
         JSAutoResolveFlags rf(cx, RESOLVE_INFER);
         ok = JaegerTrampoline(cx, fp, code, stackLimit);
     }
 
 #ifdef JS_METHODJIT_SPEW
     prof.stop();
     JaegerSpew(JSpew_Prof, "script run took %d ms\n", prof.time_ms());
 #endif
 
-    /* Undo repointRegs in SetVMFrameRegs. */
-    cx->stack.repointRegs(&oldRegs);
-
     JaegerStatus status = cx->compartment->jaegerCompartment()->lastUnfinished();
     if (status) {
         if (partial) {
             /*
              * Being called from the interpreter, which will resume execution
              * where the JIT left off.
              */
             return status;
--- a/js/src/methodjit/TrampolineMasmX64.asm
+++ b/js/src/methodjit/TrampolineMasmX64.asm
@@ -32,17 +32,16 @@
 ; and other provisions required by the GPL or the LGPL. If you do not delete
 ; 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 *****
 
 
 extern js_InternalThrow:PROC
-extern SetVMFrameRegs:PROC
 extern PushActiveVMFrame:PROC
 extern PopActiveVMFrame:PROC
 extern js_InternalInterpret:PROC
 
 .CODE
 
 ; JSBool JaegerTrampoline(JSContext *cx, StackFrame *fp, void *code,
 ;                         Value *stackLimit, void *safePoint);
@@ -90,18 +89,16 @@ JaegerTrampoline PROC FRAME
     ; This is actually part of the VMFrame.
     mov     r10, [rbp+8*5+8]
     push    r10
 
     ; Set cx->regs and set the active frame. Save r8 and align frame in one
     push    r8
     mov     rcx, rsp
     sub     rsp, 20h
-    call    SetVMFrameRegs
-    lea     rcx, [rsp+20h]
     call    PushActiveVMFrame
     add     rsp, 20h
 
     ; Jump into the JIT code.
     jmp     qword ptr [rsp]
 JaegerTrampoline ENDP
 
 ; void JaegerTrampolineReturn();
--- a/js/src/methodjit/TrampolineMingwX64.s
+++ b/js/src/methodjit/TrampolineMingwX64.s
@@ -32,17 +32,16 @@
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # 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 *****
 
 
 .extern js_InternalThrow
-.extern SetVMFrameRegs
 .extern PushActiveVMFrame
 .extern PopActiveVMFrame
 .extern js_InternalInterpret
 
 .text
 .intel_syntax noprefix
 
 # JSBool JaegerTrampoline(JSContext *cx, StackFrame *fp, void *code,
@@ -96,18 +95,16 @@ JaegerTrampoline:
     # This is actually part of the VMFrame.
     mov     r10, [rbp+8*5+8]
     push    r10
 
     # Set cx->regs and set the active frame. Save r8 and align frame in one
     push    r8
     mov     rcx, rsp
     sub     rsp, 0x20
-    call    SetVMFrameRegs
-    lea     rcx, [rsp+0x20]
     call    PushActiveVMFrame
     add     rsp, 0x20
 
     # Jump into the JIT code.
     jmp     qword ptr [rsp]
 
 # void JaegerTrampolineReturn()#
 .globl JaegerTrampolineReturn
--- a/js/src/methodjit/TrampolineSUNWX64.s
+++ b/js/src/methodjit/TrampolineSUNWX64.s
@@ -74,18 +74,16 @@ JaegerTrampoline:
     subq  $0x28, %rsp
 
     /* This is actually part of the VMFrame. */
     pushq %r8
 
     /* Set cx->regs and set the active frame. Save rdx and align frame in one. */
     pushq %rdx
     movq  %rsp, %rdi
-    call SetVMFrameRegs
-    movq  %rsp, %rdi
     call PushActiveVMFrame
 
     /* Jump into into the JIT'd code. */
     jmp *0(%rsp)
 .size   JaegerTrampoline, . - JaegerTrampoline
 
 / void JaegerTrampolineReturn()
 .global JaegerTrampolineReturn
--- a/js/src/methodjit/TrampolineSUNWX86.s
+++ b/js/src/methodjit/TrampolineSUNWX86.s
@@ -61,17 +61,16 @@ JaegerTrampoline:
     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                       /* load fp for JIT code */
     jmp  *88(%esp)
 .size   JaegerTrampoline, . - JaegerTrampoline
 
 / void JaegerTrampolineReturn()
--- a/js/src/methodjit/TrampolineSparc.s
+++ b/js/src/methodjit/TrampolineSparc.s
@@ -46,18 +46,16 @@
 JaegerTrampoline:
     save    %sp,-168,%sp
     st      %i1, [%fp - 36]        ! fp
     st      %i0, [%fp - 32]        ! cx
     st      %i3, [%fp - 28]        ! stackLimit
     st      %i1, [%fp - 24]        ! entryFp
     st      %i1, [%fp - 20]        ! entryncode
     st      %g0, [%fp - 16]        ! stubRejoin
-    call    SetVMFrameRegs
-    mov     %sp, %o0
     call    PushActiveVMFrame
     mov     %sp, %o0
     ld      [%fp - 36], %l0         ! fp
     jmp     %i2
     st      %i7, [%fp - 12]         ! return address
 .size   JaegerTrampoline, . - JaegerTrampoline
 
 ! void JaegerTrampolineReturn()