Changeset 119660 in webkit for trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
- Timestamp:
- Jun 6, 2012, 6:35:59 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
r118579 r119660 83 83 84 84 private: 85 bool setPrediction( PredictedType prediction)85 bool setPrediction(SpeculatedType prediction) 86 86 { 87 87 ASSERT(m_graph[m_compileIndex].hasResult()); … … 89 89 // setPrediction() is used when we know that there is no way that we can change 90 90 // our minds about what the prediction is going to be. There is no semantic 91 // difference between setPrediction() and merge Prediction() other than the91 // difference between setPrediction() and mergeSpeculation() other than the 92 92 // increased checking to validate this property. 93 ASSERT(m_graph[m_compileIndex].prediction() == PredictNone || m_graph[m_compileIndex].prediction() == prediction);93 ASSERT(m_graph[m_compileIndex].prediction() == SpecNone || m_graph[m_compileIndex].prediction() == prediction); 94 94 95 95 return m_graph[m_compileIndex].predict(prediction); 96 96 } 97 97 98 bool mergePrediction( PredictedType prediction)98 bool mergePrediction(SpeculatedType prediction) 99 99 { 100 100 ASSERT(m_graph[m_compileIndex].hasResult()); … … 135 135 case JSConstant: 136 136 case WeakJSConstant: { 137 changed |= setPrediction( predictionFromValue(m_graph.valueOfJSConstant(m_compileIndex)));137 changed |= setPrediction(speculationFromValue(m_graph.valueOfJSConstant(m_compileIndex))); 138 138 break; 139 139 } … … 141 141 case GetLocal: { 142 142 VariableAccessData* variableAccessData = node.variableAccessData(); 143 PredictedType prediction = variableAccessData->prediction();143 SpeculatedType prediction = variableAccessData->prediction(); 144 144 if (prediction) 145 145 changed |= mergePrediction(prediction); … … 169 169 case BitLShift: 170 170 case BitURShift: { 171 changed |= setPrediction( PredictInt32);171 changed |= setPrediction(SpecInt32); 172 172 flags |= NodeUsedAsInt; 173 173 flags &= ~(NodeUsedAsNumber | NodeNeedsNegZero); … … 178 178 179 179 case ValueToInt32: { 180 changed |= setPrediction( PredictInt32);180 changed |= setPrediction(SpecInt32); 181 181 flags |= NodeUsedAsInt; 182 182 flags &= ~(NodeUsedAsNumber | NodeNeedsNegZero); … … 206 206 207 207 case StringCharCodeAt: { 208 changed |= mergePrediction( PredictInt32);208 changed |= mergePrediction(SpecInt32); 209 209 changed |= m_graph[node.child1()].mergeFlags(NodeUsedAsValue); 210 210 changed |= m_graph[node.child2()].mergeFlags(NodeUsedAsNumber | NodeUsedAsInt); … … 213 213 214 214 case ArithMod: { 215 PredictedType left = m_graph[node.child1()].prediction();216 PredictedType right = m_graph[node.child2()].prediction();215 SpeculatedType left = m_graph[node.child1()].prediction(); 216 SpeculatedType right = m_graph[node.child2()].prediction(); 217 217 218 218 if (left && right) { 219 if (isInt32 Prediction(mergePredictions(left, right))219 if (isInt32Speculation(mergeSpeculations(left, right)) 220 220 && nodeCanSpeculateInteger(node.arithNodeFlags())) 221 changed |= mergePrediction( PredictInt32);222 else 223 changed |= mergePrediction( PredictDouble);221 changed |= mergePrediction(SpecInt32); 222 else 223 changed |= mergePrediction(SpecDouble); 224 224 } 225 225 … … 232 232 case UInt32ToNumber: { 233 233 if (nodeCanSpeculateInteger(node.arithNodeFlags())) 234 changed |= mergePrediction( PredictInt32);234 changed |= mergePrediction(SpecInt32); 235 235 else 236 changed |= mergePrediction( PredictNumber);236 changed |= mergePrediction(SpecNumber); 237 237 238 238 changed |= m_graph[node.child1()].mergeFlags(flags); … … 241 241 242 242 case ValueAdd: { 243 PredictedType left = m_graph[node.child1()].prediction();244 PredictedType right = m_graph[node.child2()].prediction();243 SpeculatedType left = m_graph[node.child1()].prediction(); 244 SpeculatedType right = m_graph[node.child2()].prediction(); 245 245 246 246 if (left && right) { 247 if (isNumber Prediction(left) && isNumberPrediction(right)) {247 if (isNumberSpeculation(left) && isNumberSpeculation(right)) { 248 248 if (m_graph.addShouldSpeculateInteger(node)) 249 changed |= mergePrediction( PredictInt32);249 changed |= mergePrediction(SpecInt32); 250 250 else 251 changed |= mergePrediction( PredictDouble);252 } else if (!(left & PredictNumber) || !(right & PredictNumber)) {251 changed |= mergePrediction(SpecDouble); 252 } else if (!(left & SpecNumber) || !(right & SpecNumber)) { 253 253 // left or right is definitely something other than a number. 254 changed |= mergePrediction( PredictString);254 changed |= mergePrediction(SpecString); 255 255 } else 256 changed |= mergePrediction( PredictString | PredictInt32 | PredictDouble);256 changed |= mergePrediction(SpecString | SpecInt32 | SpecDouble); 257 257 } 258 258 … … 266 266 267 267 case ArithAdd: { 268 PredictedType left = m_graph[node.child1()].prediction();269 PredictedType right = m_graph[node.child2()].prediction();268 SpeculatedType left = m_graph[node.child1()].prediction(); 269 SpeculatedType right = m_graph[node.child2()].prediction(); 270 270 271 271 if (left && right) { 272 272 if (m_graph.addShouldSpeculateInteger(node)) 273 changed |= mergePrediction( PredictInt32);274 else 275 changed |= mergePrediction( PredictDouble);273 changed |= mergePrediction(SpecInt32); 274 else 275 changed |= mergePrediction(SpecDouble); 276 276 } 277 277 … … 285 285 286 286 case ArithSub: { 287 PredictedType left = m_graph[node.child1()].prediction();288 PredictedType right = m_graph[node.child2()].prediction();287 SpeculatedType left = m_graph[node.child1()].prediction(); 288 SpeculatedType right = m_graph[node.child2()].prediction(); 289 289 290 290 if (left && right) { 291 291 if (m_graph.addShouldSpeculateInteger(node)) 292 changed |= mergePrediction( PredictInt32);293 else 294 changed |= mergePrediction( PredictDouble);292 changed |= mergePrediction(SpecInt32); 293 else 294 changed |= mergePrediction(SpecDouble); 295 295 } 296 296 … … 306 306 if (m_graph[node.child1()].prediction()) { 307 307 if (m_graph.negateShouldSpeculateInteger(node)) 308 changed |= mergePrediction( PredictInt32);309 else 310 changed |= mergePrediction( PredictDouble);308 changed |= mergePrediction(SpecInt32); 309 else 310 changed |= mergePrediction(SpecDouble); 311 311 } 312 312 … … 316 316 case ArithMin: 317 317 case ArithMax: { 318 PredictedType left = m_graph[node.child1()].prediction();319 PredictedType right = m_graph[node.child2()].prediction();318 SpeculatedType left = m_graph[node.child1()].prediction(); 319 SpeculatedType right = m_graph[node.child2()].prediction(); 320 320 321 321 if (left && right) { 322 if (isInt32 Prediction(mergePredictions(left, right))322 if (isInt32Speculation(mergeSpeculations(left, right)) 323 323 && nodeCanSpeculateInteger(node.arithNodeFlags())) 324 changed |= mergePrediction( PredictInt32);325 else 326 changed |= mergePrediction( PredictDouble);324 changed |= mergePrediction(SpecInt32); 325 else 326 changed |= mergePrediction(SpecDouble); 327 327 } 328 328 … … 334 334 335 335 case ArithMul: { 336 PredictedType left = m_graph[node.child1()].prediction();337 PredictedType right = m_graph[node.child2()].prediction();336 SpeculatedType left = m_graph[node.child1()].prediction(); 337 SpeculatedType right = m_graph[node.child2()].prediction(); 338 338 339 339 if (left && right) { 340 340 if (m_graph.mulShouldSpeculateInteger(node)) 341 changed |= mergePrediction( PredictInt32);342 else 343 changed |= mergePrediction( PredictDouble);341 changed |= mergePrediction(SpecInt32); 342 else 343 changed |= mergePrediction(SpecDouble); 344 344 } 345 345 … … 356 356 357 357 case ArithDiv: { 358 PredictedType left = m_graph[node.child1()].prediction();359 PredictedType right = m_graph[node.child2()].prediction();358 SpeculatedType left = m_graph[node.child1()].prediction(); 359 SpeculatedType right = m_graph[node.child2()].prediction(); 360 360 361 361 if (left && right) { 362 if (isInt32 Prediction(mergePredictions(left, right))362 if (isInt32Speculation(mergeSpeculations(left, right)) 363 363 && nodeCanSpeculateInteger(node.arithNodeFlags())) 364 changed |= mergePrediction( PredictInt32);365 else 366 changed |= mergePrediction( PredictDouble);364 changed |= mergePrediction(SpecInt32); 365 else 366 changed |= mergePrediction(SpecDouble); 367 367 } 368 368 … … 379 379 380 380 case ArithSqrt: { 381 changed |= setPrediction( PredictDouble);381 changed |= setPrediction(SpecDouble); 382 382 changed |= m_graph[node.child1()].mergeFlags(flags | NodeUsedAsValue); 383 383 break; … … 385 385 386 386 case ArithAbs: { 387 PredictedType child = m_graph[node.child1()].prediction();387 SpeculatedType child = m_graph[node.child1()].prediction(); 388 388 if (nodeCanSpeculateInteger(node.arithNodeFlags())) 389 389 changed |= mergePrediction(child); 390 390 else 391 changed |= setPrediction( PredictDouble);391 changed |= setPrediction(SpecDouble); 392 392 393 393 flags &= ~NodeNeedsNegZero; … … 410 410 case IsObject: 411 411 case IsFunction: { 412 changed |= setPrediction( PredictBoolean);412 changed |= setPrediction(SpecBoolean); 413 413 changed |= mergeDefaultFlags(node); 414 414 break; … … 429 429 if (m_graph[node.child1()].shouldSpeculateFloat32Array() 430 430 || m_graph[node.child1()].shouldSpeculateFloat64Array()) 431 changed |= mergePrediction( PredictDouble);431 changed |= mergePrediction(SpecDouble); 432 432 else 433 433 changed |= mergePrediction(node.getHeapPrediction()); … … 445 445 446 446 case GetMyArgumentsLengthSafe: { 447 changed |= setPrediction( PredictInt32);447 changed |= setPrediction(SpecInt32); 448 448 break; 449 449 } … … 451 451 case GetPropertyStorage: 452 452 case GetIndexedPropertyStorage: { 453 changed |= setPrediction( PredictOther);453 changed |= setPrediction(SpecOther); 454 454 changed |= mergeDefaultFlags(node); 455 455 break; … … 475 475 476 476 case ConvertThis: { 477 PredictedType prediction = m_graph[node.child1()].prediction();477 SpeculatedType prediction = m_graph[node.child1()].prediction(); 478 478 if (prediction) { 479 if (prediction & ~ PredictObjectMask) {480 prediction &= PredictObjectMask;481 prediction = merge Predictions(prediction, PredictObjectOther);479 if (prediction & ~SpecObjectMask) { 480 prediction &= SpecObjectMask; 481 prediction = mergeSpeculations(prediction, SpecObjectOther); 482 482 } 483 483 changed |= mergePrediction(prediction); … … 502 502 case ResolveBaseStrictPut: 503 503 case ResolveGlobal: { 504 PredictedType prediction = node.getHeapPrediction();504 SpeculatedType prediction = node.getHeapPrediction(); 505 505 changed |= mergePrediction(prediction); 506 506 break; … … 508 508 509 509 case GetScopeChain: { 510 changed |= setPrediction( PredictCellOther);510 changed |= setPrediction(SpecCellOther); 511 511 break; 512 512 } 513 513 514 514 case GetCallee: { 515 changed |= setPrediction( PredictFunction);515 changed |= setPrediction(SpecFunction); 516 516 break; 517 517 } … … 519 519 case CreateThis: 520 520 case NewObject: { 521 changed |= setPrediction( PredictFinalObject);521 changed |= setPrediction(SpecFinalObject); 522 522 changed |= mergeDefaultFlags(node); 523 523 break; … … 525 525 526 526 case NewArray: { 527 changed |= setPrediction( PredictArray);527 changed |= setPrediction(SpecArray); 528 528 for (unsigned childIdx = node.firstChild(); 529 529 childIdx < node.firstChild() + node.numChildren(); … … 536 536 537 537 case NewArrayBuffer: { 538 changed |= setPrediction( PredictArray);538 changed |= setPrediction(SpecArray); 539 539 break; 540 540 } 541 541 542 542 case NewRegexp: { 543 changed |= setPrediction( PredictObjectOther);543 changed |= setPrediction(SpecObjectOther); 544 544 break; 545 545 } 546 546 547 547 case StringCharAt: { 548 changed |= setPrediction( PredictString);548 changed |= setPrediction(SpecString); 549 549 changed |= m_graph[node.child1()].mergeFlags(NodeUsedAsValue); 550 550 changed |= m_graph[node.child2()].mergeFlags(NodeUsedAsNumber | NodeUsedAsInt); … … 553 553 554 554 case StrCat: { 555 changed |= setPrediction( PredictString);555 changed |= setPrediction(SpecString); 556 556 for (unsigned childIdx = node.firstChild(); 557 557 childIdx < node.firstChild() + node.numChildren(); … … 562 562 563 563 case ToPrimitive: { 564 PredictedType child = m_graph[node.child1()].prediction();564 SpeculatedType child = m_graph[node.child1()].prediction(); 565 565 if (child) { 566 if (isObject Prediction(child)) {566 if (isObjectSpeculation(child)) { 567 567 // I'd love to fold this case into the case below, but I can't, because 568 // removing PredictObjectMask from something that only has an object569 // prediction and nothing else means we have an ill-formed PredictedType568 // removing SpecObjectMask from something that only has an object 569 // prediction and nothing else means we have an ill-formed SpeculatedType 570 570 // (strong predict-none). This should be killed once we remove all traces 571 571 // of static (aka weak) predictions. 572 changed |= mergePrediction( PredictString);573 } else if (child & PredictObjectMask) {572 changed |= mergePrediction(SpecString); 573 } else if (child & SpecObjectMask) { 574 574 // Objects get turned into strings. So if the input has hints of objectness, 575 575 // the output will have hinsts of stringiness. 576 576 changed |= mergePrediction( 577 merge Predictions(child & ~PredictObjectMask, PredictString));577 mergeSpeculations(child & ~SpecObjectMask, SpecString)); 578 578 } else 579 579 changed |= mergePrediction(child); … … 584 584 585 585 case CreateActivation: { 586 changed |= setPrediction( PredictObjectOther);586 changed |= setPrediction(SpecObjectOther); 587 587 break; 588 588 } … … 591 591 // At this stage we don't try to predict whether the arguments are ours or 592 592 // someone else's. We could, but we don't, yet. 593 changed |= setPrediction( PredictArguments);593 changed |= setPrediction(SpecArguments); 594 594 break; 595 595 } … … 598 598 case NewFunctionNoCheck: 599 599 case NewFunctionExpression: { 600 changed |= setPrediction( PredictFunction);600 changed |= setPrediction(SpecFunction); 601 601 break; 602 602 } … … 690 690 691 691 #if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE) 692 dataLog("%s\n", predictionToString(m_graph[m_compileIndex].prediction()));692 dataLog("%s\n", speculationToString(m_graph[m_compileIndex].prediction())); 693 693 #endif 694 694 … … 785 785 case ArithAdd: 786 786 case ArithSub: { 787 PredictedType left = m_graph[node.child1()].prediction();788 PredictedType right = m_graph[node.child2()].prediction();787 SpeculatedType left = m_graph[node.child1()].prediction(); 788 SpeculatedType right = m_graph[node.child2()].prediction(); 789 789 790 790 VariableAccessData::Ballot ballot; 791 791 792 if (isNumber Prediction(left) && isNumberPrediction(right)792 if (isNumberSpeculation(left) && isNumberSpeculation(right) 793 793 && !m_graph.addShouldSpeculateInteger(node)) 794 794 ballot = VariableAccessData::VoteDouble; … … 802 802 803 803 case ArithMul: { 804 PredictedType left = m_graph[node.child1()].prediction();805 PredictedType right = m_graph[node.child2()].prediction();804 SpeculatedType left = m_graph[node.child1()].prediction(); 805 SpeculatedType right = m_graph[node.child2()].prediction(); 806 806 807 807 VariableAccessData::Ballot ballot; 808 808 809 if (isNumber Prediction(left) && isNumberPrediction(right)809 if (isNumberSpeculation(left) && isNumberSpeculation(right) 810 810 && !m_graph.mulShouldSpeculateInteger(node)) 811 811 ballot = VariableAccessData::VoteDouble; … … 822 822 case ArithMod: 823 823 case ArithDiv: { 824 PredictedType left = m_graph[node.child1()].prediction();825 PredictedType right = m_graph[node.child2()].prediction();824 SpeculatedType left = m_graph[node.child1()].prediction(); 825 SpeculatedType right = m_graph[node.child2()].prediction(); 826 826 827 827 VariableAccessData::Ballot ballot; 828 828 829 if (isNumber Prediction(left) && isNumberPrediction(right)829 if (isNumberSpeculation(left) && isNumberSpeculation(right) 830 830 && !(Node::shouldSpeculateInteger(m_graph[node.child1()], m_graph[node.child1()]) 831 831 && node.canSpeculateInteger())) … … 855 855 856 856 case SetLocal: { 857 PredictedType prediction = m_graph[node.child1()].prediction();858 if (isDouble Prediction(prediction))857 SpeculatedType prediction = m_graph[node.child1()].prediction(); 858 if (isDoubleSpeculation(prediction)) 859 859 node.variableAccessData()->vote(VariableAccessData::VoteDouble); 860 else if (!isNumber Prediction(prediction) || isInt32Prediction(prediction))860 else if (!isNumberSpeculation(prediction) || isInt32Speculation(prediction)) 861 861 node.variableAccessData()->vote(VariableAccessData::VoteValue); 862 862 break;
Note:
See TracChangeset
for help on using the changeset viewer.