533 for (Node usage : currentNode.usages()) {
534 if (immutableGraph && !visited.contains(usage)) {
535 /*
536 * Normally, dead nodes are deleted by the scheduler before we reach this
537 * point. Only when the scheduler is asked to not modify a graph, we can see
538 * dead nodes here.
539 */
540 continue;
541 }
542 latestBlock = calcBlockForUsage(currentNode, usage, latestBlock, currentNodeMap);
543 }
544
545 assert latestBlock != null : currentNode;
546
547 if (strategy == SchedulingStrategy.FINAL_SCHEDULE || strategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS) {
548 Block currentBlock = latestBlock;
549 while (currentBlock.getLoopDepth() > earliestBlock.getLoopDepth() && currentBlock != earliestBlock.getDominator()) {
550 Block previousCurrentBlock = currentBlock;
551 currentBlock = currentBlock.getDominator();
552 if (previousCurrentBlock.isLoopHeader()) {
553 if (currentBlock.probability() < latestBlock.probability() || ((StructuredGraph) currentNode.graph()).hasValueProxies()) {
554 // Only assign new latest block if frequency is actually lower or if
555 // loop proxies would be required otherwise.
556 latestBlock = currentBlock;
557 }
558 }
559 }
560 }
561
562 if (latestBlock != earliestBlock && latestBlock != earliestBlock.getDominator() && constrainingLocation != null) {
563 latestBlock = checkKillsBetween(earliestBlock, latestBlock, constrainingLocation);
564 }
565 }
566
567 if (latestBlock != earliestBlock && currentNode instanceof FloatingReadNode) {
568
569 FloatingReadNode floatingReadNode = (FloatingReadNode) currentNode;
570 if (isImplicitNullOpportunity(floatingReadNode, earliestBlock) && earliestBlock.probability() < latestBlock.probability() * IMPLICIT_NULL_CHECK_OPPORTUNITY_PROBABILITY_FACTOR) {
571 latestBlock = earliestBlock;
572 }
573 }
574
575 selectLatestBlock(currentNode, earliestBlock, latestBlock, currentNodeMap, watchListMap, constrainingLocation, latestBlockToNodesMap);
576 }
577
578 private static boolean isImplicitNullOpportunity(FloatingReadNode floatingReadNode, Block block) {
579
580 Node pred = block.getBeginNode().predecessor();
581 if (pred instanceof IfNode) {
582 IfNode ifNode = (IfNode) pred;
583 if (ifNode.condition() instanceof IsNullNode) {
584 IsNullNode isNullNode = (IsNullNode) ifNode.condition();
585 if (getUnproxifiedUncompressed(floatingReadNode.getAddress().getBase()) == getUnproxifiedUncompressed(isNullNode.getValue())) {
586 return true;
587 }
588 }
589 }
590 return false;
|
533 for (Node usage : currentNode.usages()) {
534 if (immutableGraph && !visited.contains(usage)) {
535 /*
536 * Normally, dead nodes are deleted by the scheduler before we reach this
537 * point. Only when the scheduler is asked to not modify a graph, we can see
538 * dead nodes here.
539 */
540 continue;
541 }
542 latestBlock = calcBlockForUsage(currentNode, usage, latestBlock, currentNodeMap);
543 }
544
545 assert latestBlock != null : currentNode;
546
547 if (strategy == SchedulingStrategy.FINAL_SCHEDULE || strategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS) {
548 Block currentBlock = latestBlock;
549 while (currentBlock.getLoopDepth() > earliestBlock.getLoopDepth() && currentBlock != earliestBlock.getDominator()) {
550 Block previousCurrentBlock = currentBlock;
551 currentBlock = currentBlock.getDominator();
552 if (previousCurrentBlock.isLoopHeader()) {
553 if (currentBlock.getRelativeFrequency() < latestBlock.getRelativeFrequency() || ((StructuredGraph) currentNode.graph()).hasValueProxies()) {
554 // Only assign new latest block if frequency is actually lower or if
555 // loop proxies would be required otherwise.
556 latestBlock = currentBlock;
557 }
558 }
559 }
560 }
561
562 if (latestBlock != earliestBlock && latestBlock != earliestBlock.getDominator() && constrainingLocation != null) {
563 latestBlock = checkKillsBetween(earliestBlock, latestBlock, constrainingLocation);
564 }
565 }
566
567 if (latestBlock != earliestBlock && currentNode instanceof FloatingReadNode) {
568
569 FloatingReadNode floatingReadNode = (FloatingReadNode) currentNode;
570 if (isImplicitNullOpportunity(floatingReadNode, earliestBlock) &&
571 earliestBlock.getRelativeFrequency() < latestBlock.getRelativeFrequency() * IMPLICIT_NULL_CHECK_OPPORTUNITY_PROBABILITY_FACTOR) {
572 latestBlock = earliestBlock;
573 }
574 }
575
576 selectLatestBlock(currentNode, earliestBlock, latestBlock, currentNodeMap, watchListMap, constrainingLocation, latestBlockToNodesMap);
577 }
578
579 private static boolean isImplicitNullOpportunity(FloatingReadNode floatingReadNode, Block block) {
580
581 Node pred = block.getBeginNode().predecessor();
582 if (pred instanceof IfNode) {
583 IfNode ifNode = (IfNode) pred;
584 if (ifNode.condition() instanceof IsNullNode) {
585 IsNullNode isNullNode = (IsNullNode) ifNode.condition();
586 if (getUnproxifiedUncompressed(floatingReadNode.getAddress().getBase()) == getUnproxifiedUncompressed(isNullNode.getValue())) {
587 return true;
588 }
589 }
590 }
591 return false;
|