use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.
the class HotSpotGraalRuntime method openDebugContext.
@Override
public DebugContext openDebugContext(OptionValues compilationOptions, CompilationIdentifier compilationId, Object compilable, Iterable<DebugHandlersFactory> factories, PrintStream logStream) {
if (management != null && management.poll(false) != null) {
if (compilable instanceof HotSpotResolvedJavaMethod) {
HotSpotResolvedObjectType type = ((HotSpotResolvedJavaMethod) compilable).getDeclaringClass();
if (type instanceof HotSpotResolvedJavaType) {
Class<?> clazz = runtime().getMirror(type);
if (clazz != null) {
try {
ClassLoader cl = clazz.getClassLoader();
if (cl != null) {
loaders.add(cl);
}
} catch (SecurityException e) {
// This loader can obviously not be used for resolving class names
}
}
}
}
}
Description description = new Description(compilable, compilationId.toString(CompilationIdentifier.Verbosity.ID));
Builder builder = //
new Builder(compilationOptions, factories).globalMetrics(//
metricValues).description(//
description).logStream(logStream);
if (compilerProfiler != null) {
int compileId = ((HotSpotCompilationIdentifier) compilationId).getRequest().getId();
builder.compilationListener(new CompilationListenerProfiler(compilerProfiler, compileId));
}
return builder.build();
}
use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.
the class PerformanceWarningTest method testHelper.
@SuppressWarnings("try")
private void testHelper(RootNode rootNode, boolean expectException, String... outputStrings) {
// Compile and capture output to logger's stream.
boolean seenException = false;
try {
OptimizedCallTarget target = (OptimizedCallTarget) rootNode.getCallTarget();
DebugContext debug = new Builder(GraalTruffleRuntime.getRuntime().getGraalOptions(OptionValues.class)).build();
try (DebugCloseable d = debug.disableIntercept();
DebugContext.Scope s = debug.scope("PerformanceWarningTest")) {
final OptimizedCallTarget compilable = target;
CompilationIdentifier compilationId = getTruffleCompiler(target).createCompilationIdentifier(compilable);
getTruffleCompiler(target).compileAST(compilable.getOptionValues(), debug, compilable, compilationId, new TruffleCompilerImpl.CancellableTruffleCompilationTask(new TruffleCompilationTask() {
private TruffleInliningData inlining = new TruffleInlining();
@Override
public boolean isCancelled() {
return false;
}
@Override
public boolean isLastTier() {
return true;
}
@Override
public TruffleInliningData inliningData() {
return inlining;
}
@Override
public boolean hasNextTier() {
return false;
}
}), null);
assertTrue(compilable.isValid());
}
} catch (AssertionError e) {
seenException = true;
if (!expectException) {
throw new AssertionError("Unexpected exception caught." + (outContent.size() > 0 ? '\n' + outContent.toString() : ""), e);
}
}
if (expectException && !seenException) {
Assert.assertTrue("Expected exception not caught.", false);
}
// Check output on TTY.
String output = outContent.toString();
if (outputStrings == EMPTY_PERF_WARNINGS) {
Assert.assertEquals("", output);
} else {
for (String s : outputStrings) {
Assert.assertTrue(String.format("Root node class %s: \"%s\" not found in output \"%s\"", rootNode.getClass().getName(), s, output), output.contains(s));
}
}
}
use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.
the class StaticInterfaceFieldTest method eagerlyParseMethod.
@SuppressWarnings("try")
private void eagerlyParseMethod(Class<C> clazz, String methodName) {
RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
Providers providers = rt.getHostBackend().getProviders();
MetaAccessProvider metaAccess = providers.getMetaAccess();
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
Plugins plugins = new Plugins(new InvocationPlugins());
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
Assume.assumeTrue(VerifyPhase.class.desiredAssertionStatus());
final Method m = getMethod(clazz, methodName);
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
OptionValues options = getInitialOptions();
DebugContext debug = new Builder(options).build();
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
try (DebugCloseable s = debug.disableIntercept();
DebugContext.Scope ds = debug.scope("GraphBuilding", graph, method)) {
graphBuilderSuite.apply(graph, context);
} catch (Throwable e) {
throw debug.handle(e);
}
}
use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.
the class VerifyBailoutUsageTest method testBailoutUsage.
@SuppressWarnings("try")
private static void testBailoutUsage(Class<?> c) {
RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
Providers providers = rt.getHostBackend().getProviders();
MetaAccessProvider metaAccess = providers.getMetaAccess();
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
Plugins plugins = new Plugins(new InvocationPlugins());
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
OptionValues options = getInitialOptions();
DebugContext debug = new Builder(options).build();
for (Method m : c.getDeclaredMethods()) {
if (!Modifier.isNative(m.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
graphBuilderSuite.apply(graph, context);
try (DebugCloseable s = debug.disableIntercept()) {
new VerifyBailoutUsage().apply(graph, context);
}
}
}
}
use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.
the class TruffleCompilerImpl method openDebugContext.
@Override
public final TruffleDebugContext openDebugContext(Map<String, Object> options, TruffleCompilation compilation) {
OptionValues graalOptions = TruffleCompilerRuntime.getRuntime().getGraalOptions(OptionValues.class);
final DebugContext debugContext;
if (compilation == null) {
debugContext = new Builder(graalOptions).build();
} else {
TruffleCompilationIdentifier ident = asTruffleCompilationIdentifier(compilation);
CompilableTruffleAST compilable = ident.getCompilable();
org.graalvm.options.OptionValues truffleOptions = getOptionsForCompiler(options);
if (ExpansionStatistics.isEnabled(truffleOptions)) {
graalOptions = enableNodeSourcePositions(graalOptions);
}
debugContext = createDebugContext(graalOptions, ident, compilable, DebugContext.getDefaultLogStream());
}
return new TruffleDebugContextImpl(debugContext);
}
Aggregations