Title: [192519] trunk/Source/_javascript_Core
Revision
192519
Author
mark....@apple.com
Date
2015-11-17 11:41:27 -0800 (Tue, 17 Nov 2015)

Log Message

[JSC] Support Doubles with B3's Sub.
https://bugs.webkit.org/show_bug.cgi?id=151322

Reviewed by Filip Pizlo.

* b3/B3LowerToAir.cpp:
(JSC::B3::Air::LowerToAir::lower):
* b3/air/AirOpcode.opcodes:

* b3/testb3.cpp:
(JSC::B3::testSubImmArg32):
(JSC::B3::testSubArgDouble):
(JSC::B3::testSubArgsDouble):
(JSC::B3::testSubArgImmDouble):
(JSC::B3::testSubImmArgDouble):
(JSC::B3::testSubImmsDouble):
(JSC::B3::testBitAndArgs):
(JSC::B3::negativeZero):
(JSC::B3::posInfinity):
(JSC::B3::negInfinity):
(JSC::B3::doubleOperands):
(JSC::B3::run):
- Added RUN_UNARY and RUN_BINARY macros to auto generate permutations
  of operands for the tests.
- Added SubDouble tests using the new macros.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (192518 => 192519)


--- trunk/Source/_javascript_Core/ChangeLog	2015-11-17 19:41:26 UTC (rev 192518)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-11-17 19:41:27 UTC (rev 192519)
@@ -1,3 +1,31 @@
+2015-11-16  Mark Lam  <mark....@apple.com>
+
+        [JSC] Support Doubles with B3's Sub.
+        https://bugs.webkit.org/show_bug.cgi?id=151322
+
+        Reviewed by Filip Pizlo.
+
+        * b3/B3LowerToAir.cpp:
+        (JSC::B3::Air::LowerToAir::lower):
+        * b3/air/AirOpcode.opcodes:
+
+        * b3/testb3.cpp:
+        (JSC::B3::testSubImmArg32):
+        (JSC::B3::testSubArgDouble):
+        (JSC::B3::testSubArgsDouble):
+        (JSC::B3::testSubArgImmDouble):
+        (JSC::B3::testSubImmArgDouble):
+        (JSC::B3::testSubImmsDouble):
+        (JSC::B3::testBitAndArgs):
+        (JSC::B3::negativeZero):
+        (JSC::B3::posInfinity):
+        (JSC::B3::negInfinity):
+        (JSC::B3::doubleOperands):
+        (JSC::B3::run):
+        - Added RUN_UNARY and RUN_BINARY macros to auto generate permutations
+          of operands for the tests.
+        - Added SubDouble tests using the new macros.
+
 2015-11-17  Benjamin Poulain  <bpoul...@apple.com>
 
         [JSC] IteratedRegisterCoalescingAllocator's freeze can add zombie Tmps to our coloring algorithm

Modified: trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp (192518 => 192519)


--- trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp	2015-11-17 19:41:26 UTC (rev 192518)
+++ trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp	2015-11-17 19:41:27 UTC (rev 192519)
@@ -1255,7 +1255,7 @@
             if (m_value->child(0)->isInt(0))
                 appendUnOp<Neg32, Neg64, Air::Oops>(m_value->child(1));
             else
-                appendBinOp<Sub32, Sub64, Air::Oops>(m_value->child(0), m_value->child(1));
+                appendBinOp<Sub32, Sub64, SubDouble>(m_value->child(0), m_value->child(1));
             return;
         }
 

Modified: trunk/Source/_javascript_Core/b3/air/AirOpcode.opcodes (192518 => 192519)


--- trunk/Source/_javascript_Core/b3/air/AirOpcode.opcodes	2015-11-17 19:41:26 UTC (rev 192518)
+++ trunk/Source/_javascript_Core/b3/air/AirOpcode.opcodes	2015-11-17 19:41:27 UTC (rev 192519)
@@ -93,6 +93,10 @@
     Tmp, Tmp
     Imm, Tmp
 
+SubDouble U:F, UD:F
+    Tmp, Tmp
+    Addr, Tmp
+
 Neg32 UD:G
     Tmp
     Addr

Modified: trunk/Source/_javascript_Core/b3/testb3.cpp (192518 => 192519)


--- trunk/Source/_javascript_Core/b3/testb3.cpp	2015-11-17 19:41:26 UTC (rev 192518)
+++ trunk/Source/_javascript_Core/b3/testb3.cpp	2015-11-17 19:41:27 UTC (rev 192519)
@@ -42,8 +42,10 @@
 #include "InitializeThreading.h"
 #include "JSCInlines.h"
 #include "LinkBuffer.h"
+#include "PureNaN.h"
 #include "VM.h"
 #include <cmath>
+#include <string>
 #include <wtf/Lock.h>
 #include <wtf/NumberOfCores.h>
 #include <wtf/Threading.h>
@@ -552,6 +554,70 @@
     CHECK(compileAndRun<int>(proc, b) == a - b);
 }
 
+void testSubArgDouble(double a)
+{
+    Procedure proc;
+    BasicBlock* root = proc.addBlock();
+    Value* value = root->appendNew<ArgumentRegValue>(proc, Origin(), FPRInfo::argumentFPR0);
+    root->appendNew<ControlValue>(
+        proc, Return, Origin(),
+        root->appendNew<Value>(proc, Sub, Origin(), value, value));
+
+    CHECK(isIdentical(compileAndRun<double>(proc, a), a - a));
+}
+
+void testSubArgsDouble(double a, double b)
+{
+    Procedure proc;
+    BasicBlock* root = proc.addBlock();
+    Value* valueA = root->appendNew<ArgumentRegValue>(proc, Origin(), FPRInfo::argumentFPR0);
+    Value* valueB = root->appendNew<ArgumentRegValue>(proc, Origin(), FPRInfo::argumentFPR1);
+    root->appendNew<ControlValue>(
+        proc, Return, Origin(),
+        root->appendNew<Value>(proc, Sub, Origin(), valueA, valueB));
+
+    CHECK(isIdentical(compileAndRun<double>(proc, a, b), a - b));
+}
+
+void testSubArgImmDouble(double a, double b)
+{
+    Procedure proc;
+    BasicBlock* root = proc.addBlock();
+    Value* valueA = root->appendNew<ArgumentRegValue>(proc, Origin(), FPRInfo::argumentFPR0);
+    Value* valueB = root->appendNew<ConstDoubleValue>(proc, Origin(), b);
+    root->appendNew<ControlValue>(
+        proc, Return, Origin(),
+        root->appendNew<Value>(proc, Sub, Origin(), valueA, valueB));
+
+    CHECK(isIdentical(compileAndRun<double>(proc, a), a - b));
+}
+
+void testSubImmArgDouble(double a, double b)
+{
+    Procedure proc;
+    BasicBlock* root = proc.addBlock();
+    Value* valueA = root->appendNew<ConstDoubleValue>(proc, Origin(), a);
+    Value* valueB = root->appendNew<ArgumentRegValue>(proc, Origin(), FPRInfo::argumentFPR0);
+    root->appendNew<ControlValue>(
+        proc, Return, Origin(),
+        root->appendNew<Value>(proc, Sub, Origin(), valueA, valueB));
+
+    CHECK(isIdentical(compileAndRun<double>(proc, b), a - b));
+}
+
+void testSubImmsDouble(double a, double b)
+{
+    Procedure proc;
+    BasicBlock* root = proc.addBlock();
+    Value* valueA = root->appendNew<ConstDoubleValue>(proc, Origin(), a);
+    Value* valueB = root->appendNew<ConstDoubleValue>(proc, Origin(), b);
+    root->appendNew<ControlValue>(
+        proc, Return, Origin(),
+        root->appendNew<Value>(proc, Sub, Origin(), valueA, valueB));
+    
+    CHECK(isIdentical(compileAndRun<double>(proc), a - b));
+}
+
 void testBitAndArgs(int64_t a, int64_t b)
 {
     Procedure proc;
@@ -4167,6 +4233,39 @@
     return -zero();
 }
 
+// Some convenience functions for brevity of the test output.
+double posInfinity()
+{
+    return std::numeric_limits<double>::infinity();
+}
+
+double negInfinity()
+{
+    return -std::numeric_limits<double>::infinity();
+}
+
+
+struct DoubleOperand {
+    const char* name;
+    double value;
+};
+
+static const std::array<DoubleOperand, 9>& doubleOperands()
+{
+    static const std::array<DoubleOperand, 9> operands = {{
+        { "M_PI", M_PI },
+        { "-M_PI", -M_PI },
+        { "1", 1 },
+        { "-1", -1 },
+        { "0", 0 },
+        { "negativeZero()", negativeZero() },
+        { "posInfinity()", posInfinity() },
+        { "negInfinity()", negInfinity() },
+        { "PNaN", PNaN },
+    }};
+    return operands;
+};
+
 #define RUN(test) do {                          \
         if (!shouldRun(#test))                  \
             break;                              \
@@ -4179,6 +4278,34 @@
                 }));                            \
     } while (false);
 
+#define RUN_UNARY(test, values) \
+    for (auto a : values) {                             \
+        CString testStr = toCString(#test, "(", a.name, ")"); \
+        if (!shouldRun(testStr.data()))                 \
+            continue;                                   \
+        tasks.append(createSharedTask<void()>(          \
+            [=] () {                                    \
+                dataLog(testStr, "...\n");              \
+                test(a.value);                          \
+                dataLog(testStr, ": OK!\n");            \
+            }));                                        \
+    }
+
+#define RUN_BINARY(test, valuesA, valuesB) \
+    for (auto a : valuesA) {                                \
+        for (auto b : valuesB) {                            \
+            CString testStr = toCString(#test, "(", a.name, ", ", b.name, ")"); \
+            if (!shouldRun(testStr.data()))                 \
+                continue;                                   \
+            tasks.append(createSharedTask<void()>(          \
+                [=] () {                                    \
+                    dataLog(testStr, "...\n");              \
+                    test(a.value, b.value);                 \
+                    dataLog(testStr, ": OK!\n");            \
+                }));                                        \
+        }                                                   \
+    }
+
 void run(const char* filter)
 {
     JSC::initializeThreading();
@@ -4321,6 +4448,12 @@
     RUN(testSubImmArg32(13, -42));
     RUN(testSubImmArg32(-13, 42));
 
+    RUN_UNARY(testSubArgDouble, doubleOperands());
+    RUN_BINARY(testSubArgsDouble, doubleOperands(), doubleOperands());
+    RUN_BINARY(testSubArgImmDouble, doubleOperands(), doubleOperands());
+    RUN_BINARY(testSubImmArgDouble, doubleOperands(), doubleOperands());
+    RUN_BINARY(testSubImmsDouble, doubleOperands(), doubleOperands());
+
     RUN(testBitAndArgs(43, 43));
     RUN(testBitAndArgs(43, 0));
     RUN(testBitAndArgs(10, 3));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to