use of org.graalvm.compiler.debug.DebugCloseable in project graal by oracle.
the class GraalCompiler method emitBackEnd.
@SuppressWarnings("try")
public static <T extends CompilationResult> void emitBackEnd(StructuredGraph graph, Object stub, ResolvedJavaMethod installedCodeOwner, Backend backend, T compilationResult, CompilationResultBuilderFactory factory, RegisterConfig registerConfig, LIRSuites lirSuites) {
DebugContext debug = graph.getDebug();
try (DebugContext.Scope s = debug.scope("BackEnd", graph.getLastSchedule());
DebugCloseable a = BackEnd.start(debug)) {
LIRGenerationResult lirGen = null;
lirGen = emitLIR(backend, graph, stub, registerConfig, lirSuites);
try (DebugContext.Scope s2 = debug.scope("CodeGen", lirGen, lirGen.getLIR())) {
int bytecodeSize = graph.method() == null ? 0 : graph.getBytecodeSize();
compilationResult.setHasUnsafeAccess(graph.hasUnsafeAccess());
emitCode(backend, graph.getAssumptions(), graph.method(), graph.getMethods(), graph.getFields(), bytecodeSize, lirGen, compilationResult, installedCodeOwner, factory);
} catch (Throwable e) {
throw debug.handle(e);
}
} catch (Throwable e) {
throw debug.handle(e);
} finally {
graph.checkCancellation();
}
}
use of org.graalvm.compiler.debug.DebugCloseable in project graal by oracle.
the class BasePhase method apply.
@SuppressWarnings("try")
protected final void apply(final StructuredGraph graph, final C context, final boolean dumpGraph) {
graph.checkCancellation();
DebugContext debug = graph.getDebug();
try (DebugCloseable a = timer.start(debug);
DebugContext.Scope s = debug.scope(getClass(), this);
DebugCloseable c = memUseTracker.start(debug)) {
int sizeBefore = 0;
Mark before = null;
OptionValues options = graph.getOptions();
boolean verifySizeContract = PhaseOptions.VerifyGraalPhasesSize.getValue(options) && checkContract();
if (verifySizeContract) {
sizeBefore = NodeCostUtil.computeGraphSize(graph);
before = graph.getMark();
}
boolean isTopLevel = getEnclosingPhase(graph.getDebug()) == null;
boolean dumpedBefore = false;
if (dumpGraph && debug.areScopesEnabled()) {
dumpedBefore = dumpBefore(graph, context, isTopLevel);
}
inputNodesCount.add(debug, graph.getNodeCount());
this.run(graph, context);
executionCount.increment(debug);
if (verifySizeContract) {
if (!before.isCurrent()) {
int sizeAfter = NodeCostUtil.computeGraphSize(graph);
NodeCostUtil.phaseFulfillsSizeContract(graph, sizeBefore, sizeAfter, this);
}
}
if (dumpGraph && debug.areScopesEnabled()) {
dumpAfter(graph, isTopLevel, dumpedBefore);
}
if (debug.isVerifyEnabled()) {
debug.verify(graph, "%s", getName());
}
assert graph.verify();
} catch (Throwable t) {
throw debug.handle(t);
}
}
use of org.graalvm.compiler.debug.DebugCloseable in project graal by oracle.
the class TypeGuardInlineInfo method createGuard.
@SuppressWarnings("try")
private void createGuard(StructuredGraph graph, Providers providers) {
try (DebugCloseable context = invoke.asNode().withNodeSourcePosition()) {
ValueNode nonNullReceiver = InliningUtil.nonNullReceiver(invoke);
LoadHubNode receiverHub = graph.unique(new LoadHubNode(providers.getStampProvider(), nonNullReceiver));
ConstantNode typeHub = ConstantNode.forConstant(receiverHub.stamp(NodeView.DEFAULT), providers.getConstantReflection().asObjectHub(type), providers.getMetaAccess(), graph);
LogicNode typeCheck = CompareNode.createCompareNode(graph, CanonicalCondition.EQ, receiverHub, typeHub, providers.getConstantReflection(), NodeView.DEFAULT);
FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile));
assert invoke.predecessor() != null;
ValueNode anchoredReceiver = InliningUtil.createAnchoredReceiver(graph, guard, type, nonNullReceiver, true);
invoke.callTarget().replaceFirstInput(nonNullReceiver, anchoredReceiver);
graph.addBeforeFixed(invoke.asNode(), guard);
}
}
Aggregations