[X86_64] Smaller code for store64(imm, address) when imm fits in 32 bits.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Mar 2014 07:53:11 +0000 (07:53 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Mar 2014 07:53:11 +0000 (07:53 +0000)
<https://webkit.org/b/130002>

Generate this:

    mov [address], imm32

Instead of this:

    mov scratchRegister, imm32
    mov [address], scratchRegister

For store64(imm, address) where the 64-bit immediate can be passed as
a sign-extended 32-bit value.

Reviewed by Benjamin Poulain.

* assembler/MacroAssemblerX86_64.h:
(CAN_SIGN_EXTEND_32_64):
(JSC::MacroAssemblerX86_64::store64):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165366 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h

index af7ed73c4d6b4ec5cc2639b240dacdd2020cab31..f723b4f9401d8cf406473b0ceba30344cdba020f 100644 (file)
@@ -1,3 +1,26 @@
+2014-03-10  Andreas Kling  <akling@apple.com>
+
+        [X86_64] Smaller code for store64(imm, address) when imm fits in 32 bits.
+        <https://webkit.org/b/130002>
+
+        Generate this:
+
+            mov [address], imm32
+
+        Instead of this:
+
+            mov scratchRegister, imm32
+            mov [address], scratchRegister
+
+        For store64(imm, address) where the 64-bit immediate can be passed as
+        a sign-extended 32-bit value.
+
+        Reviewed by Benjamin Poulain.
+
+        * assembler/MacroAssemblerX86_64.h:
+        (CAN_SIGN_EXTEND_32_64):
+        (JSC::MacroAssemblerX86_64::store64):
+
 2014-03-10  Andreas Kling  <akling@apple.com>
 
         [X86_64] Smaller code for xchg_rr when one register is accumulator.
index 7284f34e9c6af5006177da8eedefd15cf5454c66..e70e2576a917388dbc58f68f3a37dc3012986c74 100644 (file)
@@ -36,6 +36,8 @@
 
 #define REPTACH_OFFSET_CALL_R11 3
 
+inline bool CAN_SIGN_EXTEND_32_64(int64_t value) { return value == (int64_t)(int32_t)value; }
+
 namespace JSC {
 
 class MacroAssemblerX86_64 : public MacroAssemblerX86Common {
@@ -412,8 +414,12 @@ public:
 
     void store64(TrustedImm64 imm, ImplicitAddress address)
     {
-        move(imm, scratchRegister);
-        store64(scratchRegister, address);
+        if (CAN_SIGN_EXTEND_32_64(imm.m_value))
+            m_assembler.movq_i32m(static_cast<int>(imm.m_value), address.offset, address.base);
+        else {
+            move(imm, scratchRegister);
+            store64(scratchRegister, address);
+        }
     }
 
     void store64(TrustedImm64 imm, BaseIndex address)