src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/LinearScanEliminateSpillMovePhase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Cdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/LinearScanEliminateSpillMovePhase.java

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

Print this page

        

*** 29,39 **** import static org.graalvm.compiler.lir.phases.LIRPhase.Options.LIROptimization; import java.util.ArrayList; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; ! import org.graalvm.compiler.debug.Debug; import org.graalvm.compiler.debug.Indent; import org.graalvm.compiler.lir.LIRInsertionBuffer; import org.graalvm.compiler.lir.LIRInstruction; import org.graalvm.compiler.lir.StandardOp.LoadConstantOp; import org.graalvm.compiler.lir.StandardOp.MoveOp; --- 29,39 ---- import static org.graalvm.compiler.lir.phases.LIRPhase.Options.LIROptimization; import java.util.ArrayList; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; ! import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.debug.Indent; import org.graalvm.compiler.lir.LIRInsertionBuffer; import org.graalvm.compiler.lir.LIRInstruction; import org.graalvm.compiler.lir.StandardOp.LoadConstantOp; import org.graalvm.compiler.lir.StandardOp.MoveOp;
*** 88,112 **** } // called once before assignment of register numbers @SuppressWarnings("try") void eliminateSpillMoves(LIRGenerationResult res) { ! try (Indent indent = Debug.logAndIndent("Eliminating unnecessary spill moves")) { /* * collect all intervals that must be stored after their definition. The list is sorted * by Interval.spillDefinitionPos. */ Interval interval; interval = allocator.createUnhandledLists(mustStoreAtDefinition, null).getLeft(); if (DetailedAsserts.getValue(allocator.getOptions())) { ! checkIntervals(interval); } LIRInsertionBuffer insertionBuffer = new LIRInsertionBuffer(); for (AbstractBlockBase<?> block : allocator.sortedBlocks()) { ! try (Indent indent1 = Debug.logAndIndent("Handle %s", block)) { ArrayList<LIRInstruction> instructions = allocator.getLIR().getLIRforBlock(block); int numInst = instructions.size(); // iterate all instructions of the block. for (int j = firstInstructionOfInterest(); j < numInst; j++) { --- 88,113 ---- } // called once before assignment of register numbers @SuppressWarnings("try") void eliminateSpillMoves(LIRGenerationResult res) { ! DebugContext debug = allocator.getDebug(); ! try (Indent indent = debug.logAndIndent("Eliminating unnecessary spill moves")) { /* * collect all intervals that must be stored after their definition. The list is sorted * by Interval.spillDefinitionPos. */ Interval interval; interval = allocator.createUnhandledLists(mustStoreAtDefinition, null).getLeft(); if (DetailedAsserts.getValue(allocator.getOptions())) { ! checkIntervals(debug, interval); } LIRInsertionBuffer insertionBuffer = new LIRInsertionBuffer(); for (AbstractBlockBase<?> block : allocator.sortedBlocks()) { ! try (Indent indent1 = debug.logAndIndent("Handle %s", block)) { ArrayList<LIRInstruction> instructions = allocator.getLIR().getLIRforBlock(block); int numInst = instructions.size(); // iterate all instructions of the block. for (int j = firstInstructionOfInterest(); j < numInst; j++) {
*** 123,140 **** if (Options.LIROptLSRAEliminateSpillMoves.getValue(allocator.getOptions()) && canEliminateSpillMove(block, move)) { /* * Move target is a stack slot that is always correct, so eliminate * instruction. */ ! if (Debug.isLogEnabled()) { if (ValueMoveOp.isValueMoveOp(op)) { ValueMoveOp vmove = ValueMoveOp.asValueMoveOp(op); ! Debug.log("eliminating move from interval %d (%s) to %d (%s) in block %s", allocator.operandNumber(vmove.getInput()), vmove.getInput(), allocator.operandNumber(vmove.getResult()), vmove.getResult(), block); } else { LoadConstantOp load = LoadConstantOp.asLoadConstantOp(op); ! Debug.log("eliminating constant load from %s to %d (%s) in block %s", load.getConstant(), allocator.operandNumber(load.getResult()), load.getResult(), block); } } // null-instructions are deleted by assignRegNum instructions.set(j, null); --- 124,141 ---- if (Options.LIROptLSRAEliminateSpillMoves.getValue(allocator.getOptions()) && canEliminateSpillMove(block, move)) { /* * Move target is a stack slot that is always correct, so eliminate * instruction. */ ! if (debug.isLogEnabled()) { if (ValueMoveOp.isValueMoveOp(op)) { ValueMoveOp vmove = ValueMoveOp.asValueMoveOp(op); ! debug.log("eliminating move from interval %d (%s) to %d (%s) in block %s", allocator.operandNumber(vmove.getInput()), vmove.getInput(), allocator.operandNumber(vmove.getResult()), vmove.getResult(), block); } else { LoadConstantOp load = LoadConstantOp.asLoadConstantOp(op); ! debug.log("eliminating constant load from %s to %d (%s) in block %s", load.getConstant(), allocator.operandNumber(load.getResult()), load.getResult(), block); } } // null-instructions are deleted by assignRegNum instructions.set(j, null);
*** 168,179 **** LIRInstruction move = allocator.getSpillMoveFactory().createMove(toLocation, fromLocation); insertionBuffer.append(j + 1, move); move.setComment(res, "LSRAEliminateSpillMove: store at definition"); ! if (Debug.isLogEnabled()) { ! Debug.log("inserting move after definition of interval %d to stack slot %s at opId %d", interval.operandNumber, interval.spillSlot(), opId); } } } interval = interval.next; } --- 169,180 ---- LIRInstruction move = allocator.getSpillMoveFactory().createMove(toLocation, fromLocation); insertionBuffer.append(j + 1, move); move.setComment(res, "LSRAEliminateSpillMove: store at definition"); ! if (debug.isLogEnabled()) { ! debug.log("inserting move after definition of interval %d to stack slot %s at opId %d", interval.operandNumber, interval.spillSlot(), opId); } } } interval = interval.next; }
*** 204,214 **** return true; } return false; } ! private static void checkIntervals(Interval interval) { Interval prev = null; Interval temp = interval; while (!temp.isEndMarker()) { assert temp.spillDefinitionPos() > 0 : "invalid spill definition pos"; if (prev != null) { --- 205,215 ---- return true; } return false; } ! private static void checkIntervals(DebugContext debug, Interval interval) { Interval prev = null; Interval temp = interval; while (!temp.isEndMarker()) { assert temp.spillDefinitionPos() > 0 : "invalid spill definition pos"; if (prev != null) {
*** 218,229 **** assert temp.spillSlot() != null || temp.canMaterialize() : "interval has no spill slot assigned"; assert temp.spillDefinitionPos() >= temp.from() : "invalid order"; assert temp.spillDefinitionPos() <= temp.from() + 2 : "only intervals defined once at their start-pos can be optimized"; ! if (Debug.isLogEnabled()) { ! Debug.log("interval %d (from %d to %d) must be stored at %d", temp.operandNumber, temp.from(), temp.to(), temp.spillDefinitionPos()); } prev = temp; temp = temp.next; } --- 219,230 ---- assert temp.spillSlot() != null || temp.canMaterialize() : "interval has no spill slot assigned"; assert temp.spillDefinitionPos() >= temp.from() : "invalid order"; assert temp.spillDefinitionPos() <= temp.from() + 2 : "only intervals defined once at their start-pos can be optimized"; ! if (debug.isLogEnabled()) { ! debug.log("interval %d (from %d to %d) must be stored at %d", temp.operandNumber, temp.from(), temp.to(), temp.spillDefinitionPos()); } prev = temp; temp = temp.next; }
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/LinearScanEliminateSpillMovePhase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File