src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/phases/StackMoveOptimizationPhase.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.amd64/src/org/graalvm/compiler/lir/amd64/phases/StackMoveOptimizationPhase.java

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/phases/StackMoveOptimizationPhase.java

Print this page

        

*** 27,38 **** import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; ! import org.graalvm.compiler.debug.Debug; ! import org.graalvm.compiler.debug.DebugCounter; import org.graalvm.compiler.lir.LIR; import org.graalvm.compiler.lir.LIRInstruction; import org.graalvm.compiler.lir.RedundantMoveElimination; import org.graalvm.compiler.lir.amd64.AMD64Move.AMD64MultiStackMove; import org.graalvm.compiler.lir.amd64.AMD64Move.AMD64StackMove; --- 27,38 ---- import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; ! import org.graalvm.compiler.debug.CounterKey; ! import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.lir.LIR; import org.graalvm.compiler.lir.LIRInstruction; import org.graalvm.compiler.lir.RedundantMoveElimination; import org.graalvm.compiler.lir.amd64.AMD64Move.AMD64MultiStackMove; import org.graalvm.compiler.lir.amd64.AMD64Move.AMD64StackMove;
*** 60,77 **** @Option(help = "", type = OptionType.Debug) public static final NestedBooleanOptionKey LIROptStackMoveOptimizer = new NestedBooleanOptionKey(LIROptimization, true); // @formatter:on } ! private static final DebugCounter eliminatedBackup = Debug.counter("StackMoveOptimizer[EliminatedScratchBackupRestore]"); @Override protected void run(TargetDescription target, LIRGenerationResult lirGenRes, PostAllocationOptimizationContext context) { LIR lir = lirGenRes.getLIR(); for (AbstractBlockBase<?> block : lir.getControlFlowGraph().getBlocks()) { ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block); ! new Closure().process(instructions); } } private static class Closure { private static final int NONE = -1; --- 60,78 ---- @Option(help = "", type = OptionType.Debug) public static final NestedBooleanOptionKey LIROptStackMoveOptimizer = new NestedBooleanOptionKey(LIROptimization, true); // @formatter:on } ! private static final CounterKey eliminatedBackup = DebugContext.counter("StackMoveOptimizer[EliminatedScratchBackupRestore]"); @Override protected void run(TargetDescription target, LIRGenerationResult lirGenRes, PostAllocationOptimizationContext context) { LIR lir = lirGenRes.getLIR(); + DebugContext debug = lir.getDebug(); for (AbstractBlockBase<?> block : lir.getControlFlowGraph().getBlocks()) { ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block); ! new Closure().process(debug, instructions); } } private static class Closure { private static final int NONE = -1;
*** 81,100 **** private List<AllocatableValue> dst; private List<Value> src; private AllocatableValue slot; private boolean removed = false; ! public void process(List<LIRInstruction> instructions) { for (int i = 0; i < instructions.size(); i++) { LIRInstruction inst = instructions.get(i); if (isStackMove(inst)) { AMD64StackMove move = asStackMove(inst); if (reg != null && !reg.equals(move.getScratchRegister())) { // end of trace & start of new ! replaceStackMoves(instructions); } // lazy initialize if (dst == null) { assert src == null; --- 82,101 ---- private List<AllocatableValue> dst; private List<Value> src; private AllocatableValue slot; private boolean removed = false; ! public void process(DebugContext debug, List<LIRInstruction> instructions) { for (int i = 0; i < instructions.size(); i++) { LIRInstruction inst = instructions.get(i); if (isStackMove(inst)) { AMD64StackMove move = asStackMove(inst); if (reg != null && !reg.equals(move.getScratchRegister())) { // end of trace & start of new ! replaceStackMoves(debug, instructions); } // lazy initialize if (dst == null) { assert src == null;
*** 112,142 **** slot = move.getBackupSlot(); } } else if (begin != NONE) { // end of trace ! replaceStackMoves(instructions); } } // remove instructions if (removed) { instructions.removeAll(Collections.singleton(null)); } } ! private void replaceStackMoves(List<LIRInstruction> instructions) { int size = dst.size(); if (size > 1) { AMD64MultiStackMove multiMove = new AMD64MultiStackMove(dst.toArray(new AllocatableValue[size]), src.toArray(new AllocatableValue[size]), reg, slot); // replace first instruction instructions.set(begin, multiMove); // and null out others Collections.fill(instructions.subList(begin + 1, begin + size), null); // removed removed = true; ! eliminatedBackup.add(size - 1); } // reset dst.clear(); src.clear(); begin = NONE; --- 113,143 ---- slot = move.getBackupSlot(); } } else if (begin != NONE) { // end of trace ! replaceStackMoves(debug, instructions); } } // remove instructions if (removed) { instructions.removeAll(Collections.singleton(null)); } } ! private void replaceStackMoves(DebugContext debug, List<LIRInstruction> instructions) { int size = dst.size(); if (size > 1) { AMD64MultiStackMove multiMove = new AMD64MultiStackMove(dst.toArray(new AllocatableValue[size]), src.toArray(new AllocatableValue[size]), reg, slot); // replace first instruction instructions.set(begin, multiMove); // and null out others Collections.fill(instructions.subList(begin + 1, begin + size), null); // removed removed = true; ! eliminatedBackup.add(debug, size - 1); } // reset dst.clear(); src.clear(); begin = NONE;
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/phases/StackMoveOptimizationPhase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File