Changeset 156019 in webkit for trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
- Timestamp:
- Sep 17, 2013, 6:31:04 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
r155593 r156019 65 65 } 66 66 67 for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex) 68 fixupUntypedSetLocalsInBlock(m_graph.block(blockIndex)); 69 67 70 return true; 68 71 } … … 93 96 case SetLocal: { 94 97 // This gets handled by fixupSetLocalsInBlock(). 95 break;98 return; 96 99 } 97 100 … … 125 128 } 126 129 130 if (node->child1()->shouldSpeculateMachineInt()) { 131 fixEdge<MachineIntUse>(node->child1()); 132 break; 133 } 134 127 135 if (node->child1()->shouldSpeculateNumber()) { 128 136 fixEdge<NumberUse>(node->child1()); … … 198 206 break; 199 207 } 208 if (m_graph.negateShouldSpeculateMachineInt(node)) { 209 fixEdge<MachineIntUse>(node->child1()); 210 break; 211 } 200 212 fixEdge<NumberUse>(node->child1()); 201 213 break; … … 206 218 fixEdge<Int32Use>(node->child1()); 207 219 fixEdge<Int32Use>(node->child2()); 220 break; 221 } 222 if (m_graph.mulShouldSpeculateMachineInt(node)) { 223 fixEdge<MachineIntUse>(node->child1()); 224 fixEdge<MachineIntUse>(node->child2()); 208 225 break; 209 226 } … … 301 318 break; 302 319 } 320 if (enableInt52() 321 && Node::shouldSpeculateMachineInt(node->child1().node(), node->child2().node())) { 322 fixEdge<MachineIntUse>(node->child1()); 323 fixEdge<MachineIntUse>(node->child2()); 324 break; 325 } 303 326 if (Node::shouldSpeculateNumber(node->child1().node(), node->child2().node())) { 304 327 fixEdge<NumberUse>(node->child1()); … … 354 377 fixEdge<Int32Use>(node->child1()); 355 378 fixEdge<Int32Use>(node->child2()); 379 break; 380 } 381 if (enableInt52() 382 && Node::shouldSpeculateMachineInt(node->child1().node(), node->child2().node())) { 383 fixEdge<MachineIntUse>(node->child1()); 384 fixEdge<MachineIntUse>(node->child2()); 356 385 break; 357 386 } … … 477 506 fixEdge<Int32Use>(child2); 478 507 fixEdge<Int32Use>(child3); 508 if (child3->prediction() & SpecInt52) 509 fixEdge<MachineIntUse>(child3); 510 else 511 fixEdge<Int32Use>(child3); 479 512 break; 480 513 case Array::Double: … … 494 527 if (child3->shouldSpeculateInt32()) 495 528 fixEdge<Int32Use>(child3); 529 else if (child3->shouldSpeculateMachineInt()) 530 fixEdge<MachineIntUse>(child3); 496 531 else 497 532 fixEdge<NumberUse>(child3); … … 848 883 case CheckTierUpAtReturn: 849 884 case CheckTierUpAndOSREnter: 885 case Int52ToDouble: 886 case Int52ToValue: 850 887 RELEASE_ASSERT_NOT_REACHED(); 851 888 break; … … 1190 1227 fixEdge<Int32Use>(node->child1()); 1191 1228 break; 1229 case FlushedInt52: 1230 fixEdge<MachineIntUse>(node->child1()); 1231 break; 1192 1232 case FlushedCell: 1193 1233 fixEdge<CellUse>(node->child1()); … … 1200 1240 break; 1201 1241 } 1242 } 1243 m_insertionSet.execute(block); 1244 } 1245 1246 void fixupUntypedSetLocalsInBlock(BasicBlock* block) 1247 { 1248 if (!block) 1249 return; 1250 ASSERT(block->isReachable); 1251 m_block = block; 1252 for (m_indexInBlock = 0; m_indexInBlock < block->size(); ++m_indexInBlock) { 1253 Node* node = m_currentNode = block->at(m_indexInBlock); 1254 if (node->op() != SetLocal) 1255 continue; 1256 1257 if (node->child1().useKind() == UntypedUse) 1258 fixEdge<UntypedUse>(node->child1()); 1202 1259 } 1203 1260 m_insertionSet.execute(block); … … 1305 1362 return; 1306 1363 1364 // FIXME: The way this uses alwaysUnboxSimplePrimitives() is suspicious. 1365 // https://bugs.webkit.org/show_bug.cgi?id=121518 1366 1307 1367 VariableAccessData* variable = node->variableAccessData(); 1308 1368 switch (useKind) { … … 1320 1380 if (alwaysUnboxSimplePrimitives() 1321 1381 || isBooleanSpeculation(variable->prediction())) 1382 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true); 1383 break; 1384 case MachineIntUse: 1385 if (isMachineIntSpeculation(variable->prediction())) 1322 1386 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true); 1323 1387 break; … … 1348 1412 void fixEdge(Edge& edge, SpeculationDirection direction = BackwardSpeculation) 1349 1413 { 1350 if (isDouble(useKind) && edge->shouldSpeculateInt32ForArithmetic()) { 1351 injectInt32ToDoubleNode(edge, useKind, direction); 1414 if (isDouble(useKind)) { 1415 if (edge->shouldSpeculateInt32ForArithmetic()) { 1416 injectInt32ToDoubleNode(edge, useKind, direction); 1417 return; 1418 } 1419 1420 if (enableInt52() && edge->shouldSpeculateMachineInt()) { 1421 // Make all double uses of int52 values have an intermediate Int52ToDouble. 1422 // This is for the same reason as Int52ToValue (see below) except that 1423 // Int8ToDouble will convert int52's that fit in an int32 into a double 1424 // rather than trying to create a boxed int32 like Int52ToValue does. 1425 1426 Node* result = m_insertionSet.insertNode( 1427 m_indexInBlock, SpecInt52AsDouble, Int52ToDouble, 1428 m_currentNode->codeOrigin, Edge(edge.node(), NumberUse)); 1429 edge = Edge(result, useKind); 1430 return; 1431 } 1432 } 1433 1434 if (enableInt52() && useKind != MachineIntUse 1435 && edge->shouldSpeculateMachineInt() && !edge->shouldSpeculateInt32()) { 1436 // We make all non-int52 uses of int52 values have an intermediate Int52ToValue 1437 // node to ensure that we handle this properly: 1438 // 1439 // a: SomeInt52 1440 // b: ArithAdd(@a, ...) 1441 // c: Call(..., @a) 1442 // d: ArithAdd(@a, ...) 1443 // 1444 // Without an intermediate node and just labeling the uses, we will get: 1445 // 1446 // a: SomeInt52 1447 // b: ArithAdd(Int52:@a, ...) 1448 // c: Call(..., Untyped:@a) 1449 // d: ArithAdd(Int52:@a, ...) 1450 // 1451 // And now the c->Untyped:@a edge will box the value of @a into a double. This 1452 // is bad, because now the d->Int52:@a edge will either have to do double-to-int 1453 // conversions, or will have to OSR exit unconditionally. Alternatively we could 1454 // have the c->Untyped:@a edge box the value by copying rather than in-place. 1455 // But these boxings are also costly so this wouldn't be great. 1456 // 1457 // The solution we use is to always have non-Int52 uses of predicted Int52's use 1458 // an intervening Int52ToValue node: 1459 // 1460 // a: SomeInt52 1461 // b: ArithAdd(Int52:@a, ...) 1462 // x: Int52ToValue(Int52:@a) 1463 // c: Call(..., Untyped:@x) 1464 // d: ArithAdd(Int52:@a, ...) 1465 // 1466 // Note that even if we had multiple non-int52 uses of @a, the multiple 1467 // Int52ToValue's would get CSE'd together. So the boxing would only happen once. 1468 // At the same time, @a would continue to be represented as a native int52. 1469 // 1470 // An alternative would have been to insert ToNativeInt52 nodes on int52 uses of 1471 // int52's. This would have handled the above example but would fall over for: 1472 // 1473 // a: SomeInt52 1474 // b: Call(..., @a) 1475 // c: ArithAdd(@a, ...) 1476 // 1477 // But the solution we use handles the above gracefully. 1478 1479 Node* result = m_insertionSet.insertNode( 1480 m_indexInBlock, SpecInt52, Int52ToValue, 1481 m_currentNode->codeOrigin, Edge(edge.node(), UntypedUse)); 1482 edge = Edge(result, useKind); 1352 1483 return; 1353 1484 } 1354 1485 1355 1486 observeUseKindOnNode<useKind>(edge.node()); 1487 1356 1488 edge.setUseKind(useKind); 1357 1489 } … … 1379 1511 { 1380 1512 Node* result = m_insertionSet.insertNode( 1381 m_indexInBlock, SpecInt 48, Int32ToDouble,1513 m_indexInBlock, SpecInt52AsDouble, Int32ToDouble, 1382 1514 m_currentNode->codeOrigin, Edge(edge.node(), NumberUse)); 1383 1515 if (direction == ForwardSpeculation) … … 1435 1567 { 1436 1568 AddSpeculationMode mode = m_graph.addSpeculationMode(node); 1437 if (mode == DontSpeculateInt32) 1438 return false; 1439 1440 truncateConstantsIfNecessary(node, mode); 1441 fixEdge<Int32Use>(node->child1()); 1442 fixEdge<Int32Use>(node->child2()); 1443 return true; 1569 if (mode != DontSpeculateInt32) { 1570 truncateConstantsIfNecessary(node, mode); 1571 fixEdge<Int32Use>(node->child1()); 1572 fixEdge<Int32Use>(node->child2()); 1573 return true; 1574 } 1575 1576 if (m_graph.addShouldSpeculateMachineInt(node)) { 1577 fixEdge<MachineIntUse>(node->child1()); 1578 fixEdge<MachineIntUse>(node->child2()); 1579 return true; 1580 } 1581 1582 return false; 1444 1583 } 1445 1584
Note:
See TracChangeset
for help on using the changeset viewer.