Changeset 260802 in webkit


Ignore:
Timestamp:
Apr 27, 2020 5:35:45 PM (4 years ago)
Author:
sbarati@apple.com
Message:

compilePeepHoleBigInt32Branch needs to handle all conditions
https://bugs.webkit.org/show_bug.cgi?id=211096
<rdar://problem/62469971>

Reviewed by Yusuke Suzuki.

We were falling through to the generic path for all conditions which
weren't Equal/NotEqual. The generic path does not do speculation, so
it was leading to potential miscompiles because we omitted a type check.
Defining compilePeepHoleBigInt32Branch for other conditions is trivial,
so this patch just implements that.

This failure is caught by microbenchmarks/sunspider-sha1-big-int.js

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compilePeepHoleBranch):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compilePeepHoleBigInt32Branch):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r260799 r260802  
     12020-04-27  Saam Barati  <sbarati@apple.com>
     2
     3        compilePeepHoleBigInt32Branch needs to handle all conditions
     4        https://bugs.webkit.org/show_bug.cgi?id=211096
     5        <rdar://problem/62469971>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        We were falling through to the generic path for all conditions which
     10        weren't Equal/NotEqual. The generic path does not do speculation, so
     11        it was leading to potential miscompiles because we omitted a type check.
     12        Defining compilePeepHoleBigInt32Branch for other conditions is trivial,
     13        so this patch just implements that.
     14
     15        This failure is caught by microbenchmarks/sunspider-sha1-big-int.js
     16
     17        * dfg/DFGSpeculativeJIT.cpp:
     18        (JSC::DFG::SpeculativeJIT::compilePeepHoleBranch):
     19        * dfg/DFGSpeculativeJIT64.cpp:
     20        (JSC::DFG::SpeculativeJIT::compilePeepHoleBigInt32Branch):
     21
    1222020-04-27  Jason Lawrence  <lawrence.j@apple.com>
    223
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r260730 r260802  
    17171717            compilePeepHoleInt32Branch(node, branchNode, condition);
    17181718#if USE(BIGINT32)
    1719         else if (node->isBinaryUseKind(BigInt32Use) && (condition == MacroAssembler::Equal || condition == MacroAssembler::NotEqual))
     1719        else if (node->isBinaryUseKind(BigInt32Use))
    17201720            compilePeepHoleBigInt32Branch(node, branchNode, condition);
    17211721#endif
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r260660 r260802  
    17681768void SpeculativeJIT::compilePeepHoleBigInt32Branch(Node* node, Node* branchNode, JITCompiler::RelationalCondition condition)
    17691769{
    1770     // Other conditions would require unboxing the BigInt32 to get correct results on negative numbers.
    1771     ASSERT(condition == MacroAssembler::Equal || condition == MacroAssembler::NotEqual);
    1772 
    17731770    BasicBlock* taken = branchNode->branchData()->taken.block;
    17741771    BasicBlock* notTaken = branchNode->branchData()->notTaken.block;
     
    17781775    if (taken == nextBlock()) {
    17791776        condition = JITCompiler::invert(condition);
    1780         BasicBlock* tmp = taken;
    1781         taken = notTaken;
    1782         notTaken = tmp;
     1777        std::swap(taken, notTaken);
    17831778    }
    17841779
    17851780    SpeculateBigInt32Operand op1(this, node->child1());
    17861781    SpeculateBigInt32Operand op2(this, node->child2());
    1787 
    1788     branch64(condition, op1.gpr(), op2.gpr(), taken);
    1789     jump(notTaken);
     1782    GPRReg op1GPR = op1.gpr();
     1783    GPRReg op2GPR = op2.gpr();
     1784
     1785    if (condition == MacroAssembler::Equal || condition == MacroAssembler::NotEqual) {
     1786        branch64(condition, op1GPR, op2GPR, taken);
     1787        jump(notTaken);
     1788    } else {
     1789        GPRTemporary lhs(this, Reuse, op1);
     1790        GPRTemporary rhs(this, Reuse, op2);
     1791        GPRReg lhsGPR = lhs.gpr();
     1792        GPRReg rhsGPR = rhs.gpr();
     1793        m_jit.unboxBigInt32(op1GPR, lhsGPR);
     1794        m_jit.unboxBigInt32(op2GPR, rhsGPR);
     1795        branch32(condition, lhsGPR, rhsGPR, taken);
     1796        jump(notTaken);
     1797    }
     1798
    17901799}
    17911800#endif // USE(BIGINT32)
Note: See TracChangeset for help on using the changeset viewer.