Title: [154207] trunk/Source/_javascript_Core
Revision
154207
Author
[email protected]
Date
2013-08-16 16:34:21 -0700 (Fri, 16 Aug 2013)

Log Message

[JSC] x86: improve code generation for xxxTest32
https://bugs.webkit.org/show_bug.cgi?id=119876

Reviewed by Geoffrey Garen.

Try to use testb whenever possible when testing for an immediate value.

When the input is an address and an offset, we can tweak the mask
and offset to be able to generate testb for any byte of the mask.

When the input is a register, we can use testb if we are only interested
in testing the low bits.

* assembler/MacroAssemblerX86Common.h:
(JSC::MacroAssemblerX86Common::branchTest32):
(JSC::MacroAssemblerX86Common::test32):
(JSC::MacroAssemblerX86Common::generateTest32):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (154206 => 154207)


--- trunk/Source/_javascript_Core/ChangeLog	2013-08-16 21:56:36 UTC (rev 154206)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-08-16 23:34:21 UTC (rev 154207)
@@ -1,3 +1,23 @@
+2013-08-16  Benjamin Poulain  <[email protected]>
+
+        [JSC] x86: improve code generation for xxxTest32
+        https://bugs.webkit.org/show_bug.cgi?id=119876
+
+        Reviewed by Geoffrey Garen.
+
+        Try to use testb whenever possible when testing for an immediate value.
+
+        When the input is an address and an offset, we can tweak the mask
+        and offset to be able to generate testb for any byte of the mask.
+
+        When the input is a register, we can use testb if we are only interested
+        in testing the low bits.
+
+        * assembler/MacroAssemblerX86Common.h:
+        (JSC::MacroAssemblerX86Common::branchTest32):
+        (JSC::MacroAssemblerX86Common::test32):
+        (JSC::MacroAssemblerX86Common::generateTest32):
+
 2013-08-16  Mark Lam  <[email protected]>
 
         <https://bugs.webkit.org/show_bug.cgi?id=119913> Baseline JIT gives erroneous

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h (154206 => 154207)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h	2013-08-16 21:56:36 UTC (rev 154206)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h	2013-08-16 23:34:21 UTC (rev 154207)
@@ -1138,9 +1138,10 @@
 
     Jump branchTest32(ResultCondition cond, RegisterID reg, TrustedImm32 mask = TrustedImm32(-1))
     {
-        // if we are only interested in the low seven bits, this can be tested with a testb
         if (mask.m_value == -1)
             m_assembler.testl_rr(reg, reg);
+        else if (!(mask.m_value & ~0xff))
+            m_assembler.testb_i8r(mask.m_value, reg);
         else
             m_assembler.testl_i32r(mask.m_value, reg);
         return Jump(m_assembler.jCC(x86Condition(cond)));
@@ -1148,10 +1149,7 @@
 
     Jump branchTest32(ResultCondition cond, Address address, TrustedImm32 mask = TrustedImm32(-1))
     {
-        if (mask.m_value == -1)
-            m_assembler.cmpl_im(0, address.offset, address.base);
-        else
-            m_assembler.testl_i32m(mask.m_value, address.offset, address.base);
+        generateTest32(address, mask);
         return Jump(m_assembler.jCC(x86Condition(cond)));
     }
 
@@ -1419,10 +1417,7 @@
 
     void test32(ResultCondition cond, Address address, TrustedImm32 mask, RegisterID dest)
     {
-        if (mask.m_value == -1)
-            m_assembler.cmpl_im(0, address.offset, address.base);
-        else
-            m_assembler.testl_i32m(mask.m_value, address.offset, address.base);
+        generateTest32(address, mask);
         set32(x86Condition(cond), dest);
     }
 
@@ -1504,6 +1499,22 @@
     // x86_64, and clients & subclasses of MacroAssembler should be using 'supportsFloatingPoint()'.
     friend class MacroAssemblerX86;
 
+    ALWAYS_INLINE void generateTest32(Address address, TrustedImm32 mask = TrustedImm32(-1))
+    {
+        if (mask.m_value == -1)
+            m_assembler.cmpl_im(0, address.offset, address.base);
+        else if (!(mask.m_value & ~0xff))
+            m_assembler.testb_im(mask.m_value, address.offset, address.base);
+        else if (!(mask.m_value & ~0xff00))
+            m_assembler.testb_im(mask.m_value >> 8, address.offset + 1, address.base);
+        else if (!(mask.m_value & ~0xff0000))
+            m_assembler.testb_im(mask.m_value >> 16, address.offset + 2, address.base);
+        else if (!(mask.m_value & ~0xff000000))
+            m_assembler.testb_im(mask.m_value >> 24, address.offset + 3, address.base);
+        else
+            m_assembler.testl_i32m(mask.m_value, address.offset, address.base);
+    }
+
 #if CPU(X86)
 #if OS(MAC_OS_X)
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to