Changeset 192353 in webkit


Ignore:
Timestamp:
Nov 11, 2015 11:17:09 PM (8 years ago)
Author:
mark.lam@apple.com
Message:

The BinarySnippetRegisterContext needs to copy the result back from the scratch register.
https://bugs.webkit.org/show_bug.cgi?id=150712

Reviewed by Geoffrey Garen.

If the BinarySnippetRegisterContext had re-assigned the result register to a scratch
before emitting the snippet, it needs to copy the result back from the scratch after
the snippet is done.

This fixes the cdjs-tests.yaml/main.js.ftl failure reported in
https://bugs.webkit.org/show_bug.cgi?id=150687.

Also added an optimization to check for the case where any of the left, right,
or result registers are aliased together, and to map them to the corresponding
allocated scratch register for their alias instead of allocating separate ones.

  • JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
  • JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
  • Added JITSubGenerator.h to these project files for completeness.
  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • Re-enable ArithSub handling of UntypedUse operands.
  • ftl/FTLCompile.cpp:
  • ftl/FTLInlineCacheSize.cpp:

(JSC::FTL::sizeOfArithSub):

  • Adjusted IC sizes to account for the snippet changes.
Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r192352 r192353  
     12015-11-11  Mark Lam  <mark.lam@apple.com>
     2
     3        The BinarySnippetRegisterContext needs to copy the result back from the scratch register.
     4        https://bugs.webkit.org/show_bug.cgi?id=150712
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        If the BinarySnippetRegisterContext had re-assigned the result register to a scratch
     9        before emitting the snippet, it needs to copy the result back from the scratch after
     10        the snippet is done.
     11
     12        This fixes the cdjs-tests.yaml/main.js.ftl failure reported in
     13        https://bugs.webkit.org/show_bug.cgi?id=150687.
     14
     15        Also added an optimization to check for the case where any of the left, right,
     16        or result registers are aliased together, and to map them to the corresponding
     17        allocated scratch register for their alias instead of allocating separate ones.
     18
     19        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
     20        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
     21        - Added JITSubGenerator.h to these project files for completeness.
     22
     23        * ftl/FTLCapabilities.cpp:
     24        (JSC::FTL::canCompile):
     25        - Re-enable ArithSub handling of UntypedUse operands.
     26
     27        * ftl/FTLCompile.cpp:
     28
     29        * ftl/FTLInlineCacheSize.cpp:
     30        (JSC::FTL::sizeOfArithSub):
     31        - Adjusted IC sizes to account for the snippet changes.
     32
    1332015-11-11  Mark Lam  <mark.lam@apple.com>
    234
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r192273 r192353  
    14701470    <ClInclude Include="..\jit\JITOperations.h" />
    14711471    <ClInclude Include="..\jit\JITStubRoutine.h" />
     1472    <ClInclude Include="..\jit\JITSubGenerator.h" />
    14721473    <ClInclude Include="..\jit\JITThunks.h" />
    14731474    <ClInclude Include="..\jit\JITToDFGDeferredCompilationCallback.h" />
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters

    r192273 r192353  
    25232523      <Filter>jit</Filter>
    25242524    </ClInclude>
     2525    <ClInclude Include="..\jit\JITSubGenerator.h">
     2526      <Filter>jit</Filter>
     2527    </ClInclude>
    25252528    <ClInclude Include="..\jit\JITThunks.h">
    25262529      <Filter>jit</Filter>
  • trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp

    r191753 r192353  
    8585    case ArithAdd:
    8686    case ArithClz32:
     87    case ArithSub:
    8788    case ArithMul:
    8889    case ArithDiv:
     
    212213        // These are OK.
    213214        break;
    214     case ArithSub:
    215         if (node->result() == NodeResultJS)
    216             return CannotCompile;
    217         break;
    218215
    219216    case Identity:
  • trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp

    r192334 r192353  
    311311    // The purpose of this class is to shuffle registers to get them into the state
    312312    // that baseline code expects so that we can use the baseline snippet generators i.e.
    313     //    1. ensure that the inputs and outputs are not in tag or scratch registers.
    314     //    2. tag registers are loaded with the expected values.
     313    //    1. Ensure that the inputs and output are not in reserved registers (which
     314    //       include the tag registers). The snippet will use these reserved registers.
     315    //       Hence, we need to put the inputs and output in other scratch registers.
     316    //    2. Tag registers are loaded with the expected values.
    315317    //
    316     // We also need to:
    317     //    1. restore the input and tag registers to the values that LLVM put there originally.
    318     //    2. that is except when one of the input registers is also the result register.
    319     //       In this case, we don't want to trash the result, and hence, should not restore into it.
     318    // When the snippet is done:
     319    //    1. If we had re-assigned the result register to a scratch, we need to copy the
     320    //       result back from the scratch.
     321    //    2. Restore the input and tag registers to the values that LLVM put there originally.
     322    //       That is unless when one of them is also the result register. In that case, we
     323    //       don't want to trash the result, and hence, should not restore into it.
    320324
    321325public:
     
    333337        m_allocator.lock(m_right);
    334338
    335         RegisterSet inputRegisters = RegisterSet(m_left, m_right);
    336         RegisterSet inputAndOutputRegisters = RegisterSet(inputRegisters, m_result);
    337 
     339        RegisterSet inputAndOutputRegisters = RegisterSet(m_left, m_right, m_result);
    338340        RegisterSet reservedRegisters;
    339341        for (GPRReg reg : GPRInfo::reservedRegisters())
     
    342344        if (reservedRegisters.get(m_left))
    343345            m_left = m_allocator.allocateScratchGPR();
    344         if (reservedRegisters.get(m_right))
    345             m_right = m_allocator.allocateScratchGPR();
    346         if (!inputRegisters.get(m_result) && reservedRegisters.get(m_result))
    347             m_result = m_allocator.allocateScratchGPR();
    348        
     346        if (reservedRegisters.get(m_right)) {
     347            if (m_origRight == m_origLeft)
     348                m_right = m_left;
     349            else
     350                m_right = m_allocator.allocateScratchGPR();
     351        }
     352        if (reservedRegisters.get(m_result)) {
     353            if (m_origResult == m_origLeft)
     354                m_result = m_left;
     355            else if (m_origResult == m_origRight)
     356                m_result = m_right;
     357            else
     358                m_result = m_allocator.allocateScratchGPR();
     359        }
     360
    349361        if (!inputAndOutputRegisters.get(GPRInfo::tagMaskRegister))
    350362            m_savedTagMaskRegister = m_allocator.allocateScratchGPR();
     
    357369        if (m_left != m_origLeft)
    358370            jit.move(m_origLeft, m_left);
    359         if (m_right != m_origRight)
     371        if (m_right != m_origRight && m_origRight != m_origLeft)
    360372            jit.move(m_origRight, m_right);
    361373
     
    370382    void restoreRegisters(CCallHelpers& jit)
    371383    {
     384        if (m_origResult != m_result)
     385            jit.move(m_result, m_origResult);
    372386        if (m_origLeft != m_left && m_origLeft != m_origResult)
    373387            jit.move(m_left, m_origLeft);
    374         if (m_origRight != m_right && m_origRight != m_origResult)
     388        if (m_origRight != m_right && m_origRight != m_origResult && m_origRight != m_origLeft)
    375389            jit.move(m_right, m_origRight);
    376        
    377         if (m_savedTagMaskRegister != InvalidGPRReg)
     390
     391        // We are guaranteed that the tag registers are not the same as the original input
     392        // or output registers. Otherwise, we would not have allocated a scratch for them.
     393        // Hence, we don't need to need to check for overlap like we do for the input registers.
     394        if (m_savedTagMaskRegister != InvalidGPRReg) {
     395            ASSERT(GPRInfo::tagMaskRegister != m_origLeft);
     396            ASSERT(GPRInfo::tagMaskRegister != m_origRight);
     397            ASSERT(GPRInfo::tagMaskRegister != m_origResult);
    378398            jit.move(m_savedTagMaskRegister, GPRInfo::tagMaskRegister);
    379         if (m_savedTagTypeNumberRegister != InvalidGPRReg)
     399        }
     400        if (m_savedTagTypeNumberRegister != InvalidGPRReg) {
     401            ASSERT(GPRInfo::tagTypeNumberRegister != m_origLeft);
     402            ASSERT(GPRInfo::tagTypeNumberRegister != m_origRight);
     403            ASSERT(GPRInfo::tagTypeNumberRegister != m_origResult);
    380404            jit.move(m_savedTagTypeNumberRegister, GPRInfo::tagTypeNumberRegister);
     405        }
    381406    }
    382407
  • trunk/Source/JavaScriptCore/ftl/FTLInlineCacheSize.cpp

    r192334 r192353  
    133133#if CPU(ARM64)
    134134#ifdef NDEBUG
    135     return 192; // ARM64 release.
     135    return 216; // ARM64 release.
    136136#else
    137     return 288; // ARM64 debug.
     137    return 312; // ARM64 debug.
    138138#endif
    139139#else // CPU(X86_64)
    140140#ifdef NDEBUG
    141     return 184; // X86_64 release.
     141    return 223; // X86_64 release.
    142142#else
    143     return 259; // X86_64 debug.
     143    return 298; // X86_64 debug.
    144144#endif
    145145#endif
Note: See TracChangeset for help on using the changeset viewer.