Title: [240731] trunk/Source/_javascript_Core
Revision
240731
Author
[email protected]
Date
2019-01-30 14:42:11 -0800 (Wed, 30 Jan 2019)

Log Message

mul32 should convert powers of 2 to an lshift
https://bugs.webkit.org/show_bug.cgi?id=193957

Reviewed by Yusuke Suzuki.

* assembler/MacroAssembler.h:
(JSC::MacroAssembler::mul32):
* assembler/testmasm.cpp:
(JSC::int32Operands):
(JSC::testMul32WithImmediates):
(JSC::run):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (240730 => 240731)


--- trunk/Source/_javascript_Core/ChangeLog	2019-01-30 22:12:52 UTC (rev 240730)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-01-30 22:42:11 UTC (rev 240731)
@@ -1,3 +1,17 @@
+2019-01-30  Keith Miller  <[email protected]>
+
+        mul32 should convert powers of 2 to an lshift
+        https://bugs.webkit.org/show_bug.cgi?id=193957
+
+        Reviewed by Yusuke Suzuki.
+
+        * assembler/MacroAssembler.h:
+        (JSC::MacroAssembler::mul32):
+        * assembler/testmasm.cpp:
+        (JSC::int32Operands):
+        (JSC::testMul32WithImmediates):
+        (JSC::run):
+
 2019-01-30  Yusuke Suzuki  <[email protected]>
 
         [JSC] Make disassembler data structures constant read-only data

Modified: trunk/Source/_javascript_Core/assembler/MacroAssembler.h (240730 => 240731)


--- trunk/Source/_javascript_Core/assembler/MacroAssembler.h	2019-01-30 22:12:52 UTC (rev 240730)
+++ trunk/Source/_javascript_Core/assembler/MacroAssembler.h	2019-01-30 22:42:11 UTC (rev 240731)
@@ -1904,6 +1904,15 @@
         urshift32(src, trustedImm32ForShift(amount), dest);
     }
 
+    void mul32(TrustedImm32 imm, RegisterID src, RegisterID dest)
+    {
+        if (hasOneBitSet(imm.m_value)) {
+            lshift32(src, TrustedImm32(getLSBSet(imm.m_value)), dest);
+            return;
+        }
+        MacroAssemblerBase::mul32(imm, src, dest);
+    }
+
     // If the result jump is taken that means the assert passed.
     void jitAssert(const WTF::ScopedLambda<Jump(void)>&);
 

Modified: trunk/Source/_javascript_Core/assembler/testmasm.cpp (240730 => 240731)


--- trunk/Source/_javascript_Core/assembler/testmasm.cpp	2019-01-30 22:12:52 UTC (rev 240730)
+++ trunk/Source/_javascript_Core/assembler/testmasm.cpp	2019-01-30 22:42:11 UTC (rev 240731)
@@ -264,6 +264,21 @@
     };
 }
 
+static Vector<int32_t> int32Operands()
+{
+    return Vector<int32_t> {
+        0,
+        1,
+        -1,
+        2,
+        -2,
+        42,
+        -42,
+        64,
+        std::numeric_limits<int32_t>::max(),
+        std::numeric_limits<int32_t>::min(),
+    };
+}
 
 void testCompareDouble(MacroAssembler::DoubleCondition condition)
 {
@@ -306,6 +321,23 @@
     }
 }
 
+void testMul32WithImmediates()
+{
+    for (auto immediate : int32Operands()) {
+        auto mul = compile([=] (CCallHelpers& jit) {
+            jit.emitFunctionPrologue();
+
+            jit.mul32(CCallHelpers::TrustedImm32(immediate), GPRInfo::argumentGPR0, GPRInfo::returnValueGPR);
+
+            jit.emitFunctionEpilogue();
+            jit.ret();
+        });
+
+        for (auto value : int32Operands())
+            CHECK_EQ(invoke<int>(mul, value), immediate * value);
+    }
+}
+
 #if CPU(X86) || CPU(X86_64) || CPU(ARM64)
 void testCompareFloat(MacroAssembler::DoubleCondition condition)
 {
@@ -956,6 +988,7 @@
     RUN(testCompareDouble(MacroAssembler::DoubleGreaterThanOrEqualOrUnordered));
     RUN(testCompareDouble(MacroAssembler::DoubleLessThanOrUnordered));
     RUN(testCompareDouble(MacroAssembler::DoubleLessThanOrEqualOrUnordered));
+    RUN(testMul32WithImmediates());
 
 #if CPU(X86) || CPU(X86_64) || CPU(ARM64)
     RUN(testCompareFloat(MacroAssembler::DoubleEqual));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to