src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/stackslotalloc/FixPointIntervalBuilder.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/stackslotalloc/FixPointIntervalBuilder.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/stackslotalloc/FixPointIntervalBuilder.java
Print this page
*** 31,52 ****
import java.util.Deque;
import java.util.EnumSet;
import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
import org.graalvm.compiler.core.common.cfg.BlockMap;
! import org.graalvm.compiler.debug.Debug;
! import org.graalvm.compiler.debug.DebugCounter;
import org.graalvm.compiler.debug.Indent;
import org.graalvm.compiler.lir.InstructionValueConsumer;
import org.graalvm.compiler.lir.InstructionValueProcedure;
import org.graalvm.compiler.lir.LIR;
import org.graalvm.compiler.lir.LIRInstruction;
import org.graalvm.compiler.lir.LIRInstruction.OperandFlag;
import org.graalvm.compiler.lir.LIRInstruction.OperandMode;
- import org.graalvm.util.Equivalence;
- import org.graalvm.util.EconomicSet;
import org.graalvm.compiler.lir.VirtualStackSlot;
import jdk.vm.ci.meta.Value;
/**
* Calculates the stack intervals using a worklist-based backwards data-flow analysis.
--- 31,52 ----
import java.util.Deque;
import java.util.EnumSet;
import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
import org.graalvm.compiler.core.common.cfg.BlockMap;
! import org.graalvm.compiler.debug.CounterKey;
! import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.Indent;
import org.graalvm.compiler.lir.InstructionValueConsumer;
import org.graalvm.compiler.lir.InstructionValueProcedure;
import org.graalvm.compiler.lir.LIR;
import org.graalvm.compiler.lir.LIRInstruction;
import org.graalvm.compiler.lir.LIRInstruction.OperandFlag;
import org.graalvm.compiler.lir.LIRInstruction.OperandMode;
import org.graalvm.compiler.lir.VirtualStackSlot;
+ import org.graalvm.util.EconomicSet;
+ import org.graalvm.util.Equivalence;
import jdk.vm.ci.meta.Value;
/**
* Calculates the stack intervals using a worklist-based backwards data-flow analysis.
*** 60,70 ****
private final EconomicSet<LIRInstruction> usePos;
/**
* The number of allocated stack slots.
*/
! private static final DebugCounter uninitializedSlots = Debug.counter("StackSlotAllocator[uninitializedSlots]");
FixPointIntervalBuilder(LIR lir, StackInterval[] stackSlotMap, int maxOpId) {
this.lir = lir;
this.stackSlotMap = stackSlotMap;
this.maxOpId = maxOpId;
--- 60,70 ----
private final EconomicSet<LIRInstruction> usePos;
/**
* The number of allocated stack slots.
*/
! private static final CounterKey uninitializedSlots = DebugContext.counter("StackSlotAllocator[uninitializedSlots]");
FixPointIntervalBuilder(LIR lir, StackInterval[] stackSlotMap, int maxOpId) {
this.lir = lir;
this.stackSlotMap = stackSlotMap;
this.maxOpId = maxOpId;
*** 111,122 ****
return false;
}
@SuppressWarnings("try")
private void processBlock(AbstractBlockBase<?> block, Deque<AbstractBlockBase<?>> worklist) {
if (updateOutBlock(block)) {
! try (Indent indent = Debug.logAndIndent("handle block %s", block)) {
ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block);
// get out set and mark intervals
BitSet outSet = liveOutMap.get(block);
markOutInterval(outSet, getBlockEnd(instructions));
printLiveSet("liveOut", outSet);
--- 111,123 ----
return false;
}
@SuppressWarnings("try")
private void processBlock(AbstractBlockBase<?> block, Deque<AbstractBlockBase<?>> worklist) {
+ DebugContext debug = lir.getDebug();
if (updateOutBlock(block)) {
! try (Indent indent = debug.logAndIndent("handle block %s", block)) {
ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block);
// get out set and mark intervals
BitSet outSet = liveOutMap.get(block);
markOutInterval(outSet, getBlockEnd(instructions));
printLiveSet("liveOut", outSet);
*** 141,153 ****
}
}
@SuppressWarnings("try")
private void printLiveSet(String label, BitSet liveSet) {
! if (Debug.isLogEnabled()) {
! try (Indent indent = Debug.logAndIndent(label)) {
! Debug.log("%s", liveSetToString(liveSet));
}
}
}
private String liveSetToString(BitSet liveSet) {
--- 142,155 ----
}
}
@SuppressWarnings("try")
private void printLiveSet(String label, BitSet liveSet) {
! DebugContext debug = lir.getDebug();
! if (debug.isLogEnabled()) {
! try (Indent indent = debug.logAndIndent(label)) {
! debug.log("%s", liveSetToString(liveSet));
}
}
}
private String liveSetToString(BitSet liveSet) {
*** 158,178 ****
}
return sb.toString();
}
private void markOutInterval(BitSet outSet, int blockEndOpId) {
for (int i = outSet.nextSetBit(0); i >= 0; i = outSet.nextSetBit(i + 1)) {
StackInterval interval = getIntervalFromStackId(i);
! Debug.log("mark live operand: %s", interval.getOperand());
interval.addTo(blockEndOpId);
}
}
private void markInInterval(BitSet inSet, int blockFirstOpId) {
for (int i = inSet.nextSetBit(0); i >= 0; i = inSet.nextSetBit(i + 1)) {
StackInterval interval = getIntervalFromStackId(i);
! Debug.log("mark live operand: %s", interval.getOperand());
interval.addFrom(blockFirstOpId);
}
}
private final class BlockClosure {
--- 160,182 ----
}
return sb.toString();
}
private void markOutInterval(BitSet outSet, int blockEndOpId) {
+ DebugContext debug = lir.getDebug();
for (int i = outSet.nextSetBit(0); i >= 0; i = outSet.nextSetBit(i + 1)) {
StackInterval interval = getIntervalFromStackId(i);
! debug.log("mark live operand: %s", interval.getOperand());
interval.addTo(blockEndOpId);
}
}
private void markInInterval(BitSet inSet, int blockFirstOpId) {
+ DebugContext debug = lir.getDebug();
for (int i = inSet.nextSetBit(0); i >= 0; i = inSet.nextSetBit(i + 1)) {
StackInterval interval = getIntervalFromStackId(i);
! debug.log("mark live operand: %s", interval.getOperand());
interval.addFrom(blockFirstOpId);
}
}
private final class BlockClosure {
*** 190,200 ****
* Process all values of an instruction bottom-up, i.e. definitions before usages. Values
* that start or end at the current operation are not included.
*/
@SuppressWarnings("try")
private void processInstructionBottomUp(LIRInstruction op) {
! try (Indent indent = Debug.logAndIndent("handle op %d, %s", op.id(), op)) {
// kills
op.visitEachTemp(defConsumer);
op.visitEachOutput(defConsumer);
// gen - values that are considered alive for this state
--- 194,205 ----
* Process all values of an instruction bottom-up, i.e. definitions before usages. Values
* that start or end at the current operation are not included.
*/
@SuppressWarnings("try")
private void processInstructionBottomUp(LIRInstruction op) {
! DebugContext debug = lir.getDebug();
! try (Indent indent = debug.logAndIndent("handle op %d, %s", op.id(), op)) {
// kills
op.visitEachTemp(defConsumer);
op.visitEachOutput(defConsumer);
// gen - values that are considered alive for this state
*** 208,236 ****
InstructionValueConsumer useConsumer = new InstructionValueConsumer() {
@Override
public void visitValue(LIRInstruction inst, Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
if (isVirtualStackSlot(operand)) {
VirtualStackSlot vslot = asVirtualStackSlot(operand);
addUse(vslot, inst, flags);
addRegisterHint(inst, vslot, mode, flags, false);
usePos.add(inst);
! Debug.log("set operand: %s", operand);
currentSet.set(vslot.getId());
}
}
};
InstructionValueConsumer defConsumer = new InstructionValueConsumer() {
@Override
public void visitValue(LIRInstruction inst, Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
if (isVirtualStackSlot(operand)) {
VirtualStackSlot vslot = asVirtualStackSlot(operand);
addDef(vslot, inst);
addRegisterHint(inst, vslot, mode, flags, true);
usePos.add(inst);
! Debug.log("clear operand: %s", operand);
currentSet.clear(vslot.getId());
}
}
};
--- 213,243 ----
InstructionValueConsumer useConsumer = new InstructionValueConsumer() {
@Override
public void visitValue(LIRInstruction inst, Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
if (isVirtualStackSlot(operand)) {
+ DebugContext debug = lir.getDebug();
VirtualStackSlot vslot = asVirtualStackSlot(operand);
addUse(vslot, inst, flags);
addRegisterHint(inst, vslot, mode, flags, false);
usePos.add(inst);
! debug.log("set operand: %s", operand);
currentSet.set(vslot.getId());
}
}
};
InstructionValueConsumer defConsumer = new InstructionValueConsumer() {
@Override
public void visitValue(LIRInstruction inst, Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
if (isVirtualStackSlot(operand)) {
+ DebugContext debug = lir.getDebug();
VirtualStackSlot vslot = asVirtualStackSlot(operand);
addDef(vslot, inst);
addRegisterHint(inst, vslot, mode, flags, true);
usePos.add(inst);
! debug.log("clear operand: %s", operand);
currentSet.clear(vslot.getId());
}
}
};
*** 238,249 ****
private void addUse(VirtualStackSlot stackSlot, LIRInstruction inst, EnumSet<OperandFlag> flags) {
StackInterval interval = getOrCreateInterval(stackSlot);
if (flags.contains(OperandFlag.UNINITIALIZED)) {
// Stack slot is marked uninitialized so we have to assume it is live all
// the time.
! if (Debug.isCountEnabled() && !(interval.from() == 0 && interval.to() == maxOpId)) {
! uninitializedSlots.increment();
}
interval.addFrom(0);
interval.addTo(maxOpId);
} else {
interval.addTo(inst.id());
--- 245,257 ----
private void addUse(VirtualStackSlot stackSlot, LIRInstruction inst, EnumSet<OperandFlag> flags) {
StackInterval interval = getOrCreateInterval(stackSlot);
if (flags.contains(OperandFlag.UNINITIALIZED)) {
// Stack slot is marked uninitialized so we have to assume it is live all
// the time.
! DebugContext debug = lir.getDebug();
! if (debug.isCountEnabled() && !(interval.from() == 0 && interval.to() == maxOpId)) {
! uninitializedSlots.increment(debug);
}
interval.addFrom(0);
interval.addTo(maxOpId);
} else {
interval.addTo(inst.id());
*** 268,279 ****
if (hintAtDef) {
to.setLocationHint(from);
} else {
from.setLocationHint(to);
}
! if (Debug.isLogEnabled()) {
! Debug.log("operation %s at opId %d: added hint from interval %s to %s", op, op.id(), from, to);
}
return registerHint;
}
return null;
--- 276,288 ----
if (hintAtDef) {
to.setLocationHint(from);
} else {
from.setLocationHint(to);
}
! DebugContext debug = lir.getDebug();
! if (debug.isLogEnabled()) {
! debug.log("operation %s at opId %d: added hint from interval %s to %s", op, op.id(), from, to);
}
return registerHint;
}
return null;
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/stackslotalloc/FixPointIntervalBuilder.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File