diff options
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp | 187 |
1 files changed, 95 insertions, 92 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp b/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp index 75f0b7a74..bcb79a96a 100644 --- a/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp +++ b/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp @@ -82,20 +82,20 @@ public: } private: - bool setPrediction(PredictedType prediction) + bool setPrediction(SpeculatedType prediction) { ASSERT(m_graph[m_compileIndex].hasResult()); // setPrediction() is used when we know that there is no way that we can change // our minds about what the prediction is going to be. There is no semantic - // difference between setPrediction() and mergePrediction() other than the + // difference between setPrediction() and mergeSpeculation() other than the // increased checking to validate this property. - ASSERT(m_graph[m_compileIndex].prediction() == PredictNone || m_graph[m_compileIndex].prediction() == prediction); + ASSERT(m_graph[m_compileIndex].prediction() == SpecNone || m_graph[m_compileIndex].prediction() == prediction); return m_graph[m_compileIndex].predict(prediction); } - bool mergePrediction(PredictedType prediction) + bool mergePrediction(SpeculatedType prediction) { ASSERT(m_graph[m_compileIndex].hasResult()); @@ -134,13 +134,13 @@ private: switch (op) { case JSConstant: case WeakJSConstant: { - changed |= setPrediction(predictionFromValue(m_graph.valueOfJSConstant(m_compileIndex))); + changed |= setPrediction(speculationFromValue(m_graph.valueOfJSConstant(m_compileIndex))); break; } case GetLocal: { VariableAccessData* variableAccessData = node.variableAccessData(); - PredictedType prediction = variableAccessData->prediction(); + SpeculatedType prediction = variableAccessData->prediction(); if (prediction) changed |= mergePrediction(prediction); @@ -168,7 +168,7 @@ private: case BitRShift: case BitLShift: case BitURShift: { - changed |= setPrediction(PredictInt32); + changed |= setPrediction(SpecInt32); flags |= NodeUsedAsInt; flags &= ~(NodeUsedAsNumber | NodeNeedsNegZero); changed |= m_graph[node.child1()].mergeFlags(flags); @@ -177,7 +177,7 @@ private: } case ValueToInt32: { - changed |= setPrediction(PredictInt32); + changed |= setPrediction(SpecInt32); flags |= NodeUsedAsInt; flags &= ~(NodeUsedAsNumber | NodeNeedsNegZero); changed |= m_graph[node.child1()].mergeFlags(flags); @@ -205,22 +205,22 @@ private: } case StringCharCodeAt: { - changed |= mergePrediction(PredictInt32); + changed |= mergePrediction(SpecInt32); changed |= m_graph[node.child1()].mergeFlags(NodeUsedAsValue); changed |= m_graph[node.child2()].mergeFlags(NodeUsedAsNumber | NodeUsedAsInt); break; } case ArithMod: { - PredictedType left = m_graph[node.child1()].prediction(); - PredictedType right = m_graph[node.child2()].prediction(); + SpeculatedType left = m_graph[node.child1()].prediction(); + SpeculatedType right = m_graph[node.child2()].prediction(); if (left && right) { - if (isInt32Prediction(mergePredictions(left, right)) + if (isInt32Speculation(mergeSpeculations(left, right)) && nodeCanSpeculateInteger(node.arithNodeFlags())) - changed |= mergePrediction(PredictInt32); + changed |= mergePrediction(SpecInt32); else - changed |= mergePrediction(PredictDouble); + changed |= mergePrediction(SpecDouble); } flags |= NodeUsedAsValue; @@ -231,29 +231,29 @@ private: case UInt32ToNumber: { if (nodeCanSpeculateInteger(node.arithNodeFlags())) - changed |= mergePrediction(PredictInt32); + changed |= mergePrediction(SpecInt32); else - changed |= mergePrediction(PredictNumber); + changed |= mergePrediction(SpecNumber); changed |= m_graph[node.child1()].mergeFlags(flags); break; } case ValueAdd: { - PredictedType left = m_graph[node.child1()].prediction(); - PredictedType right = m_graph[node.child2()].prediction(); + SpeculatedType left = m_graph[node.child1()].prediction(); + SpeculatedType right = m_graph[node.child2()].prediction(); if (left && right) { - if (isNumberPrediction(left) && isNumberPrediction(right)) { + if (isNumberSpeculation(left) && isNumberSpeculation(right)) { if (m_graph.addShouldSpeculateInteger(node)) - changed |= mergePrediction(PredictInt32); + changed |= mergePrediction(SpecInt32); else - changed |= mergePrediction(PredictDouble); - } else if (!(left & PredictNumber) || !(right & PredictNumber)) { + changed |= mergePrediction(SpecDouble); + } else if (!(left & SpecNumber) || !(right & SpecNumber)) { // left or right is definitely something other than a number. - changed |= mergePrediction(PredictString); + changed |= mergePrediction(SpecString); } else - changed |= mergePrediction(PredictString | PredictInt32 | PredictDouble); + changed |= mergePrediction(SpecString | SpecInt32 | SpecDouble); } if (isNotNegZero(node.child1().index()) || isNotNegZero(node.child2().index())) @@ -265,14 +265,14 @@ private: } case ArithAdd: { - PredictedType left = m_graph[node.child1()].prediction(); - PredictedType right = m_graph[node.child2()].prediction(); + SpeculatedType left = m_graph[node.child1()].prediction(); + SpeculatedType right = m_graph[node.child2()].prediction(); if (left && right) { if (m_graph.addShouldSpeculateInteger(node)) - changed |= mergePrediction(PredictInt32); + changed |= mergePrediction(SpecInt32); else - changed |= mergePrediction(PredictDouble); + changed |= mergePrediction(SpecDouble); } if (isNotNegZero(node.child1().index()) || isNotNegZero(node.child2().index())) @@ -284,14 +284,14 @@ private: } case ArithSub: { - PredictedType left = m_graph[node.child1()].prediction(); - PredictedType right = m_graph[node.child2()].prediction(); + SpeculatedType left = m_graph[node.child1()].prediction(); + SpeculatedType right = m_graph[node.child2()].prediction(); if (left && right) { if (m_graph.addShouldSpeculateInteger(node)) - changed |= mergePrediction(PredictInt32); + changed |= mergePrediction(SpecInt32); else - changed |= mergePrediction(PredictDouble); + changed |= mergePrediction(SpecDouble); } if (isNotZero(node.child1().index()) || isNotZero(node.child2().index())) @@ -305,9 +305,9 @@ private: case ArithNegate: if (m_graph[node.child1()].prediction()) { if (m_graph.negateShouldSpeculateInteger(node)) - changed |= mergePrediction(PredictInt32); + changed |= mergePrediction(SpecInt32); else - changed |= mergePrediction(PredictDouble); + changed |= mergePrediction(SpecDouble); } changed |= m_graph[node.child1()].mergeFlags(flags); @@ -315,15 +315,15 @@ private: case ArithMin: case ArithMax: { - PredictedType left = m_graph[node.child1()].prediction(); - PredictedType right = m_graph[node.child2()].prediction(); + SpeculatedType left = m_graph[node.child1()].prediction(); + SpeculatedType right = m_graph[node.child2()].prediction(); if (left && right) { - if (isInt32Prediction(mergePredictions(left, right)) + if (isInt32Speculation(mergeSpeculations(left, right)) && nodeCanSpeculateInteger(node.arithNodeFlags())) - changed |= mergePrediction(PredictInt32); + changed |= mergePrediction(SpecInt32); else - changed |= mergePrediction(PredictDouble); + changed |= mergePrediction(SpecDouble); } flags |= NodeUsedAsNumber; @@ -333,14 +333,14 @@ private: } case ArithMul: { - PredictedType left = m_graph[node.child1()].prediction(); - PredictedType right = m_graph[node.child2()].prediction(); + SpeculatedType left = m_graph[node.child1()].prediction(); + SpeculatedType right = m_graph[node.child2()].prediction(); if (left && right) { if (m_graph.mulShouldSpeculateInteger(node)) - changed |= mergePrediction(PredictInt32); + changed |= mergePrediction(SpecInt32); else - changed |= mergePrediction(PredictDouble); + changed |= mergePrediction(SpecDouble); } // As soon as a multiply happens, we can easily end up in the part @@ -355,15 +355,15 @@ private: } case ArithDiv: { - PredictedType left = m_graph[node.child1()].prediction(); - PredictedType right = m_graph[node.child2()].prediction(); + SpeculatedType left = m_graph[node.child1()].prediction(); + SpeculatedType right = m_graph[node.child2()].prediction(); if (left && right) { - if (isInt32Prediction(mergePredictions(left, right)) + if (isInt32Speculation(mergeSpeculations(left, right)) && nodeCanSpeculateInteger(node.arithNodeFlags())) - changed |= mergePrediction(PredictInt32); + changed |= mergePrediction(SpecInt32); else - changed |= mergePrediction(PredictDouble); + changed |= mergePrediction(SpecDouble); } // As soon as a multiply happens, we can easily end up in the part @@ -378,17 +378,17 @@ private: } case ArithSqrt: { - changed |= setPrediction(PredictDouble); + changed |= setPrediction(SpecDouble); changed |= m_graph[node.child1()].mergeFlags(flags | NodeUsedAsValue); break; } case ArithAbs: { - PredictedType child = m_graph[node.child1()].prediction(); + SpeculatedType child = m_graph[node.child1()].prediction(); if (nodeCanSpeculateInteger(node.arithNodeFlags())) changed |= mergePrediction(child); else - changed |= setPrediction(PredictDouble); + changed |= setPrediction(SpecDouble); flags &= ~NodeNeedsNegZero; changed |= m_graph[node.child1()].mergeFlags(flags); @@ -409,7 +409,7 @@ private: case IsString: case IsObject: case IsFunction: { - changed |= setPrediction(PredictBoolean); + changed |= setPrediction(SpecBoolean); changed |= mergeDefaultFlags(node); break; } @@ -428,7 +428,7 @@ private: case GetByVal: { if (m_graph[node.child1()].shouldSpeculateFloat32Array() || m_graph[node.child1()].shouldSpeculateFloat64Array()) - changed |= mergePrediction(PredictDouble); + changed |= mergePrediction(SpecDouble); else changed |= mergePrediction(node.getHeapPrediction()); @@ -444,13 +444,13 @@ private: } case GetMyArgumentsLengthSafe: { - changed |= setPrediction(PredictInt32); + changed |= setPrediction(SpecInt32); break; } case GetPropertyStorage: case GetIndexedPropertyStorage: { - changed |= setPrediction(PredictOther); + changed |= setPrediction(SpecOther); changed |= mergeDefaultFlags(node); break; } @@ -474,11 +474,11 @@ private: } case ConvertThis: { - PredictedType prediction = m_graph[node.child1()].prediction(); + SpeculatedType prediction = m_graph[node.child1()].prediction(); if (prediction) { - if (prediction & ~PredictObjectMask) { - prediction &= PredictObjectMask; - prediction = mergePredictions(prediction, PredictObjectOther); + if (prediction & ~SpecObjectMask) { + prediction &= SpecObjectMask; + prediction = mergeSpeculations(prediction, SpecObjectOther); } changed |= mergePrediction(prediction); } @@ -491,7 +491,8 @@ private: break; } - case PutGlobalVar: { + case PutGlobalVar: + case PutGlobalVarCheck: { changed |= m_graph[node.child1()].mergeFlags(NodeUsedAsValue); break; } @@ -501,30 +502,30 @@ private: case ResolveBase: case ResolveBaseStrictPut: case ResolveGlobal: { - PredictedType prediction = node.getHeapPrediction(); + SpeculatedType prediction = node.getHeapPrediction(); changed |= mergePrediction(prediction); break; } case GetScopeChain: { - changed |= setPrediction(PredictCellOther); + changed |= setPrediction(SpecCellOther); break; } case GetCallee: { - changed |= setPrediction(PredictFunction); + changed |= setPrediction(SpecFunction); break; } case CreateThis: case NewObject: { - changed |= setPrediction(PredictFinalObject); + changed |= setPrediction(SpecFinalObject); changed |= mergeDefaultFlags(node); break; } case NewArray: { - changed |= setPrediction(PredictArray); + changed |= setPrediction(SpecArray); for (unsigned childIdx = node.firstChild(); childIdx < node.firstChild() + node.numChildren(); ++childIdx) { @@ -535,24 +536,24 @@ private: } case NewArrayBuffer: { - changed |= setPrediction(PredictArray); + changed |= setPrediction(SpecArray); break; } case NewRegexp: { - changed |= setPrediction(PredictObjectOther); + changed |= setPrediction(SpecObjectOther); break; } case StringCharAt: { - changed |= setPrediction(PredictString); + changed |= setPrediction(SpecString); changed |= m_graph[node.child1()].mergeFlags(NodeUsedAsValue); changed |= m_graph[node.child2()].mergeFlags(NodeUsedAsNumber | NodeUsedAsInt); break; } case StrCat: { - changed |= setPrediction(PredictString); + changed |= setPrediction(SpecString); for (unsigned childIdx = node.firstChild(); childIdx < node.firstChild() + node.numChildren(); ++childIdx) @@ -561,20 +562,20 @@ private: } case ToPrimitive: { - PredictedType child = m_graph[node.child1()].prediction(); + SpeculatedType child = m_graph[node.child1()].prediction(); if (child) { - if (isObjectPrediction(child)) { + if (isObjectSpeculation(child)) { // I'd love to fold this case into the case below, but I can't, because - // removing PredictObjectMask from something that only has an object - // prediction and nothing else means we have an ill-formed PredictedType + // removing SpecObjectMask from something that only has an object + // prediction and nothing else means we have an ill-formed SpeculatedType // (strong predict-none). This should be killed once we remove all traces // of static (aka weak) predictions. - changed |= mergePrediction(PredictString); - } else if (child & PredictObjectMask) { + changed |= mergePrediction(SpecString); + } else if (child & SpecObjectMask) { // Objects get turned into strings. So if the input has hints of objectness, // the output will have hinsts of stringiness. changed |= mergePrediction( - mergePredictions(child & ~PredictObjectMask, PredictString)); + mergeSpeculations(child & ~SpecObjectMask, SpecString)); } else changed |= mergePrediction(child); } @@ -583,21 +584,21 @@ private: } case CreateActivation: { - changed |= setPrediction(PredictObjectOther); + changed |= setPrediction(SpecObjectOther); break; } case CreateArguments: { // At this stage we don't try to predict whether the arguments are ours or // someone else's. We could, but we don't, yet. - changed |= setPrediction(PredictArguments); + changed |= setPrediction(SpecArguments); break; } case NewFunction: case NewFunctionNoCheck: case NewFunctionExpression: { - changed |= setPrediction(PredictFunction); + changed |= setPrediction(SpecFunction); break; } @@ -663,12 +664,14 @@ private: case ForceOSRExit: case SetArgument: case CheckStructure: + case StructureTransitionWatchpoint: case CheckFunction: case PutStructure: case TearOffActivation: case TearOffArguments: case CheckNumber: case CheckArgumentsNotCreated: + case GlobalVarWatchpoint: changed |= mergeDefaultFlags(node); break; @@ -689,7 +692,7 @@ private: } #if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE) - dataLog("%s\n", predictionToString(m_graph[m_compileIndex].prediction())); + dataLog("%s\n", speculationToString(m_graph[m_compileIndex].prediction())); #endif m_changed |= changed; @@ -784,12 +787,12 @@ private: case ValueAdd: case ArithAdd: case ArithSub: { - PredictedType left = m_graph[node.child1()].prediction(); - PredictedType right = m_graph[node.child2()].prediction(); + SpeculatedType left = m_graph[node.child1()].prediction(); + SpeculatedType right = m_graph[node.child2()].prediction(); VariableAccessData::Ballot ballot; - if (isNumberPrediction(left) && isNumberPrediction(right) + if (isNumberSpeculation(left) && isNumberSpeculation(right) && !m_graph.addShouldSpeculateInteger(node)) ballot = VariableAccessData::VoteDouble; else @@ -801,12 +804,12 @@ private: } case ArithMul: { - PredictedType left = m_graph[node.child1()].prediction(); - PredictedType right = m_graph[node.child2()].prediction(); + SpeculatedType left = m_graph[node.child1()].prediction(); + SpeculatedType right = m_graph[node.child2()].prediction(); VariableAccessData::Ballot ballot; - if (isNumberPrediction(left) && isNumberPrediction(right) + if (isNumberSpeculation(left) && isNumberSpeculation(right) && !m_graph.mulShouldSpeculateInteger(node)) ballot = VariableAccessData::VoteDouble; else @@ -821,12 +824,12 @@ private: case ArithMax: case ArithMod: case ArithDiv: { - PredictedType left = m_graph[node.child1()].prediction(); - PredictedType right = m_graph[node.child2()].prediction(); + SpeculatedType left = m_graph[node.child1()].prediction(); + SpeculatedType right = m_graph[node.child2()].prediction(); VariableAccessData::Ballot ballot; - if (isNumberPrediction(left) && isNumberPrediction(right) + if (isNumberSpeculation(left) && isNumberSpeculation(right) && !(Node::shouldSpeculateInteger(m_graph[node.child1()], m_graph[node.child1()]) && node.canSpeculateInteger())) ballot = VariableAccessData::VoteDouble; @@ -854,10 +857,10 @@ private: break; case SetLocal: { - PredictedType prediction = m_graph[node.child1()].prediction(); - if (isDoublePrediction(prediction)) + SpeculatedType prediction = m_graph[node.child1()].prediction(); + if (isDoubleSpeculation(prediction)) node.variableAccessData()->vote(VariableAccessData::VoteDouble); - else if (!isNumberPrediction(prediction) || isInt32Prediction(prediction)) + else if (!isNumberSpeculation(prediction) || isInt32Speculation(prediction)) node.variableAccessData()->vote(VariableAccessData::VoteValue); break; } |