Ignore:
Timestamp:
Dec 8, 2013, 5:06:54 PM (11 years ago)
Author:
[email protected]
Message:

FTL should support UntypedUse versions of Compare nodes
https://bugs.webkit.org/show_bug.cgi?id=125426

Reviewed by Oliver Hunt.

This adds UntypedUse versions of all comparisons except CompareStrictEq, which is
sufficiently different that I thought I'd do it in another patch.

This also extends our ability to abstract over comparison kind and removes a bunch of
copy-paste code.

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompare):

  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLIntrinsicRepository.h:
  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::compileCompareEq):
(JSC::FTL::LowerDFGToLLVM::compileCompareLess):
(JSC::FTL::LowerDFGToLLVM::compileCompareLessEq):
(JSC::FTL::LowerDFGToLLVM::compileCompareGreater):
(JSC::FTL::LowerDFGToLLVM::compileCompareGreaterEq):
(JSC::FTL::LowerDFGToLLVM::compare):
(JSC::FTL::LowerDFGToLLVM::nonSpeculativeCompare):

  • ftl/FTLOutput.h:

(JSC::FTL::Output::icmp):
(JSC::FTL::Output::equal):
(JSC::FTL::Output::notEqual):
(JSC::FTL::Output::above):
(JSC::FTL::Output::aboveOrEqual):
(JSC::FTL::Output::below):
(JSC::FTL::Output::belowOrEqual):
(JSC::FTL::Output::greaterThan):
(JSC::FTL::Output::greaterThanOrEqual):
(JSC::FTL::Output::lessThan):
(JSC::FTL::Output::lessThanOrEqual):
(JSC::FTL::Output::fcmp):
(JSC::FTL::Output::doubleEqual):
(JSC::FTL::Output::doubleNotEqualOrUnordered):
(JSC::FTL::Output::doubleLessThan):
(JSC::FTL::Output::doubleLessThanOrEqual):
(JSC::FTL::Output::doubleGreaterThan):
(JSC::FTL::Output::doubleGreaterThanOrEqual):
(JSC::FTL::Output::doubleEqualOrUnordered):
(JSC::FTL::Output::doubleNotEqual):
(JSC::FTL::Output::doubleLessThanOrUnordered):
(JSC::FTL::Output::doubleLessThanOrEqualOrUnordered):
(JSC::FTL::Output::doubleGreaterThanOrUnordered):
(JSC::FTL::Output::doubleGreaterThanOrEqualOrUnordered):

  • tests/stress/untyped-equality.js: Added.

(foo):

  • tests/stress/untyped-less-than.js: Added.

(foo):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp

    r160292 r160294  
    23972397        }
    23982398       
     2399        if (m_node->isBinaryUseKind(UntypedUse)) {
     2400            nonSpeculativeCompare(LLVMIntEQ, operationCompareEq);
     2401            return;
     2402        }
     2403       
    23992404        RELEASE_ASSERT_NOT_REACHED();
    24002405    }
     
    24652470    void compileCompareLess()
    24662471    {
    2467         if (m_node->isBinaryUseKind(Int32Use)) {
    2468             setBoolean(
    2469                 m_out.lessThan(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
    2470             return;
    2471         }
    2472        
    2473         if (m_node->isBinaryUseKind(MachineIntUse)) {
    2474             Int52Kind kind;
    2475             LValue left = lowWhicheverInt52(m_node->child1(), kind);
    2476             LValue right = lowInt52(m_node->child2(), kind);
    2477             setBoolean(m_out.lessThan(left, right));
    2478             return;
    2479         }
    2480        
    2481         if (m_node->isBinaryUseKind(NumberUse)) {
    2482             setBoolean(
    2483                 m_out.doubleLessThan(lowDouble(m_node->child1()), lowDouble(m_node->child2())));
    2484             return;
    2485         }
    2486        
    2487         RELEASE_ASSERT_NOT_REACHED();
     2472        compare(LLVMIntSLT, LLVMRealOLT, operationCompareLess);
    24882473    }
    24892474   
    24902475    void compileCompareLessEq()
    24912476    {
    2492         if (m_node->isBinaryUseKind(Int32Use)) {
    2493             setBoolean(
    2494                 m_out.lessThanOrEqual(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
    2495             return;
    2496         }
    2497        
    2498         if (m_node->isBinaryUseKind(MachineIntUse)) {
    2499             Int52Kind kind;
    2500             LValue left = lowWhicheverInt52(m_node->child1(), kind);
    2501             LValue right = lowInt52(m_node->child2(), kind);
    2502             setBoolean(m_out.lessThanOrEqual(left, right));
    2503             return;
    2504         }
    2505        
    2506         if (m_node->isBinaryUseKind(NumberUse)) {
    2507             setBoolean(
    2508                 m_out.doubleLessThanOrEqual(
    2509                     lowDouble(m_node->child1()), lowDouble(m_node->child2())));
    2510             return;
    2511         }
    2512        
    2513         RELEASE_ASSERT_NOT_REACHED();
     2477        compare(LLVMIntSLE, LLVMRealOLE, operationCompareLessEq);
    25142478    }
    25152479   
    25162480    void compileCompareGreater()
    25172481    {
    2518         if (m_node->isBinaryUseKind(Int32Use)) {
    2519             setBoolean(
    2520                 m_out.greaterThan(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
    2521             return;
    2522         }
    2523        
    2524         if (m_node->isBinaryUseKind(MachineIntUse)) {
    2525             Int52Kind kind;
    2526             LValue left = lowWhicheverInt52(m_node->child1(), kind);
    2527             LValue right = lowInt52(m_node->child2(), kind);
    2528             setBoolean(m_out.greaterThan(left, right));
    2529             return;
    2530         }
    2531        
    2532         if (m_node->isBinaryUseKind(NumberUse)) {
    2533             setBoolean(
    2534                 m_out.doubleGreaterThan(
    2535                     lowDouble(m_node->child1()), lowDouble(m_node->child2())));
    2536             return;
    2537         }
    2538        
    2539         RELEASE_ASSERT_NOT_REACHED();
     2482        compare(LLVMIntSGT, LLVMRealOGT, operationCompareGreater);
    25402483    }
    25412484   
    25422485    void compileCompareGreaterEq()
    25432486    {
    2544         if (m_node->isBinaryUseKind(Int32Use)) {
    2545             setBoolean(
    2546                 m_out.greaterThanOrEqual(
    2547                     lowInt32(m_node->child1()), lowInt32(m_node->child2())));
    2548             return;
    2549         }
    2550        
    2551         if (m_node->isBinaryUseKind(MachineIntUse)) {
    2552             Int52Kind kind;
    2553             LValue left = lowWhicheverInt52(m_node->child1(), kind);
    2554             LValue right = lowInt52(m_node->child2(), kind);
    2555             setBoolean(m_out.greaterThanOrEqual(left, right));
    2556             return;
    2557         }
    2558        
    2559         if (m_node->isBinaryUseKind(NumberUse)) {
    2560             setBoolean(
    2561                 m_out.doubleGreaterThanOrEqual(
    2562                     lowDouble(m_node->child1()), lowDouble(m_node->child2())));
    2563             return;
    2564         }
    2565        
    2566         RELEASE_ASSERT_NOT_REACHED();
     2487        compare(LLVMIntSGE, LLVMRealOGE, operationCompareGreaterEq);
    25672488    }
    25682489   
     
    27992720            heap, storage, m_out.zeroExt(index, m_out.intPtr),
    28002721            m_state.forNode(edge).m_value);
     2722    }
     2723   
     2724    void compare(
     2725        LIntPredicate intCondition, LRealPredicate realCondition,
     2726        S_JITOperation_EJJ helperFunction)
     2727    {
     2728        if (m_node->isBinaryUseKind(Int32Use)) {
     2729            LValue left = lowInt32(m_node->child1());
     2730            LValue right = lowInt32(m_node->child2());
     2731            setBoolean(m_out.icmp(intCondition, left, right));
     2732            return;
     2733        }
     2734       
     2735        if (m_node->isBinaryUseKind(MachineIntUse)) {
     2736            Int52Kind kind;
     2737            LValue left = lowWhicheverInt52(m_node->child1(), kind);
     2738            LValue right = lowInt52(m_node->child2(), kind);
     2739            setBoolean(m_out.icmp(intCondition, left, right));
     2740            return;
     2741        }
     2742       
     2743        if (m_node->isBinaryUseKind(NumberUse)) {
     2744            LValue left = lowDouble(m_node->child1());
     2745            LValue right = lowDouble(m_node->child2());
     2746            setBoolean(m_out.fcmp(realCondition, left, right));
     2747            return;
     2748        }
     2749       
     2750        if (m_node->isBinaryUseKind(UntypedUse)) {
     2751            nonSpeculativeCompare(intCondition, helperFunction);
     2752            return;
     2753        }
     2754       
     2755        RELEASE_ASSERT_NOT_REACHED();
     2756    }
     2757   
     2758    void nonSpeculativeCompare(LIntPredicate intCondition, S_JITOperation_EJJ helperFunction)
     2759    {
     2760        LValue left = lowJSValue(m_node->child1());
     2761        LValue right = lowJSValue(m_node->child2());
     2762       
     2763        LBasicBlock leftIsInt = FTL_NEW_BLOCK(m_out, ("CompareEq untyped left is int"));
     2764        LBasicBlock fastPath = FTL_NEW_BLOCK(m_out, ("CompareEq untyped fast path"));
     2765        LBasicBlock slowPath = FTL_NEW_BLOCK(m_out, ("CompareEq untyped slow path"));
     2766        LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("CompareEq untyped continuation"));
     2767       
     2768        m_out.branch(isNotInt32(left), slowPath, leftIsInt);
     2769       
     2770        LBasicBlock lastNext = m_out.appendTo(leftIsInt, fastPath);
     2771        m_out.branch(isNotInt32(right), slowPath, fastPath);
     2772       
     2773        m_out.appendTo(fastPath, slowPath);
     2774        ValueFromBlock fastResult = m_out.anchor(
     2775            m_out.icmp(intCondition, unboxInt32(left), unboxInt32(right)));
     2776        m_out.jump(continuation);
     2777       
     2778        m_out.appendTo(slowPath, continuation);
     2779        ValueFromBlock slowResult = m_out.anchor(m_out.notNull(vmCall(
     2780            m_out.operation(helperFunction), m_callFrame, left, right)));
     2781        m_out.jump(continuation);
     2782       
     2783        m_out.appendTo(continuation, lastNext);
     2784        setBoolean(m_out.phi(m_out.boolean, fastResult, slowResult));
    28012785    }
    28022786   
Note: See TracChangeset for help on using the changeset viewer.