Bug 769853 - Replace extraneous call in x86 buildFakeExitFrame() with a label push. r=sstangl
authorEric Faust <efaust@mozilla.com>
Fri, 29 Jun 2012 17:27:12 -0700
changeset 106489 13304da358b6f6e9a068674cff5c85d5a07404d2
parent 106488 82120910b08f651baf042f96225a3b608daeeae7
child 106490 796016ef829d1a4e30b69bec1481a91fd784876e
push id23447
push userdanderson@mozilla.com
push dateTue, 11 Sep 2012 17:34:27 +0000
treeherdermozilla-central@fdfaef738a00 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs769853
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 769853 - Replace extraneous call in x86 buildFakeExitFrame() with a label push. r=sstangl
js/src/ion/CodeGenerator.cpp
js/src/ion/arm/MacroAssembler-arm.cpp
js/src/ion/arm/MacroAssembler-arm.h
js/src/ion/shared/Assembler-shared.h
js/src/ion/shared/CodeGenerator-x86-shared.cpp
js/src/ion/shared/MacroAssembler-x86-shared.h
--- a/js/src/ion/CodeGenerator.cpp
+++ b/js/src/ion/CodeGenerator.cpp
@@ -514,17 +514,19 @@ CodeGenerator::visitCallNative(LCallNati
     // Preload arguments into registers.
     masm.loadJSContext(argJSContextReg);
     masm.move32(Imm32(call->numStackArgs()), argUintNReg);
     masm.movePtr(StackPointer, argVpReg);
 
     masm.Push(argUintNReg);
 
     // Construct native exit frame.
-    uint32 safepointOffset = masm.buildFakeExitFrame(tempReg);
+    uint32 safepointOffset;
+    if (!masm.buildFakeExitFrame(tempReg, &safepointOffset))
+        return false;
     masm.enterFakeExitFrame();
 
     if (!markSafepointAt(safepointOffset, call))
         return false;
 
     // Construct and execute call.
     masm.setupUnalignedABICall(3, tempReg);
     masm.passABIArg(argJSContextReg);
--- a/js/src/ion/arm/MacroAssembler-arm.cpp
+++ b/js/src/ion/arm/MacroAssembler-arm.cpp
@@ -1340,18 +1340,18 @@ MacroAssemblerARM::ma_vstr(VFPRegister s
 }
 void
 MacroAssemblerARM::ma_vstr(VFPRegister src, Register base, Register index, int32 shift)
 {
     as_add(ScratchRegister, base, lsl(index, shift));
     ma_vstr(src, Operand(ScratchRegister, 0));
 }
 
-uint32
-MacroAssemblerARMCompat::buildFakeExitFrame(const Register &scratch)
+bool
+MacroAssemblerARMCompat::buildFakeExitFrame(const Register &scratch, uint32 *offset)
 {
     DebugOnly<uint32> initialDepth = framePushed();
     uint32 descriptor = MakeFrameDescriptor(framePushed(), IonFrame_JS);
 
     Push(Imm32(descriptor)); // descriptor_
 
     enterNoPool();
     DebugOnly<uint32> offsetBeforePush = currentOffset();
@@ -1361,17 +1361,19 @@ MacroAssemblerARMCompat::buildFakeExitFr
     // then be 8 bytes after the instruction for Push(pc); this offset can
     // therefore be fed to the safepoint.
     ma_nop();
     uint32 pseudoReturnOffset = currentOffset();
     leaveNoPool();
 
     JS_ASSERT(framePushed() == initialDepth + IonExitFrameLayout::Size());
     JS_ASSERT(pseudoReturnOffset - offsetBeforePush == 8);
-    return pseudoReturnOffset;
+
+    *offset = pseudoReturnOffset;
+    return true;
 }
 
 void
 MacroAssemblerARMCompat::callWithExitFrame(IonCode *target)
 {
     uint32 descriptor = MakeFrameDescriptor(framePushed(), IonFrame_JS);
     Push(Imm32(descriptor)); // descriptor
 
--- a/js/src/ion/arm/MacroAssembler-arm.h
+++ b/js/src/ion/arm/MacroAssembler-arm.h
@@ -893,17 +893,17 @@ class MacroAssemblerARMCompat : public M
         return framePushed_;
     }
     void setFramePushed(uint32 framePushed) {
         framePushed_ = framePushed;
     }
 
     // Builds an exit frame on the stack, with a return address to an internal
     // non-function. Returns offset to be passed to markSafepointAt().
-    uint32 buildFakeExitFrame(const Register &scratch);
+    bool buildFakeExitFrame(const Register &scratch, uint32 *offset);
 
     void callWithExitFrame(IonCode *target);
 
     // Makes an Ion call using the only two methods that it is sane for
     // indep code to make a call
     void callIon(const Register &callee);
 
     void reserveStack(uint32 amount);
--- a/js/src/ion/shared/Assembler-shared.h
+++ b/js/src/ion/shared/Assembler-shared.h
@@ -334,18 +334,18 @@ struct AbsoluteLabel : public LabelBase
 };
 
 // A code label contains an absolute reference to a point in the code
 // Thus, it cannot be patched until after linking
 class CodeLabel : public TempObject
 {
     // The destination position, where the absolute reference should get patched into
     AbsoluteLabel dest_;
-    
-    // The source label (relative) in the code to where the 
+
+    // The source label (relative) in the code to where the
     // the destination should get patched to.
     Label src_;
 
   public:
     CodeLabel()
     { }
     AbsoluteLabel *dest() {
         return &dest_;
--- a/js/src/ion/shared/CodeGenerator-x86-shared.cpp
+++ b/js/src/ion/shared/CodeGenerator-x86-shared.cpp
@@ -883,17 +883,17 @@ CodeGeneratorX86Shared::visitTableSwitch
     int32 cases = mir->numCases();
     masm.cmpl(ToRegister(temp), Imm32(cases));
     masm.j(AssemblerX86Shared::AboveOrEqual, defaultcase);
 
     // Create a JumpTable that during linking will get written.
     DeferredJumpTable *d = new DeferredJumpTable(ins);
     if (!masm.addDeferredData(d, (1 << ScalePointer) * cases))
         return false;
-   
+
     // Compute the position where a pointer to the right case stands.
     const LAllocation *base = ins->tempPointer();
     masm.mov(d->label(), ToRegister(base));
     Operand pointer = Operand(ToRegister(base), ToRegister(temp), ScalePointer);
 
     // Jump to the right case
     masm.jmp(pointer);
 
--- a/js/src/ion/shared/MacroAssembler-x86-shared.h
+++ b/js/src/ion/shared/MacroAssembler-x86-shared.h
@@ -369,43 +369,34 @@ class MacroAssemblerX86Shared : public A
 
     template <typename T>
     void computeEffectiveAddress(const T &address, Register dest) {
         lea(Operand(address), dest);
     }
 
     // Builds an exit frame on the stack, with a return address to an internal
     // non-function. Returns offset to be passed to markSafepointAt().
-    uint32 buildFakeExitFrame(const Register &scratch) {
+    bool buildFakeExitFrame(const Register &scratch, uint32 *offset) {
         DebugOnly<uint32> initialDepth = framePushed();
-        Label pseudocall, endcall;
-
-        call(&pseudocall);
-        uint32 callOffset = currentOffset();
-        jump(&endcall);
 
-        align(0x10);
-        {
-            bind(&pseudocall);
-#ifdef JS_CPU_X86
-            movl(Operand(StackPointer, 0x0), scratch);
-#else
-            movq(Operand(StackPointer, 0x0), scratch);
-#endif
-            ret();
-        }
-
-        bind(&endcall);
+        CodeLabel *cl = new CodeLabel();
+        if (!addCodeLabel(cl))
+            return false;
+        breakpoint();
+        mov(cl->dest(), scratch);
 
         uint32 descriptor = MakeFrameDescriptor(framePushed(), IonFrame_JS);
         Push(Imm32(descriptor));
         Push(scratch);
 
+        bind(cl->src());
+        *offset = currentOffset();
+
         JS_ASSERT(framePushed() == initialDepth + IonExitFrameLayout::Size());
-        return callOffset;
+        return true;
     }
 
     void callWithExitFrame(IonCode *target) {
         uint32 descriptor = MakeFrameDescriptor(framePushed(), IonFrame_JS);
         Push(Imm32(descriptor));
         call(target);
     }
     void callIon(const Register &callee) {