Title: [250200] trunk
Revision
250200
Author
[email protected]
Date
2019-09-22 02:57:48 -0700 (Sun, 22 Sep 2019)

Log Message

[JSC] Int52Rep(DoubleRepAnyIntUse) should not call operation function
https://bugs.webkit.org/show_bug.cgi?id=202072

Reviewed by Mark Lam.

JSTests:

* stress/int52rep-with-double-checks-int52-range.js: Added.
(shouldBe):
(test):

Source/_javascript_Core:

Inline doubleToStrictInt52 in FTL since it is very simple function.
This change improves JetStream2/stanford-crypto-sha256 by ~5%.

* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::doubleToStrictInt52):
* ftl/FTLOutput.cpp:
(JSC::FTL::Output::doubleToInt64):
* ftl/FTLOutput.h:

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (250199 => 250200)


--- trunk/JSTests/ChangeLog	2019-09-22 09:08:28 UTC (rev 250199)
+++ trunk/JSTests/ChangeLog	2019-09-22 09:57:48 UTC (rev 250200)
@@ -1,3 +1,14 @@
+2019-09-22  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Int52Rep(DoubleRepAnyIntUse) should not call operation function
+        https://bugs.webkit.org/show_bug.cgi?id=202072
+
+        Reviewed by Mark Lam.
+
+        * stress/int52rep-with-double-checks-int52-range.js: Added.
+        (shouldBe):
+        (test):
+
 2019-09-21  Caio Lima  <[email protected]>
 
         stress/test-out-of-memory.js is not throwing OOM into ARMv7 and MIPS

Added: trunk/JSTests/stress/int52rep-with-double-checks-int52-range-simple.js (0 => 250200)


--- trunk/JSTests/stress/int52rep-with-double-checks-int52-range-simple.js	                        (rev 0)
+++ trunk/JSTests/stress/int52rep-with-double-checks-int52-range-simple.js	2019-09-22 09:57:48 UTC (rev 250200)
@@ -0,0 +1,35 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+var doubleArray = [3, 1, 2, 3, 4, 5.5];
+doubleArray[0] = 3; // Break CoW.
+
+function test(array)
+{
+    return fiatInt52(array[0]);
+}
+noInline(test);
+
+for (var i = 0; i < 1e7; ++i)
+    shouldBe(test(doubleArray), 3);
+doubleArray[0] = 0x7ffffffffffff;
+shouldBe(test(doubleArray), 0x7ffffffffffff);
+doubleArray[0] = 0x8000000000000;
+shouldBe(test(doubleArray), 0x8000000000000);
+doubleArray[0] = -0x8000000000000;
+shouldBe(test(doubleArray), -0x8000000000000);
+doubleArray[0] = -0x8000000000001;
+shouldBe(test(doubleArray), -0x8000000000001);
+doubleArray[0] = 1.3;
+shouldBe(test(doubleArray), 1.3);
+doubleArray[0] = Number.NaN;
+shouldBe(Number.isNaN(test(doubleArray)), true);
+doubleArray[0] = Number.POSITIVE_INFINITY;
+shouldBe(test(doubleArray), Number.POSITIVE_INFINITY);
+doubleArray[0] = Number.NEGATIVE_INFINITY;
+shouldBe(test(doubleArray), Number.NEGATIVE_INFINITY);
+
+doubleArray[0] = 3;
+shouldBe(test(doubleArray), 3);

Added: trunk/JSTests/stress/int52rep-with-double-checks-int52-range.js (0 => 250200)


--- trunk/JSTests/stress/int52rep-with-double-checks-int52-range.js	                        (rev 0)
+++ trunk/JSTests/stress/int52rep-with-double-checks-int52-range.js	2019-09-22 09:57:48 UTC (rev 250200)
@@ -0,0 +1,35 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+var doubleArray = [3, 1, 2, 3, 4, 5.5];
+doubleArray[0] = 3; // Break CoW.
+
+function test(array)
+{
+    return fiatInt52(array[0]) + 0xffffffff;
+}
+noInline(test);
+
+for (var i = 0; i < 1e6; ++i)
+    shouldBe(test(doubleArray), 0xffffffff + 3);
+doubleArray[0] = 0x7ffffffffffff;
+shouldBe(test(doubleArray), 0x80000fffffffe);
+doubleArray[0] = 0x8000000000000;
+shouldBe(test(doubleArray), 0x80000ffffffff);
+doubleArray[0] = -0x8000000000000;
+shouldBe(test(doubleArray), -0x7ffff00000001);
+doubleArray[0] = -0x8000000000001;
+shouldBe(test(doubleArray), -0x7ffff00000002);
+doubleArray[0] = 1.3;
+shouldBe(test(doubleArray), 4294967296.3);
+doubleArray[0] = Number.NaN;
+shouldBe(Number.isNaN(test(doubleArray)), true);
+doubleArray[0] = Number.POSITIVE_INFINITY;
+shouldBe(test(doubleArray), Number.POSITIVE_INFINITY);
+doubleArray[0] = Number.NEGATIVE_INFINITY;
+shouldBe(test(doubleArray), Number.NEGATIVE_INFINITY);
+
+doubleArray[0] = 3;
+shouldBe(test(doubleArray), 0xffffffff + 3);

Modified: trunk/Source/_javascript_Core/ChangeLog (250199 => 250200)


--- trunk/Source/_javascript_Core/ChangeLog	2019-09-22 09:08:28 UTC (rev 250199)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-09-22 09:57:48 UTC (rev 250200)
@@ -1,5 +1,21 @@
 2019-09-22  Yusuke Suzuki  <[email protected]>
 
+        [JSC] Int52Rep(DoubleRepAnyIntUse) should not call operation function
+        https://bugs.webkit.org/show_bug.cgi?id=202072
+
+        Reviewed by Mark Lam.
+
+        Inline doubleToStrictInt52 in FTL since it is very simple function.
+        This change improves JetStream2/stanford-crypto-sha256 by ~5%.
+
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::doubleToStrictInt52):
+        * ftl/FTLOutput.cpp:
+        (JSC::FTL::Output::doubleToInt64):
+        * ftl/FTLOutput.h:
+
+2019-09-22  Yusuke Suzuki  <[email protected]>
+
         Unreviewed, follow-up change after r250198
         https://bugs.webkit.org/show_bug.cgi?id=201633
 

Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (250199 => 250200)


--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2019-09-22 09:08:28 UTC (rev 250199)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2019-09-22 09:57:48 UTC (rev 250200)
@@ -15885,16 +15885,33 @@
             
         return m_out.phi(Int64, intToInt52, doubleToInt52);
     }
-    
+
     LValue doubleToStrictInt52(Edge edge, LValue value)
     {
-        LValue possibleResult = m_out.call(
-            Int64, m_out.operation(operationConvertDoubleToInt52), value);
-        FTL_TYPE_CHECK_WITH_EXIT_KIND(Int52Overflow,
-            doubleValue(value), edge, SpecAnyIntAsDouble,
-            m_out.equal(possibleResult, m_out.constInt64(JSValue::notInt52)));
-        
-        return possibleResult;
+        LValue integerValue = m_out.doubleToInt64(value);
+        LValue integerValueConvertedToDouble = m_out.intToDouble(integerValue);
+        LValue valueNotConvertibleToInteger = m_out.doubleNotEqualOrUnordered(value, integerValueConvertedToDouble);
+        speculate(Int52Overflow, doubleValue(value), edge.node(), valueNotConvertibleToInteger);
+
+        LBasicBlock valueIsZero = m_out.newBlock();
+        LBasicBlock valueIsNotZero = m_out.newBlock();
+        LBasicBlock continuation = m_out.newBlock();
+        m_out.branch(m_out.isZero64(integerValue), unsure(valueIsZero), unsure(valueIsNotZero));
+
+        LBasicBlock lastNext = m_out.appendTo(valueIsZero, valueIsNotZero);
+        LValue doubleBitcastToInt64 = m_out.bitCast(value, Int64);
+        LValue signBitSet = m_out.lessThan(doubleBitcastToInt64, m_out.constInt64(0));
+        speculate(Int52Overflow, doubleValue(value), edge.node(), signBitSet);
+        m_out.jump(continuation);
+
+        m_out.appendTo(valueIsNotZero, continuation);
+        speculate(Int52Overflow, doubleValue(value), edge.node(), m_out.greaterThanOrEqual(integerValue, m_out.constInt64(static_cast<int64_t>(1) << (JSValue::numberOfInt52Bits - 1))));
+        speculate(Int52Overflow, doubleValue(value), edge.node(), m_out.lessThan(integerValue, m_out.constInt64(-(static_cast<int64_t>(1) << (JSValue::numberOfInt52Bits - 1)))));
+        m_out.jump(continuation);
+
+        m_out.appendTo(continuation, lastNext);
+        m_interpreter.filter(edge, SpecAnyIntAsDouble);
+        return integerValue;
     }
 
     LValue convertDoubleToInt32(LValue value, bool shouldCheckNegativeZero)

Modified: trunk/Source/_javascript_Core/ftl/FTLOutput.cpp (250199 => 250200)


--- trunk/Source/_javascript_Core/ftl/FTLOutput.cpp	2019-09-22 09:08:28 UTC (rev 250199)
+++ trunk/Source/_javascript_Core/ftl/FTLOutput.cpp	2019-09-22 09:57:48 UTC (rev 250200)
@@ -333,6 +333,18 @@
     return result;
 }
 
+LValue Output::doubleToInt64(LValue value)
+{
+    PatchpointValue* result = patchpoint(Int64);
+    result->append(value, ValueRep::SomeRegister);
+    result->setGenerator(
+        [] (CCallHelpers& jit, const StackmapGenerationParams& params) {
+            jit.truncateDoubleToInt64(params[1].fpr(), params[0].gpr());
+        });
+    result->effects = Effects::none();
+    return result;
+}
+
 LValue Output::doubleToUInt(LValue value)
 {
     PatchpointValue* result = patchpoint(Int32);

Modified: trunk/Source/_javascript_Core/ftl/FTLOutput.h (250199 => 250200)


--- trunk/Source/_javascript_Core/ftl/FTLOutput.h	2019-09-22 09:08:28 UTC (rev 250199)
+++ trunk/Source/_javascript_Core/ftl/FTLOutput.h	2019-09-22 09:57:48 UTC (rev 250200)
@@ -188,6 +188,7 @@
     LValue doubleLog(LValue);
 
     LValue doubleToInt(LValue);
+    LValue doubleToInt64(LValue);
     LValue doubleToUInt(LValue);
 
     LValue signExt32To64(LValue);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to