< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/LinearScanOptimizeSpillPositionPhase.java

Print this page
rev 52509 : [mq]: graal


 133             assert firstSpillChild != null;
 134             if (!defBlock.equals(spillBlock) && spillBlock.equals(allocator.blockForId(firstSpillChild.from()))) {
 135                 AbstractBlockBase<?> dom = spillBlock.getDominator();
 136                 if (debug.isLogEnabled()) {
 137                     debug.log("Spill block (%s) is the beginning of a spill child -> use dominator (%s)", spillBlock, dom);
 138                 }
 139                 spillBlock = dom;
 140             }
 141             if (defBlock.equals(spillBlock)) {
 142                 debug.log(DebugContext.VERBOSE_LEVEL, "Definition is the best choice: %s", defBlock);
 143                 // definition is the best choice
 144                 interval.setSpillState(SpillState.StoreAtDefinition);
 145                 return;
 146             }
 147             assert dominates(defBlock, spillBlock);
 148             betterSpillPos.increment(debug);
 149             if (debug.isLogEnabled()) {
 150                 debug.log("Better spill position found (Block %s)", spillBlock);
 151             }
 152 
 153             if (defBlock.probability() <= spillBlock.probability()) {
 154                 debug.log(DebugContext.VERBOSE_LEVEL, "Definition has lower probability %s (%f) is lower than spill block %s (%f)", defBlock, defBlock.probability(), spillBlock,
 155                                 spillBlock.probability());
 156                 // better spill block has the same probability -> do nothing
 157                 interval.setSpillState(SpillState.StoreAtDefinition);
 158                 return;
 159             }
 160 
 161             LIRInsertionBuffer insertionBuffer = insertionBuffers[spillBlock.getId()];
 162             if (insertionBuffer == null) {
 163                 insertionBuffer = new LIRInsertionBuffer();
 164                 insertionBuffers[spillBlock.getId()] = insertionBuffer;
 165                 insertionBuffer.init(allocator.getLIR().getLIRforBlock(spillBlock));
 166             }
 167             int spillOpId = allocator.getFirstLirInstructionId(spillBlock);
 168             // insert spill move
 169             AllocatableValue fromLocation = interval.getSplitChildAtOpId(spillOpId, OperandMode.DEF, allocator).location();
 170             AllocatableValue toLocation = LinearScan.canonicalSpillOpr(interval);
 171             LIRInstruction move = allocator.getSpillMoveFactory().createMove(toLocation, fromLocation);
 172             move.setComment(res, "LSRAOptimizeSpillPos: optimize spill pos");
 173             debug.log(DebugContext.VERBOSE_LEVEL, "Insert spill move %s", move);
 174             move.setId(LinearScan.DOMINATOR_SPILL_MOVE_ID);
 175             /*
 176              * We can use the insertion buffer directly because we always insert at position 1.




 133             assert firstSpillChild != null;
 134             if (!defBlock.equals(spillBlock) && spillBlock.equals(allocator.blockForId(firstSpillChild.from()))) {
 135                 AbstractBlockBase<?> dom = spillBlock.getDominator();
 136                 if (debug.isLogEnabled()) {
 137                     debug.log("Spill block (%s) is the beginning of a spill child -> use dominator (%s)", spillBlock, dom);
 138                 }
 139                 spillBlock = dom;
 140             }
 141             if (defBlock.equals(spillBlock)) {
 142                 debug.log(DebugContext.VERBOSE_LEVEL, "Definition is the best choice: %s", defBlock);
 143                 // definition is the best choice
 144                 interval.setSpillState(SpillState.StoreAtDefinition);
 145                 return;
 146             }
 147             assert dominates(defBlock, spillBlock);
 148             betterSpillPos.increment(debug);
 149             if (debug.isLogEnabled()) {
 150                 debug.log("Better spill position found (Block %s)", spillBlock);
 151             }
 152 
 153             if (defBlock.getRelativeFrequency() <= spillBlock.getRelativeFrequency()) {
 154                 debug.log(DebugContext.VERBOSE_LEVEL, "Definition has lower frequency %s (%f) is lower than spill block %s (%f)", defBlock, defBlock.getRelativeFrequency(), spillBlock,
 155                                 spillBlock.getRelativeFrequency());
 156                 // better spill block has the same frequency -> do nothing
 157                 interval.setSpillState(SpillState.StoreAtDefinition);
 158                 return;
 159             }
 160 
 161             LIRInsertionBuffer insertionBuffer = insertionBuffers[spillBlock.getId()];
 162             if (insertionBuffer == null) {
 163                 insertionBuffer = new LIRInsertionBuffer();
 164                 insertionBuffers[spillBlock.getId()] = insertionBuffer;
 165                 insertionBuffer.init(allocator.getLIR().getLIRforBlock(spillBlock));
 166             }
 167             int spillOpId = allocator.getFirstLirInstructionId(spillBlock);
 168             // insert spill move
 169             AllocatableValue fromLocation = interval.getSplitChildAtOpId(spillOpId, OperandMode.DEF, allocator).location();
 170             AllocatableValue toLocation = LinearScan.canonicalSpillOpr(interval);
 171             LIRInstruction move = allocator.getSpillMoveFactory().createMove(toLocation, fromLocation);
 172             move.setComment(res, "LSRAOptimizeSpillPos: optimize spill pos");
 173             debug.log(DebugContext.VERBOSE_LEVEL, "Insert spill move %s", move);
 174             move.setId(LinearScan.DOMINATOR_SPILL_MOVE_ID);
 175             /*
 176              * We can use the insertion buffer directly because we always insert at position 1.


< prev index next >