use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.
the class RegisterVerifier method processSuccessor.
private void processSuccessor(AbstractBlockBase<?> block, TraceInterval[] inputState) {
TraceInterval[] savedState = stateForBlock(block);
DebugContext debug = allocator.getDebug();
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
TraceInterval[] inputState = new TraceInterval[stateSize()];
setStateForBlock(start, inputState);
addToWorkList(start);
// main loop for verification
do {
AbstractBlockBase<?> block = workList.get(0);
workList.remove(0);
processBlock(block);
} while (!workList.isEmpty());
}
}
use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.
the class RegisterVerifier method processBlock.
@SuppressWarnings("try")
private void processBlock(AbstractBlockBase<?> block) {
DebugContext debug = allocator.getDebug();
try (Indent indent = debug.logAndIndent("processBlock B%d", block.getId())) {
// must copy state because it is modified
TraceInterval[] inputState = copy(stateForBlock(block));
try (Indent indent2 = debug.logAndIndent("Input-State of intervals:")) {
printState(inputState);
}
// process all operations of the block
processOperations(block, inputState);
try (Indent indent2 = debug.logAndIndent("Output-State of intervals:")) {
printState(inputState);
}
// iterate all successors
for (AbstractBlockBase<?> succ : block.getSuccessors()) {
processSuccessor(succ, inputState);
}
}
}
use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.
the class IntervalWalker method walkTo.
/**
* Walk up to {@code toOpId}.
*
* @postcondition {@link #currentPosition} is set to {@code toOpId}, {@link #activeLists} and
* {@link #inactiveLists} are populated and {@link Interval#state}s are up to
* date.
*/
@SuppressWarnings("try")
protected void walkTo(int toOpId) {
assert currentPosition <= toOpId : "can not walk backwards";
for (Interval currentInterval = nextInterval(toOpId); currentInterval != null; currentInterval = nextInterval(toOpId)) {
int opId = currentInterval.from();
// set currentPosition prior to call of walkTo
currentPosition = opId;
// update unhandled stack intervals
updateUnhandledStackIntervals(opId);
// call walkTo even if currentPosition == id
walkTo(State.Active, opId);
walkTo(State.Inactive, opId);
DebugContext debug = allocator.getDebug();
try (Indent indent = debug.logAndIndent("walk to op %d", opId)) {
currentInterval.state = State.Active;
if (activateCurrent(currentInterval)) {
activeLists.addToListSortedByCurrentFromPositions(currentBinding, currentInterval);
intervalMoved(currentInterval, State.Unhandled, State.Active);
}
}
}
// set currentPosition prior to call of walkTo
currentPosition = toOpId;
if (currentPosition <= allocator.maxOpId()) {
// update unhandled stack intervals
updateUnhandledStackIntervals(toOpId);
// call walkTo if still in range
walkTo(State.Active, toOpId);
walkTo(State.Inactive, toOpId);
}
}
use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.
the class LocationMarker method processInstructionBottomUp.
/**
* 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);
if (frameMap != null && op.destroysCallerSavedRegisters()) {
for (Register reg : frameMap.getRegisterConfig().getCallerSaveRegisters()) {
PlatformKind kind = frameMap.getTarget().arch.getLargestStorableKind(reg.getRegisterCategory());
defConsumer.visitValue(reg.asValue(LIRKind.value(kind)), OperandMode.TEMP, REGISTER_FLAG_SET);
}
}
// gen - values that are considered alive for this state
op.visitEachAlive(useConsumer);
op.visitEachState(useConsumer);
// mark locations
op.forEachState(stateConsumer);
// gen
op.visitEachInput(useConsumer);
}
}
Aggregations