Search in sources :

Example 11 with Builder

use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.

the class LambdaStableNameTest method findStableLambdaName.

private String findStableLambdaName(ResolvedJavaType type) {
    OptionValues options = new OptionValues(OptionValues.newOptionMap());
    DebugContext debug = new Builder(options, Collections.emptyList()).build();
    GraalJVMCICompiler compiler = (GraalJVMCICompiler) JVMCI.getRuntime().getCompiler();
    Providers providers = compiler.getGraalRuntime().getCapability(RuntimeProvider.class).getHostBackend().getProviders();
    final HotSpotJITClassInitializationPlugin initializationPlugin = new HotSpotJITClassInitializationPlugin();
    return LambdaUtils.findStableLambdaName(initializationPlugin, providers, type, options, debug, this);
}
Also used : GraalJVMCICompiler(org.graalvm.compiler.api.runtime.GraalJVMCICompiler) OptionValues(org.graalvm.compiler.options.OptionValues) Builder(org.graalvm.compiler.debug.DebugContext.Builder) DebugContext(org.graalvm.compiler.debug.DebugContext) Providers(org.graalvm.compiler.phases.util.Providers) HotSpotJITClassInitializationPlugin(org.graalvm.compiler.hotspot.meta.HotSpotJITClassInitializationPlugin)

Example 12 with Builder

use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.

the class JVMCIInfopointErrorTest method testUnknownJavaValue.

@SuppressWarnings("try")
@Test(expected = Error.class)
public void testUnknownJavaValue() {
    DebugContext debug = new Builder(getInitialOptions()).build();
    try (Scope s = debug.disable()) {
        /*
             * Expected: either AssertionError or GraalError, depending on whether the unit test run
             * is with assertions enabled or disabled.
             */
        test(debug, (tool, state, safepoint) -> {
            LIRFrameState newState = modifyTopFrame(state, new JavaValue[] { new UnknownJavaValue() }, new JavaKind[] { JavaKind.Int }, 1, 0, 0);
            safepoint.accept(newState);
        });
    }
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) Scope(org.graalvm.compiler.debug.DebugContext.Scope) HotSpotCompiledCodeBuilder(org.graalvm.compiler.hotspot.HotSpotCompiledCodeBuilder) CompilationResultBuilder(org.graalvm.compiler.lir.asm.CompilationResultBuilder) Builder(org.graalvm.compiler.debug.DebugContext.Builder) DebugContext(org.graalvm.compiler.debug.DebugContext) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Example 13 with Builder

use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.

the class Stub method openDebugContext.

private DebugContext openDebugContext(DebugContext outer) {
    if (DebugStubsAndSnippets.getValue(options)) {
        Description description = new Description(linkage, "Stub_" + nextStubId.incrementAndGet());
        GraalDebugHandlersFactory factory = new GraalDebugHandlersFactory(providers.getSnippetReflection());
        return new Builder(options, factory).globalMetrics(outer.getGlobalMetrics()).description(description).build();
    }
    return DebugContext.disabled(options);
}
Also used : Description(org.graalvm.compiler.debug.DebugContext.Description) HotSpotCompiledCodeBuilder(org.graalvm.compiler.hotspot.HotSpotCompiledCodeBuilder) Builder(org.graalvm.compiler.debug.DebugContext.Builder) GraalDebugHandlersFactory(org.graalvm.compiler.printer.GraalDebugHandlersFactory)

Example 14 with Builder

use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.

the class GraalTest method getDebugContext.

/**
 * Gets a {@link DebugContext} object corresponding to {@code options}, creating a new one if
 * none currently exists. Debug contexts created by this method will have their
 * {@link DebugDumpHandler}s closed in {@link #afterTest()}.
 *
 * @param options currently active options
 * @param id identification of the compilation or {@code null}
 * @param method method to use for a proper description of the context or {@code null}
 * @return configured context for compilation
 */
protected DebugContext getDebugContext(OptionValues options, String id, ResolvedJavaMethod method) {
    List<DebugContext> cached = cachedDebugs.get();
    if (cached == null) {
        cached = new ArrayList<>();
        cachedDebugs.set(cached);
    }
    for (DebugContext debug : cached) {
        if (debug.getOptions() == options) {
            return debug;
        }
    }
    final DebugContext.Description descr;
    if (method == null) {
        descr = NO_DESCRIPTION;
    } else {
        descr = new DebugContext.Description(method, id == null ? method.getName() : id);
    }
    DebugContext debug = new Builder(options, getDebugHandlersFactories()).globalMetrics(globalMetrics).description(descr).build();
    cached.add(debug);
    return debug;
}
Also used : Builder(org.graalvm.compiler.debug.DebugContext.Builder) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 15 with Builder

use of org.graalvm.compiler.debug.DebugContext.Builder in project graal by oracle.

the class IsolatedGraalUtils method compileInNewIsolate0.

@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class)
@CEntryPointOptions(publishAs = CEntryPointOptions.Publish.NotPublished)
private static void compileInNewIsolate0(@SuppressWarnings("unused") @CEntryPoint.IsolateThreadContext CompilerIsolateThread isolate, ClientIsolateThread clientIsolate, ImageHeapRef<SubstrateMethod> methodRef) {
    IsolatedCompileContext.set(new IsolatedCompileContext(clientIsolate));
    try (DebugContext debug = new Builder(RuntimeOptionValues.singleton(), new GraalDebugHandlersFactory(GraalSupport.getRuntimeConfig().getSnippetReflection())).build()) {
        SubstrateGraalUtils.doCompile(debug, GraalSupport.getRuntimeConfig(), GraalSupport.getSuites(), GraalSupport.getLIRSuites(), ImageHeapObjects.deref(methodRef));
    }
    IsolatedCompileContext.set(null);
}
Also used : Builder(org.graalvm.compiler.debug.DebugContext.Builder) DebugContext(org.graalvm.compiler.debug.DebugContext) GraalDebugHandlersFactory(org.graalvm.compiler.printer.GraalDebugHandlersFactory) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Aggregations

Builder (org.graalvm.compiler.debug.DebugContext.Builder)31 DebugContext (org.graalvm.compiler.debug.DebugContext)27 OptionValues (org.graalvm.compiler.options.OptionValues)21 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)10 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)9 GraalDebugHandlersFactory (org.graalvm.compiler.printer.GraalDebugHandlersFactory)8 Test (org.junit.Test)8 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)7 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)7 Providers (org.graalvm.compiler.phases.util.Providers)7 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)6 Method (java.lang.reflect.Method)5 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)5 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)5 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)5 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)5 PhaseSuite (org.graalvm.compiler.phases.PhaseSuite)5 RuntimeProvider (org.graalvm.compiler.runtime.RuntimeProvider)5 IOException (java.io.IOException)4 OptionKey (org.graalvm.compiler.options.OptionKey)4