Bug 818138 - On x64 optimize push with small pointer immediates. r=jandem
authorTom Schuster <evilpies@gmail.com>
Thu, 06 Dec 2012 16:33:35 +0100
changeset 124313 d148382e074c496e1762b5d1f18b542bd3519680
parent 124312 78c7f99089ea1e3c8d7ee347f75e4ca9b4c2c422
child 124314 987a92aa6fca9941caee5a5deb7fcd099d98012f
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs818138
milestone20.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 818138 - On x64 optimize push with small pointer immediates. r=jandem
js/src/ion/IonMacroAssembler.h
js/src/ion/x64/Assembler-x64.h
--- a/js/src/ion/IonMacroAssembler.h
+++ b/js/src/ion/IonMacroAssembler.h
@@ -487,17 +487,17 @@ class MacroAssembler : public MacroAssem
   public:
     void enterExitFrame(const VMFunction *f = NULL) {
         linkExitFrame();
         // Push the ioncode. (Bailout or VM wrapper)
         exitCodePatch_ = PushWithPatch(ImmWord(-1));
         // Push VMFunction pointer, to mark arguments.
         Push(ImmWord(f));
     }
-    void enterFakeExitFrame(void *codeVal = NULL) {
+    void enterFakeExitFrame(IonCode *codeVal = NULL) {
         linkExitFrame();
         Push(ImmWord(uintptr_t(codeVal)));
         Push(ImmWord(uintptr_t(NULL)));
     }
 
     void leaveExitFrame() {
         freeStack(IonExitFooterFrame::Size());
     }
--- a/js/src/ion/x64/Assembler-x64.h
+++ b/js/src/ion/x64/Assembler-x64.h
@@ -284,18 +284,24 @@ class Assembler : public AssemblerX86Sha
 
     // Actual assembly emitting functions.
 
     void push(const ImmGCPtr ptr) {
         movq(ptr, ScratchReg);
         push(ScratchReg);
     }
     void push(const ImmWord ptr) {
-        movq(ptr, ScratchReg);
-        push(ScratchReg);
+        // We often end up with ImmWords that actually fit into int32.
+        // Be aware of the sign extension behavior.
+        if (ptr.value <= INT32_MAX) {
+            push(Imm32(ptr.value));
+        } else {
+            movq(ptr, ScratchReg);
+            push(ScratchReg);
+        }
     }
     void push(const FloatRegister &src) {
         subq(Imm32(sizeof(void*)), StackPointer);
         movsd(src, Operand(StackPointer, 0));
     }
     CodeOffsetLabel pushWithPatch(const ImmWord &word) {
         movq(word, ScratchReg);
         CodeOffsetLabel label = masm.currentOffset();