Bug 868027 - Use push to push integer registers onto the stack on x64. r=nbp
authorDan Gohman <sunfish@google.com>
Fri, 03 May 2013 19:20:30 -0700
changeset 141767 a6520c0288da6adbd937cbc43fcc825ff6e50f59
parent 141766 5c124c0689926575ccfab07567cf9f621ffee3d3
child 141768 529526e6e659af53914aa26577489d661639d98d
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs868027
milestone23.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 868027 - Use push to push integer registers onto the stack on x64. r=nbp Use push instead of adjusting the stack pointer and doing stores manually. This significantly reduces code size for these sequences.
js/src/ion/x64/Trampoline-x64.cpp
--- a/js/src/ion/x64/Trampoline-x64.cpp
+++ b/js/src/ion/x64/Trampoline-x64.cpp
@@ -277,19 +277,20 @@ IonRuntime::generateInvalidator(JSContex
     AutoIonContextAlloc aica(cx);
     MacroAssembler masm(cx);
 
     // See explanatory comment in x86's IonRuntime::generateInvalidator.
 
     masm.addq(Imm32(sizeof(uintptr_t)), rsp);
 
     // Push registers such that we can access them from [base + code].
-    masm.reserveStack(Registers::Total * sizeof(void *));
-    for (uint32_t i = 0; i < Registers::Total; i++)
-        masm.movq(Register::FromCode(i), Operand(rsp, i * sizeof(void *)));
+    for (uint32_t i = Registers::Total; i > 0; ) {
+        i--;
+        masm.Push(Register::FromCode(i));
+    }
 
     // Push xmm registers, such that we can access them from [base + code].
     masm.reserveStack(FloatRegisters::Total * sizeof(double));
     for (uint32_t i = 0; i < FloatRegisters::Total; i++)
         masm.movsd(FloatRegister::FromCode(i), Operand(rsp, i * sizeof(double)));
 
     masm.movq(rsp, rax); // Argument to ion::InvalidationBailout.
 
@@ -410,19 +411,20 @@ IonRuntime::generateArgumentsRectifier(J
         *returnAddrOut = (void *) (code->raw() + returnLabel.offset());
     return code;
 }
 
 static void
 GenerateBailoutThunk(JSContext *cx, MacroAssembler &masm, uint32_t frameClass)
 {
     // Push registers such that we can access them from [base + code].
-    masm.reserveStack(Registers::Total * sizeof(void *));
-    for (uint32_t i = 0; i < Registers::Total; i++)
-        masm.movq(Register::FromCode(i), Operand(rsp, i * sizeof(void *)));
+    for (uint32_t i = Registers::Total; i > 0; ) {
+        i--;
+        masm.Push(Register::FromCode(i));
+    }
 
     // Push xmm registers, such that we can access them from [base + code].
     masm.reserveStack(FloatRegisters::Total * sizeof(double));
     for (uint32_t i = 0; i < FloatRegisters::Total; i++)
         masm.movsd(FloatRegister::FromCode(i), Operand(rsp, i * sizeof(double)));
 
     // Get the stack pointer into a register, pre-alignment.
     masm.movq(rsp, r8);