Changeset 196573 in webkit


Ignore:
Timestamp:
Feb 15, 2016 1:12:45 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC] Improve the interface of Inst::shouldTryAliasingDef()
https://bugs.webkit.org/show_bug.cgi?id=154227

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-02-15
Reviewed by Andreas Kling.

Using Optional<> instead of a bool+reference looks cleaner
at the call sites.

  • b3/B3CheckSpecial.cpp:

(JSC::B3::CheckSpecial::shouldTryAliasingDef):

  • b3/B3CheckSpecial.h:
  • b3/air/AirCustom.h:

(JSC::B3::Air::PatchCustom::shouldTryAliasingDef):

  • b3/air/AirInst.h:
  • b3/air/AirInstInlines.h:

(JSC::B3::Air::Inst::shouldTryAliasingDef):

  • b3/air/AirIteratedRegisterCoalescing.cpp:
  • b3/air/AirSpecial.cpp:

(JSC::B3::Air::Special::shouldTryAliasingDef):

  • b3/air/AirSpecial.h:
Location:
trunk/Source/JavaScriptCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r196562 r196573  
     12016-02-15  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Improve the interface of Inst::shouldTryAliasingDef()
     4        https://bugs.webkit.org/show_bug.cgi?id=154227
     5
     6        Reviewed by Andreas Kling.
     7
     8        Using Optional<> instead of a bool+reference looks cleaner
     9        at the call sites.
     10
     11        * b3/B3CheckSpecial.cpp:
     12        (JSC::B3::CheckSpecial::shouldTryAliasingDef):
     13        * b3/B3CheckSpecial.h:
     14        * b3/air/AirCustom.h:
     15        (JSC::B3::Air::PatchCustom::shouldTryAliasingDef):
     16        * b3/air/AirInst.h:
     17        * b3/air/AirInstInlines.h:
     18        (JSC::B3::Air::Inst::shouldTryAliasingDef):
     19        * b3/air/AirIteratedRegisterCoalescing.cpp:
     20        * b3/air/AirSpecial.cpp:
     21        (JSC::B3::Air::Special::shouldTryAliasingDef):
     22        * b3/air/AirSpecial.h:
     23
    1242016-02-14  Brian Burg  <bburg@apple.com>
    225
  • trunk/Source/JavaScriptCore/b3/B3CheckSpecial.cpp

    r196513 r196573  
    131131}
    132132
    133 bool CheckSpecial::shouldTryAliasingDef(Inst& inst, unsigned& defIndex)
    134 {
    135     if (hiddenBranch(inst).shouldTryAliasingDef(defIndex)) {
    136         defIndex += 1;
    137         return true;
    138     }
    139     return false;
     133Optional<unsigned> CheckSpecial::shouldTryAliasingDef(Inst& inst)
     134{
     135    if (Optional<unsigned> branchDef = hiddenBranch(inst).shouldTryAliasingDef())
     136        return *branchDef + 1;
     137    return Nullopt;
    140138}
    141139
  • trunk/Source/JavaScriptCore/b3/B3CheckSpecial.h

    r196513 r196573  
    127127    bool isValid(Air::Inst&) override;
    128128    bool admitsStack(Air::Inst&, unsigned argIndex) override;
    129     bool shouldTryAliasingDef(Air::Inst&, unsigned& defIndex) override;
     129    Optional<unsigned> shouldTryAliasingDef(Air::Inst&) override;
    130130
    131131    // NOTE: the generate method will generate the hidden branch and then register a LatePath that
  • trunk/Source/JavaScriptCore/b3/air/AirCustom.h

    r196513 r196573  
    8181    }
    8282
    83     static bool shouldTryAliasingDef(Inst& inst, unsigned& defIndex)
    84     {
    85         return inst.args[0].special()->shouldTryAliasingDef(inst, defIndex);
     83    static Optional<unsigned> shouldTryAliasingDef(Inst& inst)
     84    {
     85        return inst.args[0].special()->shouldTryAliasingDef(inst);
    8686    }
    8787
  • trunk/Source/JavaScriptCore/b3/air/AirInst.h

    r196513 r196573  
    181181    CCallHelpers::Jump generate(CCallHelpers&, GenerationContext&);
    182182
    183     // Returns true if the register allocator should attempt to alias the arguments with the destination
    184     // for this instruction.
    185     // If the method returns true, defIndex is set to the index of the destination argument. The indices
    186     // (defIndex - 1) and (defIndex - 2) are the one to alias to defIndex.
    187     bool shouldTryAliasingDef(unsigned& defIndex);
     183    // If source arguments benefits from being aliased to a destination argument,
     184    // this return the index of the destination argument.
     185    // The source are assumed to be at (index - 1) and (index - 2)
     186    // For example,
     187    //     Add Tmp1, Tmp2, Tmp3
     188    // returns 2 if 0 and 1 benefit from aliasing to Tmp3.
     189    Optional<unsigned> shouldTryAliasingDef();
    188190
    189191    void dump(PrintStream&) const;
  • trunk/Source/JavaScriptCore/b3/air/AirInstInlines.h

    r196513 r196573  
    165165}
    166166
    167 inline bool Inst::shouldTryAliasingDef(unsigned& defIndex)
     167inline Optional<unsigned> Inst::shouldTryAliasingDef()
    168168{
    169169    if (!isX86())
    170         return false;
     170        return Nullopt;
    171171
    172172    switch (opcode) {
     
    189189    case XorDouble:
    190190    case XorFloat:
    191         if (args.size() == 3) {
    192             defIndex = 2;
    193             return true;
    194         }
     191        if (args.size() == 3)
     192            return 2;
    195193        break;
    196194    case BranchAdd32:
    197195    case BranchAdd64:
    198         if (args.size() == 4) {
    199             defIndex = 3;
    200             return true;
    201         }
     196        if (args.size() == 4)
     197            return 3;
    202198        break;
    203199    case Patch:
    204         return PatchCustom::shouldTryAliasingDef(*this, defIndex);
     200        return PatchCustom::shouldTryAliasingDef(*this);
    205201    default:
    206202        break;
    207203    }
    208     return false;
     204    return Nullopt;
    209205}
    210206
  • trunk/Source/JavaScriptCore/b3/air/AirIteratedRegisterCoalescing.cpp

    r196513 r196573  
    993993        for (BasicBlock* block : m_code) {
    994994            for (Inst& inst : *block) {
    995                 unsigned defArgIndex = 0;
    996                 if (inst.shouldTryAliasingDef(defArgIndex)) {
    997                     Arg op1 = inst.args[defArgIndex - 2];
    998                     Arg op2 = inst.args[defArgIndex - 1];
    999                     Arg dest = inst.args[defArgIndex];
     995                if (Optional<unsigned> defArgIndex = inst.shouldTryAliasingDef()) {
     996                    Arg op1 = inst.args[*defArgIndex - 2];
     997                    Arg op2 = inst.args[*defArgIndex - 1];
     998                    Arg dest = inst.args[*defArgIndex];
    1000999
    10011000                    if (op1 == dest || op2 == dest)
  • trunk/Source/JavaScriptCore/b3/air/AirSpecial.cpp

    r196513 r196573  
    5151}
    5252
    53 bool Special::shouldTryAliasingDef(Inst&, unsigned&)
     53Optional<unsigned> Special::shouldTryAliasingDef(Inst&)
    5454{
    55     return false;
     55    return Nullopt;
    5656}
    5757
  • trunk/Source/JavaScriptCore/b3/air/AirSpecial.h

    r196513 r196573  
    5757    virtual bool isValid(Inst&) = 0;
    5858    virtual bool admitsStack(Inst&, unsigned argIndex) = 0;
    59     virtual bool shouldTryAliasingDef(Inst&, unsigned& defIndex);
     59    virtual Optional<unsigned> shouldTryAliasingDef(Inst&);
    6060
    6161    // This gets called on for each Inst that uses this Special. Note that there is no way to
Note: See TracChangeset for help on using the changeset viewer.