⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 110631 in webkit


Ignore:
Timestamp:
Mar 13, 2012, 3:59:43 PM (15 years ago)
Author:
fpizlo@apple.com
Message:

Loads from UInt32Arrays should not result in a double up-convert if it isn't necessary
​https://bugs.webkit.org/show_bug.cgi?id=80979
<rdar://problem/11036848>

Reviewed by Oliver Hunt.

Also improved DFG IR dumping to include type information in a somewhat more
intuitive way.

  • bytecode/PredictedType.cpp:

(JSC::predictionToAbbreviatedString):
(JSC):

  • bytecode/PredictedType.h:

(JSC):

  • dfg/DFGAbstractState.cpp:

(JSC::DFG::AbstractState::execute):

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::dump):

  • dfg/DFGPredictionPropagationPhase.cpp:

(JSC::DFG::PredictionPropagationPhase::propagate):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileUInt32ToNumber):
(JSC::DFG::SpeculativeJIT::compileGetByValOnIntTypedArray):

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::forwardSpeculationCheck):

Location:
trunk/Source/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r110617 r110631  
     12012-03-13  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Loads from UInt32Arrays should not result in a double up-convert if it isn't necessary
     4        https://bugs.webkit.org/show_bug.cgi?id=80979
     5        <rdar://problem/11036848>
     6
     7        Reviewed by Oliver Hunt.
     8       
     9        Also improved DFG IR dumping to include type information in a somewhat more
     10        intuitive way.
     11
     12        * bytecode/PredictedType.cpp:
     13        (JSC::predictionToAbbreviatedString):
     14        (JSC):
     15        * bytecode/PredictedType.h:
     16        (JSC):
     17        * dfg/DFGAbstractState.cpp:
     18        (JSC::DFG::AbstractState::execute):
     19        * dfg/DFGGraph.cpp:
     20        (JSC::DFG::Graph::dump):
     21        * dfg/DFGPredictionPropagationPhase.cpp:
     22        (JSC::DFG::PredictionPropagationPhase::propagate):
     23        * dfg/DFGSpeculativeJIT.cpp:
     24        (JSC::DFG::SpeculativeJIT::compileUInt32ToNumber):
     25        (JSC::DFG::SpeculativeJIT::compileGetByValOnIntTypedArray):
     26        * dfg/DFGSpeculativeJIT.h:
     27        (JSC::DFG::SpeculativeJIT::forwardSpeculationCheck):
     28
    1292012-03-13  George Staikos  <staikos@webkit.org>
    230
  • trunk/Source/JavaScriptCore/bytecode/PredictedType.cpp

    r108908 r110631  
    167167}
    168168
     169const char* predictionToAbbreviatedString(PredictedType prediction)
     170{
     171    if (isFinalObjectPrediction(prediction))
     172        return "<Final>";
     173    if (isArrayPrediction(prediction))
     174        return "<Array>";
     175    if (isStringPrediction(prediction))
     176        return "<String>";
     177    if (isFunctionPrediction(prediction))
     178        return "<Function>";
     179    if (isByteArrayPrediction(prediction))
     180        return "<Bytearray>";
     181    if (isInt8ArrayPrediction(prediction))
     182        return "<Int8array>";
     183    if (isInt16ArrayPrediction(prediction))
     184        return "<Int16array>";
     185    if (isInt32ArrayPrediction(prediction))
     186        return "<Int32array>";
     187    if (isUint8ArrayPrediction(prediction))
     188        return "<Uint8array>";
     189    if (isUint16ArrayPrediction(prediction))
     190        return "<Uint16array>";
     191    if (isUint32ArrayPrediction(prediction))
     192        return "<Uint32array>";
     193    if (isFloat32ArrayPrediction(prediction))
     194        return "<Float32array>";
     195    if (isFloat64ArrayPrediction(prediction))
     196        return "<Float64array>";
     197    if (isObjectPrediction(prediction))
     198        return "<Object>";
     199    if (isCellPrediction(prediction))
     200        return "<Cell>";
     201    if (isInt32Prediction(prediction))
     202        return "<Int32>";
     203    if (isDoublePrediction(prediction))
     204        return "<Double>";
     205    if (isNumberPrediction(prediction))
     206        return "<Number>";
     207    if (isBooleanPrediction(prediction))
     208        return "<Boolean>";
     209    if (isOtherPrediction(prediction))
     210        return "<Other>";
     211    return "";
     212}
     213
    169214PredictedType predictionFromClassInfo(const ClassInfo* classInfo)
    170215{
  • trunk/Source/JavaScriptCore/bytecode/PredictedType.h

    r109865 r110631  
    226226
    227227const char* predictionToString(PredictedType value);
     228const char* predictionToAbbreviatedString(PredictedType value);
    228229
    229230// Merge two predictions. Note that currently this just does left | right. It may
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractState.cpp

    r110498 r110631  
    515515            forNode(node.child1()).filter(PredictUint32Array);
    516516            forNode(node.child2()).filter(PredictInt32);
    517             forNode(nodeIndex).set(PredictDouble);
     517            if (node.shouldSpeculateInteger())
     518                forNode(nodeIndex).set(PredictInt32);
     519            else
     520                forNode(nodeIndex).set(PredictDouble);
    518521            break;
    519522        }
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp

    r110498 r110631  
    165165            else
    166166                hasPrinted = true;
    167             dataLog("@%u", m_varArgChildren[childIdx].index());
     167            dataLog("@%u%s", m_varArgChildren[childIdx].index(), predictionToAbbreviatedString(at(childIdx).prediction()));
    168168        }
    169169    } else {
    170170        if (!!node.child1())
    171             dataLog("@%u", node.child1().index());
     171            dataLog("@%u%s", node.child1().index(), predictionToAbbreviatedString(at(node.child1()).prediction()));
    172172        if (!!node.child2())
    173             dataLog(", @%u", node.child2().index());
     173            dataLog(", @%u%s", node.child2().index(), predictionToAbbreviatedString(at(node.child2()).prediction()));
    174174        if (!!node.child3())
    175             dataLog(", @%u", node.child3().index());
     175            dataLog(", @%u%s", node.child3().index(), predictionToAbbreviatedString(at(node.child3()).prediction()));
    176176        hasPrinted = !!node.child1();
    177177    }
  • trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp

    r110518 r110631  
    398398           
    399399        case GetByVal: {
    400             if (m_graph[node.child1()].shouldSpeculateUint32Array() || m_graph[node.child1()].shouldSpeculateFloat32Array() || m_graph[node.child1()].shouldSpeculateFloat64Array())
     400            if (m_graph[node.child1()].shouldSpeculateFloat32Array() || m_graph[node.child1()].shouldSpeculateFloat64Array())
    401401                changed |= mergePrediction(PredictDouble);
    402402            else if (node.getHeapPrediction())
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r110498 r110631  
    15481548    // to do this because by this point, the original values necessary to compile whatever
    15491549    // operation the UInt32ToNumber originated from might be dead.
    1550     speculationCheck(Overflow, JSValueRegs(), NoNode, m_jit.branch32(MacroAssembler::LessThan, op1.gpr(), TrustedImm32(0)));
    1551        
    1552     // Verify that we can do roll forward.
    1553     // FIXME: This isn't right, since the next node in the graph may not actually be the next
    1554     // node in the basic block's execution sequence.
    1555     ASSERT(at(m_compileIndex + 1).op() == SetLocal);
    1556     ASSERT(at(m_compileIndex + 1).codeOrigin == node.codeOrigin);
    1557     ASSERT(at(m_compileIndex + 2).codeOrigin != node.codeOrigin);
    1558        
    1559     // Now do the magic.
    1560     OSRExit& exit = m_jit.codeBlock()->lastOSRExit();
    1561     Node& setLocal = at(m_compileIndex + 1);
    1562     exit.m_codeOrigin = at(m_compileIndex + 2).codeOrigin;
    1563     exit.m_lastSetOperand = setLocal.local();
    1564        
    1565     // Create the value recovery, and stuff it into the right place.
    1566     exit.valueRecoveryForOperand(setLocal.local()) = ValueRecovery::uint32InGPR(op1.gpr());
     1550    forwardSpeculationCheck(Overflow, JSValueRegs(), NoNode, m_jit.branch32(MacroAssembler::LessThan, op1.gpr(), TrustedImm32(0)), ValueRecovery::uint32InGPR(op1.gpr()));
    15671551
    15681552    m_jit.move(op1.gpr(), result.gpr());
    … …  
    17611745    }
    17621746    outOfBounds.link(&m_jit);
    1763     if (elementSize < 4 || signedness == SignedTypedArray)
     1747    if (elementSize < 4 || signedness == SignedTypedArray) {
    17641748        integerResult(resultReg, m_compileIndex);
    1765     else {
    1766         FPRTemporary fresult(this);
    1767         m_jit.convertInt32ToDouble(resultReg, fresult.fpr());
    1768         JITCompiler::Jump positive = m_jit.branch32(MacroAssembler::GreaterThanOrEqual, resultReg, TrustedImm32(0));
    1769         m_jit.addDouble(JITCompiler::AbsoluteAddress(&AssemblyHelpers::twoToThe32), fresult.fpr());
    1770         positive.link(&m_jit);
    1771         doubleResult(fresult.fpr(), m_compileIndex);
    1772     }
     1749        return;
     1750    }
     1751   
     1752    ASSERT(elementSize == 4 && signedness == UnsignedTypedArray);
     1753    if (node.shouldSpeculateInteger()) {
     1754        forwardSpeculationCheck(Overflow, JSValueRegs(), NoNode, m_jit.branch32(MacroAssembler::LessThan, resultReg, TrustedImm32(0)), ValueRecovery::uint32InGPR(resultReg));
     1755        integerResult(resultReg, m_compileIndex);
     1756        return;
     1757    }
     1758   
     1759    FPRTemporary fresult(this);
     1760    m_jit.convertInt32ToDouble(resultReg, fresult.fpr());
     1761    JITCompiler::Jump positive = m_jit.branch32(MacroAssembler::GreaterThanOrEqual, resultReg, TrustedImm32(0));
     1762    m_jit.addDouble(JITCompiler::AbsoluteAddress(&AssemblyHelpers::twoToThe32), fresult.fpr());
     1763    positive.link(&m_jit);
     1764    doubleResult(fresult.fpr(), m_compileIndex);
    17731765}
    17741766
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r110498 r110631  
    18241824        speculationCheck(kind, jsValueSource, nodeUse.index(), jumpToFail, recovery);
    18251825    }
     1826    void forwardSpeculationCheck(ExitKind kind, JSValueSource jsValueSource, NodeIndex nodeIndex, MacroAssembler::Jump jumpToFail, const ValueRecovery& valueRecovery)
     1827    {
     1828        speculationCheck(kind, jsValueSource, nodeIndex, jumpToFail);
     1829       
     1830        Node& setLocal = at(m_jit.graph().m_blocks[m_block]->at(m_indexInBlock + 1));
     1831        Node& nextNode = at(m_jit.graph().m_blocks[m_block]->at(m_indexInBlock + 2));
     1832        ASSERT(setLocal.op() == SetLocal);
     1833        ASSERT(setLocal.codeOrigin == at(m_compileIndex).codeOrigin);
     1834        ASSERT(nextNode.codeOrigin != at(m_compileIndex).codeOrigin);
     1835       
     1836        OSRExit& exit = m_jit.codeBlock()->lastOSRExit();
     1837        exit.m_codeOrigin = nextNode.codeOrigin;
     1838        exit.m_lastSetOperand = setLocal.local();
     1839       
     1840        exit.valueRecoveryForOperand(setLocal.local()) = valueRecovery;
     1841    }
    18261842
    18271843    // Called when we statically determine that a speculation will fail.
Note: See TracChangeset for help on using the changeset viewer.