Title: [260551] trunk
Revision
260551
Author
ysuz...@apple.com
Date
2020-04-22 20:11:02 -0700 (Wed, 22 Apr 2020)

Log Message

[JSC] branchIfBigInt32 can use BigInt32Mask and remove branchIfNumber filter
https://bugs.webkit.org/show_bug.cgi?id=210870

Reviewed by Saam Barati.

JSTests:

* stress/anybigintuse-should-filter-number-correctly.js: Added.
(shouldBe):
(test):

Source/_javascript_Core:

By using BigInt32Mask, we can detect BigInt32 without filtering Numbers. In this patch,

1. Remove branchIfBigInt32KnownNotNumber and branchIfNotBigInt32KnownNotNumber. And always use branchBigInt32 and branchNotBigInt32 instead.
2. Remove branchIfNumber type filtering in DFG.
3. Use BigInt32Mask based scheme in FTL.
4. Add and64(TrustedImm64, RegisterID) implementations in MacroAssembler.
5. Add TagRegistersMode version in branchIfBigInt. We use numberTagRegister to produce really efficient code[1] by avoiding large constant materialization.

[1]: From
        mov %rax, %rdx
        mov $0xfffe000000000012, %r11
        and %r11, %rdx
        cmp $0x12, %rdx
     To
        lea 0x12(%r14), %rdx
        and %rax, %rdx
        cmp $0x12, %rdx

* assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::and64):
* assembler/MacroAssemblerX86_64.h:
(JSC::MacroAssemblerX86_64::and64):
* bytecode/ArithProfile.cpp:
(JSC::ArithProfile<BitfieldType>::emitObserveResult):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateBigInt32):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileToNumeric):
(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
(JSC::FTL::DFG::LowerDFGToB3::compileIsBigInt):
(JSC::FTL::DFG::LowerDFGToB3::boolify):
(JSC::FTL::DFG::LowerDFGToB3::buildTypeOf):
(JSC::FTL::DFG::LowerDFGToB3::lowBigInt32):
(JSC::FTL::DFG::LowerDFGToB3::isBigInt32):
(JSC::FTL::DFG::LowerDFGToB3::isNotBigInt32):
(JSC::FTL::DFG::LowerDFGToB3::isNotAnyBigInt):
(JSC::FTL::DFG::LowerDFGToB3::speculateBigInt32):
(JSC::FTL::DFG::LowerDFGToB3::speculateAnyBigInt):
(JSC::FTL::DFG::LowerDFGToB3::isBigInt32KnownNotCell): Deleted.
(JSC::FTL::DFG::LowerDFGToB3::isBigInt32KnownNotNumber): Deleted.
(JSC::FTL::DFG::LowerDFGToB3::isNotBigInt32KnownNotNumber): Deleted.
(JSC::FTL::DFG::LowerDFGToB3::isNotAnyBigIntKnownNotNumber): Deleted.
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitConvertValueToBoolean):
(JSC::AssemblyHelpers::branchIfValue):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::branchIfBigInt32):
(JSC::AssemblyHelpers::branchIfNotBigInt32):
(JSC::AssemblyHelpers::emitTypeOf):
(JSC::AssemblyHelpers::branchIfBigInt32KnownNotNumber): Deleted.
(JSC::AssemblyHelpers::branchIfNotBigInt32KnownNotNumber): Deleted.

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (260550 => 260551)


--- trunk/JSTests/ChangeLog	2020-04-23 02:18:46 UTC (rev 260550)
+++ trunk/JSTests/ChangeLog	2020-04-23 03:11:02 UTC (rev 260551)
@@ -1,3 +1,14 @@
+2020-04-22  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] branchIfBigInt32 can use BigInt32Mask and remove branchIfNumber filter
+        https://bugs.webkit.org/show_bug.cgi?id=210870
+
+        Reviewed by Saam Barati.
+
+        * stress/anybigintuse-should-filter-number-correctly.js: Added.
+        (shouldBe):
+        (test):
+
 2020-04-22  Saam Barati  <sbar...@apple.com>
 
         BigInt32 parsing should be precise

Added: trunk/JSTests/stress/anybigintuse-should-filter-number-correctly.js (0 => 260551)


--- trunk/JSTests/stress/anybigintuse-should-filter-number-correctly.js	                        (rev 0)
+++ trunk/JSTests/stress/anybigintuse-should-filter-number-correctly.js	2020-04-23 03:11:02 UTC (rev 260551)
@@ -0,0 +1,25 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+function test(a, b)
+{
+    return a === b;
+}
+noInline(test);
+
+for (var i = 0; i < 1e6; ++i) {
+    if (i & 1) {
+        test(0n, 0n);
+        test(0n, 10n);
+    } else {
+        test(100000000000000000000000000000000000000000n, 200n);
+        test(100000000000000000000000000000000000000000n, 100000000000000000000000000000000000000000n);
+    }
+}
+shouldBe(test(20, 20), true);
+shouldBe(test(20, 40), false);
+shouldBe(test(0.5, 0.5), true);
+shouldBe(test(0.5, 0.24), false);
+shouldBe(test(20.1 - 0.1, 20), true);

Modified: trunk/Source/_javascript_Core/ChangeLog (260550 => 260551)


--- trunk/Source/_javascript_Core/ChangeLog	2020-04-23 02:18:46 UTC (rev 260550)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-04-23 03:11:02 UTC (rev 260551)
@@ -1,3 +1,62 @@
+2020-04-22  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] branchIfBigInt32 can use BigInt32Mask and remove branchIfNumber filter
+        https://bugs.webkit.org/show_bug.cgi?id=210870
+
+        Reviewed by Saam Barati.
+
+        By using BigInt32Mask, we can detect BigInt32 without filtering Numbers. In this patch,
+
+        1. Remove branchIfBigInt32KnownNotNumber and branchIfNotBigInt32KnownNotNumber. And always use branchBigInt32 and branchNotBigInt32 instead.
+        2. Remove branchIfNumber type filtering in DFG.
+        3. Use BigInt32Mask based scheme in FTL.
+        4. Add and64(TrustedImm64, RegisterID) implementations in MacroAssembler.
+        5. Add TagRegistersMode version in branchIfBigInt. We use numberTagRegister to produce really efficient code[1] by avoiding large constant materialization.
+
+        [1]: From
+                mov %rax, %rdx
+                mov $0xfffe000000000012, %r11
+                and %r11, %rdx
+                cmp $0x12, %rdx
+             To
+                lea 0x12(%r14), %rdx
+                and %rax, %rdx
+                cmp $0x12, %rdx
+
+        * assembler/MacroAssemblerARM64.h:
+        (JSC::MacroAssemblerARM64::and64):
+        * assembler/MacroAssemblerX86_64.h:
+        (JSC::MacroAssemblerX86_64::and64):
+        * bytecode/ArithProfile.cpp:
+        (JSC::ArithProfile<BitfieldType>::emitObserveResult):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::fillSpeculateBigInt32):
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::compileToNumeric):
+        (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
+        (JSC::FTL::DFG::LowerDFGToB3::compileIsBigInt):
+        (JSC::FTL::DFG::LowerDFGToB3::boolify):
+        (JSC::FTL::DFG::LowerDFGToB3::buildTypeOf):
+        (JSC::FTL::DFG::LowerDFGToB3::lowBigInt32):
+        (JSC::FTL::DFG::LowerDFGToB3::isBigInt32):
+        (JSC::FTL::DFG::LowerDFGToB3::isNotBigInt32):
+        (JSC::FTL::DFG::LowerDFGToB3::isNotAnyBigInt):
+        (JSC::FTL::DFG::LowerDFGToB3::speculateBigInt32):
+        (JSC::FTL::DFG::LowerDFGToB3::speculateAnyBigInt):
+        (JSC::FTL::DFG::LowerDFGToB3::isBigInt32KnownNotCell): Deleted.
+        (JSC::FTL::DFG::LowerDFGToB3::isBigInt32KnownNotNumber): Deleted.
+        (JSC::FTL::DFG::LowerDFGToB3::isNotBigInt32KnownNotNumber): Deleted.
+        (JSC::FTL::DFG::LowerDFGToB3::isNotAnyBigIntKnownNotNumber): Deleted.
+        * jit/AssemblyHelpers.cpp:
+        (JSC::AssemblyHelpers::emitConvertValueToBoolean):
+        (JSC::AssemblyHelpers::branchIfValue):
+        * jit/AssemblyHelpers.h:
+        (JSC::AssemblyHelpers::branchIfBigInt32):
+        (JSC::AssemblyHelpers::branchIfNotBigInt32):
+        (JSC::AssemblyHelpers::emitTypeOf):
+        (JSC::AssemblyHelpers::branchIfBigInt32KnownNotNumber): Deleted.
+        (JSC::AssemblyHelpers::branchIfNotBigInt32KnownNotNumber): Deleted.
+
 2020-04-22  Saam Barati  <sbar...@apple.com>
 
         BigInt32 parsing should be precise

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h (260550 => 260551)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h	2020-04-23 02:18:46 UTC (rev 260550)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h	2020-04-23 03:11:02 UTC (rev 260551)
@@ -417,8 +417,17 @@
 
     void and64(TrustedImmPtr imm, RegisterID dest)
     {
-        LogicalImmediate logicalImm = LogicalImmediate::create64(reinterpret_cast<uint64_t>(imm.m_value));
+        intptr_t value = imm.asIntptr();
+        if constexpr (sizeof(void*) == sizeof(uint64_t))
+            and64(TrustedImm64(value), dest);
+        else
+            and64(TrustedImm32(static_cast<int32_t>(value)), dest);
+    }
 
+    void and64(TrustedImm64 imm, RegisterID dest)
+    {
+        LogicalImmediate logicalImm = LogicalImmediate::create64(bitwise_cast<uint64_t>(imm.m_value));
+
         if (logicalImm.isValid()) {
             m_assembler.and_<64>(dest, dest, logicalImm);
             return;

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerX86_64.h (260550 => 260551)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerX86_64.h	2020-04-23 02:18:46 UTC (rev 260550)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerX86_64.h	2020-04-23 03:11:02 UTC (rev 260551)
@@ -441,7 +441,13 @@
 
     void and64(TrustedImmPtr imm, RegisterID srcDest)
     {
-        intptr_t intValue = imm.asIntptr();
+        static_assert(sizeof(void*) == sizeof(int64_t));
+        and64(TrustedImm64(bitwise_cast<int64_t>(imm.m_value)), srcDest);
+    }
+
+    void and64(TrustedImm64 imm, RegisterID srcDest)
+    {
+        int64_t intValue = imm.m_value;
         if (intValue <= std::numeric_limits<int32_t>::max()
             && intValue >= std::numeric_limits<int32_t>::min()) {
             and64(TrustedImm32(static_cast<int32_t>(intValue)), srcDest);

Modified: trunk/Source/_javascript_Core/bytecode/ArithProfile.cpp (260550 => 260551)


--- trunk/Source/_javascript_Core/bytecode/ArithProfile.cpp	2020-04-23 02:18:46 UTC (rev 260550)
+++ trunk/Source/_javascript_Core/bytecode/ArithProfile.cpp	2020-04-23 03:11:02 UTC (rev 260551)
@@ -49,7 +49,7 @@
     notDouble.link(&jit);
 
 #if USE(BIGINT32)
-    CCallHelpers::Jump notBigInt32 = jit.branchIfNotBigInt32KnownNotNumber(regs, tempGPR);
+    CCallHelpers::Jump notBigInt32 = jit.branchIfNotBigInt32(regs, tempGPR, mode);
     emitSetBigInt32(jit);
     done.append(jit.jump());
     notBigInt32.link(&jit);

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp (260550 => 260551)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp	2020-04-23 02:18:46 UTC (rev 260550)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp	2020-04-23 03:11:02 UTC (rev 260551)
@@ -1469,8 +1469,7 @@
         if (type & ~SpecBigInt32) {
             CCallHelpers::JumpList failureCases;
             GPRReg tempGPR = allocate();
-            failureCases.append(m_jit.branchIfNumber(gpr));
-            failureCases.append(m_jit.branchIfNotBigInt32KnownNotNumber(gpr, tempGPR));
+            failureCases.append(m_jit.branchIfNotBigInt32(gpr, tempGPR));
             speculationCheck(BadType, JSValueRegs(gpr), edge, failureCases);
             unlock(tempGPR);
         }

Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (260550 => 260551)


--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2020-04-23 02:18:46 UTC (rev 260550)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2020-04-23 03:11:02 UTC (rev 260551)
@@ -7554,7 +7554,7 @@
             // notNumber case.
             LBasicBlock lastNext = m_out.appendTo(notNumber, continuation);
 #if USE(BIGINT32)
-            m_out.branch(isBigInt32KnownNotNumber(value, provenType(m_node->child1())), unsure(continuation), unsure(notBigInt32));
+            m_out.branch(isBigInt32(value, provenType(m_node->child1())), unsure(continuation), unsure(notBigInt32));
             m_out.appendTo(notBigInt32);
 #endif
             m_out.branch(isCell(value, provenType(m_node->child1())), unsure(isCellPath), unsure(slowPath));
@@ -8719,9 +8719,6 @@
             LBasicBlock rightIsNotBigInt32 = m_out.newBlock();
             LBasicBlock continuation = m_out.newBlock();
 
-            FTL_TYPE_CHECK(jsValueValue(left), m_node->child1(), ~SpecFullNumber, isNumber(left));
-            FTL_TYPE_CHECK(jsValueValue(right), m_node->child2(), ~SpecFullNumber, isNumber(right));
-
             // Inserts a check that a value is a HeapBigInt, assuming only that we know it is not a BigInt32
             auto checkIsHeapBigInt = [&](LValue lowValue, Edge highValue) {
                 if (m_interpreter.needsTypeCheck(highValue, SpecHeapBigInt)) {
@@ -8731,10 +8728,10 @@
                 }
             };
 
-            m_out.branch(isBigInt32KnownNotNumber(left, provenType(m_node->child1())), unsure(leftIsBigInt32), unsure(leftIsNotBigInt32));
+            m_out.branch(isBigInt32(left, provenType(m_node->child1())), unsure(leftIsBigInt32), unsure(leftIsNotBigInt32));
 
             LBasicBlock lastNext = m_out.appendTo(leftIsBigInt32, bothAreBigInt32);
-            m_out.branch(isBigInt32KnownNotNumber(right, provenType(m_node->child2())), unsure(bothAreBigInt32), unsure(onlyLeftIsBigInt32));
+            m_out.branch(isBigInt32(right, provenType(m_node->child2())), unsure(bothAreBigInt32), unsure(onlyLeftIsBigInt32));
 
             m_out.appendTo(bothAreBigInt32, onlyLeftIsBigInt32);
             ValueFromBlock resultBothAreBigInt32 = m_out.anchor(m_out.equal(left, right));
@@ -8755,7 +8752,7 @@
             m_out.jump(continuation);
 
             m_out.appendTo(leftIsHeapBigInt, rightIsBigInt32);
-            m_out.branch(isBigInt32KnownNotNumber(right, provenType(m_node->child2())), unsure(rightIsBigInt32), unsure(rightIsNotBigInt32));
+            m_out.branch(isBigInt32(right, provenType(m_node->child2())), unsure(rightIsBigInt32), unsure(rightIsNotBigInt32));
 
             m_out.appendTo(rightIsBigInt32, rightIsNotBigInt32);
             LValue unboxedRight = unboxBigInt32(right);
@@ -10928,7 +10925,7 @@
 
         LBasicBlock lastNext = m_out.appendTo(isNotCellCase, isCellCase);
         // FIXME: we should filter the provenType to include the fact that we know we are not dealing with a cell
-        ValueFromBlock notCellResult = m_out.anchor(isBigInt32KnownNotCell(value, provenType(m_node->child1())));
+        ValueFromBlock notCellResult = m_out.anchor(isBigInt32(value, provenType(m_node->child1())));
         m_out.jump(continuation);
 
         m_out.appendTo(isCellCase, continuation);
@@ -15471,7 +15468,7 @@
 #if USE(BIGINT32)
             m_out.appendTo(notDoubleCase, bigInt32Case);
             m_out.branch(
-                isBigInt32KnownNotNumber(value, provenType(edge) & ~SpecCell),
+                isBigInt32(value, provenType(edge) & ~SpecCell),
                 unsure(bigInt32Case), unsure(notBigInt32Case));
 
             m_out.appendTo(bigInt32Case, notBigInt32Case);
@@ -16197,7 +16194,7 @@
 
 #if USE(BIGINT32)
         m_out.appendTo(notNumberCase, notBigInt32Case);
-        m_out.branch(isBigInt32KnownNotNumber(value, provenType(child) & ~SpecCell), unsure(bigIntCase), unsure(notBigInt32Case));
+        m_out.branch(isBigInt32(value, provenType(child) & ~SpecCell), unsure(bigIntCase), unsure(notBigInt32Case));
 
         m_out.appendTo(notBigInt32Case, notNullCase);
 #else
@@ -16917,8 +16914,7 @@
         LoweredNodeValue value = m_jsValueValues.get(edge.node());
         if (isValid(value)) {
             LValue result = value.value();
-            FTL_TYPE_CHECK(jsValueValue(result), edge, ~SpecFullNumber, isNumber(result));
-            FTL_TYPE_CHECK(jsValueValue(result), edge, SpecBigInt32, isNotBigInt32KnownNotNumber(result));
+            FTL_TYPE_CHECK(jsValueValue(result), edge, SpecBigInt32, isNotBigInt32(result));
             return result;
         }
 
@@ -17115,23 +17111,17 @@
     }
 
 #if USE(BIGINT32)
-    LValue isBigInt32KnownNotCell(LValue jsValue, SpeculatedType type = SpecFullTop)
+    LValue isBigInt32(LValue jsValue, SpeculatedType type = SpecFullTop)
     {
         if (LValue proven = isProvenValue(type, SpecBigInt32))
             return proven;
         return m_out.equal(m_out.bitAnd(jsValue, m_out.constInt64(JSValue::BigInt32Mask)), m_out.constInt64(JSValue::BigInt32Tag));
     }
-    LValue isBigInt32KnownNotNumber(LValue jsValue, SpeculatedType type = SpecFullTop)
+    LValue isNotBigInt32(LValue jsValue, SpeculatedType type = SpecFullTop)
     {
-        if (LValue proven = isProvenValue(type, SpecBigInt32))
-            return proven;
-        return m_out.equal(m_out.bitAnd(jsValue, m_out.constInt64(JSValue::BigInt32Tag)), m_out.constInt64(JSValue::BigInt32Tag));
-    }
-    LValue isNotBigInt32KnownNotNumber(LValue jsValue, SpeculatedType type = SpecFullTop)
-    {
         if (LValue proven = isProvenValue(type, ~SpecBigInt32))
             return proven;
-        return m_out.notEqual(m_out.bitAnd(jsValue, m_out.constInt64(JSValue::BigInt32Tag)), m_out.constInt64(JSValue::BigInt32Tag));
+        return m_out.notEqual(m_out.bitAnd(jsValue, m_out.constInt64(JSValue::BigInt32Mask)), m_out.constInt64(JSValue::BigInt32Tag));
     }
     LValue unboxBigInt32(LValue jsValue)
     {
@@ -17143,7 +17133,7 @@
             m_out.shl(m_out.zeroExt(int32Value, B3::Int64), m_out.constInt64(16)),
             m_out.constInt64(JSValue::BigInt32Tag));
     }
-    LValue isNotAnyBigIntKnownNotNumber(LValue jsValue, SpeculatedType type = SpecFullTop)
+    LValue isNotAnyBigInt(LValue jsValue, SpeculatedType type = SpecFullTop)
     {
         if (LValue proven = isProvenValue(type, ~SpecBigInt))
             return proven;
@@ -17159,7 +17149,7 @@
         LBasicBlock isCellCase = m_out.newBlock();
         LBasicBlock continuation = m_out.newBlock();
 
-        m_out.branch(isBigInt32KnownNotNumber(jsValue, type), unsure(isBigInt32Case), unsure(isNotBigInt32Case));
+        m_out.branch(isBigInt32(jsValue, type), unsure(isBigInt32Case), unsure(isNotBigInt32Case));
 
         LBasicBlock lastNext = m_out.appendTo(isBigInt32Case, isNotBigInt32Case);
         ValueFromBlock returnFalse = m_out.anchor(m_out.booleanFalse);
@@ -18190,15 +18180,13 @@
     void speculateBigInt32(Edge edge)
     {
         LValue value = lowJSValue(edge, ManualOperandSpeculation);
-        FTL_TYPE_CHECK(jsValueValue(value), edge, ~SpecFullNumber, isNumber(value));
-        FTL_TYPE_CHECK(jsValueValue(value), edge, SpecBigInt32, isNotBigInt32KnownNotNumber(value));
+        FTL_TYPE_CHECK(jsValueValue(value), edge, SpecBigInt32, isNotBigInt32(value));
     }
 
     void speculateAnyBigInt(Edge edge)
     {
         LValue value = lowJSValue(edge, ManualOperandSpeculation);
-        FTL_TYPE_CHECK(jsValueValue(value), edge, ~SpecFullNumber, isNumber(value));
-        FTL_TYPE_CHECK(jsValueValue(value), edge, SpecBigInt, isNotAnyBigIntKnownNotNumber(value));
+        FTL_TYPE_CHECK(jsValueValue(value), edge, SpecBigInt, isNotAnyBigInt(value));
     }
 #endif
 

Modified: trunk/Source/_javascript_Core/jit/AssemblyHelpers.cpp (260550 => 260551)


--- trunk/Source/_javascript_Core/jit/AssemblyHelpers.cpp	2020-04-23 02:18:46 UTC (rev 260550)
+++ trunk/Source/_javascript_Core/jit/AssemblyHelpers.cpp	2020-04-23 03:11:02 UTC (rev 260551)
@@ -755,7 +755,7 @@
 
     notDouble.link(this);
 #if USE(BIGINT32)
-    auto isNotBigInt32 = branchIfNotBigInt32KnownNotNumber(value.gpr(), result);
+    auto isNotBigInt32 = branchIfNotBigInt32(value.gpr(), result);
     move(value.gpr(), result);
     urshift64(TrustedImm32(16), result);
     compare32(invert ? Equal : NotEqual, result, TrustedImm32(0), result);
@@ -856,7 +856,7 @@
 
     notDouble.link(this);
 #if USE(BIGINT32)
-    auto isNotBigInt32 = branchIfNotBigInt32KnownNotNumber(value.gpr(), scratch);
+    auto isNotBigInt32 = branchIfNotBigInt32(value.gpr(), scratch);
     move(value.gpr(), scratch);
     urshift64(TrustedImm32(16), scratch);
     truthy.append(branchTest32(invert ? Zero : NonZero, scratch));

Modified: trunk/Source/_javascript_Core/jit/AssemblyHelpers.h (260550 => 260551)


--- trunk/Source/_javascript_Core/jit/AssemblyHelpers.h	2020-04-23 02:18:46 UTC (rev 260550)
+++ trunk/Source/_javascript_Core/jit/AssemblyHelpers.h	2020-04-23 03:11:02 UTC (rev 260551)
@@ -933,39 +933,38 @@
 #if USE(BIGINT32)
     Jump branchIfBigInt32(GPRReg gpr, GPRReg tempGPR, TagRegistersMode mode = HaveTagRegisters)
     {
-        Jump number = branchIfNumber(gpr, mode);
-        Jump bigInt32 = branchIfBigInt32KnownNotNumber(gpr, tempGPR);
-        number.link(this);
-        return bigInt32;
-    }
-    JumpList branchIfNotBigInt32(GPRReg gpr, GPRReg tempGPR, TagRegistersMode mode = HaveTagRegisters)
-    {
-        JumpList result;
-        result.append(branchIfNumber(gpr, mode));
-        Jump bigInt32 = branchIfBigInt32KnownNotNumber(gpr, tempGPR);
-        result.append(jump());
-        bigInt32.link(this);
-        return result;
-    }
-
-    Jump branchIfBigInt32KnownNotNumber(GPRReg gpr, GPRReg tempGPR)
-    {
         ASSERT(tempGPR != InvalidGPRReg);
+        if (mode == HaveTagRegisters && gpr != tempGPR) {
+            static_assert(JSValue::BigInt32Mask == JSValue::NumberTag + JSValue::BigInt32Tag);
+            add64(TrustedImm32(JSValue::BigInt32Tag), GPRInfo::numberTagRegister, tempGPR);
+            and64(gpr, tempGPR);
+            return branch64(Equal, tempGPR, TrustedImm32(JSValue::BigInt32Tag));
+        }
         move(gpr, tempGPR);
-        and64(TrustedImm32(JSValue::BigInt32Tag), tempGPR);
+        and64(TrustedImm64(JSValue::BigInt32Mask), tempGPR);
         return branch64(Equal, tempGPR, TrustedImm32(JSValue::BigInt32Tag));
     }
-    Jump branchIfNotBigInt32KnownNotNumber(JSValueRegs regs, GPRReg tempGPR)
+    Jump branchIfNotBigInt32(GPRReg gpr, GPRReg tempGPR, TagRegistersMode mode = HaveTagRegisters)
     {
-        return branchIfNotBigInt32KnownNotNumber(regs.gpr(), tempGPR);
-    }
-    Jump branchIfNotBigInt32KnownNotNumber(GPRReg gpr, GPRReg tempGPR)
-    {
         ASSERT(tempGPR != InvalidGPRReg);
+        if (mode == HaveTagRegisters && gpr != tempGPR) {
+            static_assert(JSValue::BigInt32Mask == JSValue::NumberTag + JSValue::BigInt32Tag);
+            add64(TrustedImm32(JSValue::BigInt32Tag), GPRInfo::numberTagRegister, tempGPR);
+            and64(gpr, tempGPR);
+            return branch64(NotEqual, tempGPR, TrustedImm32(JSValue::BigInt32Tag));
+        }
         move(gpr, tempGPR);
-        and64(TrustedImm32(JSValue::BigInt32Tag), tempGPR);
+        and64(TrustedImm64(JSValue::BigInt32Mask), tempGPR);
         return branch64(NotEqual, tempGPR, TrustedImm32(JSValue::BigInt32Tag));
     }
+    Jump branchIfBigInt32(JSValueRegs regs, GPRReg tempGPR, TagRegistersMode mode = HaveTagRegisters)
+    {
+        return branchIfBigInt32(regs.gpr(), tempGPR, mode);
+    }
+    Jump branchIfNotBigInt32(JSValueRegs regs, GPRReg tempGPR, TagRegistersMode mode = HaveTagRegisters)
+    {
+        return branchIfNotBigInt32(regs.gpr(), tempGPR, mode);
+    }
 #endif // USE(BIGINT32)
 
     // FIXME: rename these to make it clear that they require their input to be a cell.
@@ -1833,7 +1832,7 @@
         notBoolean.link(this);
 
 #if USE(BIGINT32)
-        Jump notBigInt32 = branchIfNotBigInt32KnownNotNumber(regs, tempGPR);
+        Jump notBigInt32 = branchIfNotBigInt32(regs, tempGPR);
         functor(TypeofType::BigInt, false);
         notBigInt32.link(this);
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to