Search in sources :

Example 56 with DebugContext

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);
    }
}
Also used : DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 57 with DebugContext

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());
    }
}
Also used : DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 58 with DebugContext

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);
        }
    }
}
Also used : Indent(org.graalvm.compiler.debug.Indent) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 59 with DebugContext

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);
    }
}
Also used : Indent(org.graalvm.compiler.debug.Indent) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 60 with DebugContext

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);
    }
}
Also used : Indent(org.graalvm.compiler.debug.Indent) Register(jdk.vm.ci.code.Register) DebugContext(org.graalvm.compiler.debug.DebugContext) PlatformKind(jdk.vm.ci.meta.PlatformKind)

Aggregations

DebugContext (org.graalvm.compiler.debug.DebugContext)234 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)87 OptionValues (org.graalvm.compiler.options.OptionValues)50 Indent (org.graalvm.compiler.debug.Indent)37 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)31 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)29 Test (org.junit.Test)27 Node (org.graalvm.compiler.graph.Node)24 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)24 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)22 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)20 Scope (org.graalvm.compiler.debug.DebugContext.Scope)18 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)18 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)17 ValueNode (org.graalvm.compiler.nodes.ValueNode)16 FixedNode (org.graalvm.compiler.nodes.FixedNode)14 CompilationResult (org.graalvm.compiler.code.CompilationResult)13 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)13 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)12 LIR (org.graalvm.compiler.lir.LIR)11