use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.
the class MoveResolver method printMapping.
@SuppressWarnings("try")
private void printMapping() {
DebugContext debug = allocator.getDebug();
try (Indent indent = debug.logAndIndent("Mapping")) {
for (int i = mappingFrom.size() - 1; i >= 0; i--) {
Interval fromInterval = mappingFrom.get(i);
Interval toInterval = mappingTo.get(i);
String from;
Value to = toInterval.location();
if (fromInterval == null) {
from = mappingFromOpr.get(i).toString();
} else {
from = fromInterval.location().toString();
}
debug.log("move %s <- %s", from, to);
}
}
}
use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.
the class MoveResolver method resolveMappings.
@SuppressWarnings("try")
private void resolveMappings() {
DebugContext debug = allocator.getDebug();
try (Indent indent = debug.logAndIndent("resolveMapping")) {
assert verifyBeforeResolve();
if (debug.isLogEnabled()) {
printMapping();
}
// Block all registers that are used as input operands of a move.
// When a register is blocked, no move to this register is emitted.
// This is necessary for detecting cycles in moves.
int i;
for (i = mappingFrom.size() - 1; i >= 0; i--) {
Interval fromInterval = mappingFrom.get(i);
if (fromInterval != null) {
blockRegisters(fromInterval);
}
}
ArrayList<AllocatableValue> busySpillSlots = null;
while (mappingFrom.size() > 0) {
boolean processedInterval = false;
int spillCandidate = -1;
for (i = mappingFrom.size() - 1; i >= 0; i--) {
Interval fromInterval = mappingFrom.get(i);
Interval toInterval = mappingTo.get(i);
if (safeToProcessMove(fromInterval, toInterval)) {
// this interval can be processed because target is free
final LIRInstruction move;
if (fromInterval != null) {
move = insertMove(fromInterval, toInterval);
unblockRegisters(fromInterval);
} else {
move = insertMove(mappingFromOpr.get(i), toInterval);
}
move.setComment(res, "MoveResolver resolve mapping");
if (LIRValueUtil.isStackSlotValue(toInterval.location())) {
if (busySpillSlots == null) {
busySpillSlots = new ArrayList<>(2);
}
busySpillSlots.add(toInterval.location());
}
mappingFrom.remove(i);
mappingFromOpr.remove(i);
mappingTo.remove(i);
processedInterval = true;
} else if (fromInterval != null && isRegister(fromInterval.location()) && (busySpillSlots == null || !busySpillSlots.contains(fromInterval.spillSlot()))) {
// this interval cannot be processed now because target is not free
// it starts in a register, so it is a possible candidate for spilling
spillCandidate = i;
}
}
if (!processedInterval) {
breakCycle(spillCandidate);
}
}
}
// reset to default value
multipleReadsAllowed = false;
// check that all intervals have been processed
assert checkEmpty();
}
use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.
the class OptimizingLinearScanWalker method handleSpillSlot.
@SuppressWarnings("try")
@Override
protected void handleSpillSlot(Interval interval) {
assert interval.location() != null : "interval not assigned " + interval;
if (interval.canMaterialize()) {
assert !isStackSlotValue(interval.location()) : "interval can materialize but assigned to a stack slot " + interval;
return;
}
assert isStackSlotValue(interval.location()) : "interval not assigned to a stack slot " + interval;
DebugContext debug = allocator.getDebug();
try (DebugContext.Scope s1 = debug.scope("LSRAOptimization")) {
debug.log("adding stack to unhandled list %s", interval);
unhandledLists.addToListSortedByStartAndUsePositions(RegisterBinding.Stack, interval);
}
}
use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.
the class RegisterVerifier method processSuccessor.
private void processSuccessor(AbstractBlockBase<?> block, Interval[] inputState) {
DebugContext debug = allocator.getDebug();
Interval[] savedState = stateForBlock(block);
if (savedState != null) {
// this block was already processed before.
// check if new inputState is consistent with savedState
boolean savedStateCorrect = true;
for (int i = 0; i < stateSize(); i++) {
if (inputState[i] != savedState[i]) {
// interval in this register . assume that this register is invalid
if (savedState[i] != null) {
// invalidate old calculation only if it assumed that
// register was valid. when the register was already invalid,
// then the old calculation was correct.
savedStateCorrect = false;
savedState[i] = null;
debug.log("processSuccessor B%d: invalidating slot %d", block.getId(), i);
}
}
}
if (savedStateCorrect) {
// already processed block with correct inputState
debug.log("processSuccessor B%d: previous visit already correct", block.getId());
} else {
// must re-visit this block
debug.log("processSuccessor B%d: must re-visit because input state changed", block.getId());
addToWorkList(block);
}
} else {
// block was not processed before, so set initial inputState
debug.log("processSuccessor B%d: initial visit", block.getId());
setStateForBlock(block, copy(inputState));
addToWorkList(block);
}
}
use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.
the class RegisterVerifier method verify.
@SuppressWarnings("try")
void verify(AbstractBlockBase<?> start) {
DebugContext debug = allocator.getDebug();
try (DebugContext.Scope s = debug.scope("RegisterVerifier")) {
// setup input registers (method arguments) for first block
Interval[] inputState = new Interval[stateSize()];
setStateForBlock(start, inputState);
addToWorkList(start);
// main loop for verification
do {
AbstractBlockBase<?> block = workList.get(0);
workList.remove(0);
processBlock(block);
} while (!workList.isEmpty());
}
}
Aggregations