Search in sources :

Example 46 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class DebugContext method forceLog.

public DebugContext.Scope forceLog() throws Throwable {
    if (currentConfig != null) {
        ArrayList<Object> context = new ArrayList<>();
        for (Object obj : context()) {
            context.add(obj);
        }
        DebugConfigImpl config = new DebugConfigImpl(new OptionValues(currentConfig.getOptions(), DebugOptions.Log, ":1000"));
        return sandbox("forceLog", config, context.toArray());
    }
    return null;
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) ArrayList(java.util.ArrayList)

Example 47 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class DebugContext method forceDump.

/**
 * Forces an unconditional dump. This method exists mainly for debugging. It can also be used to
 * force a graph dump from IDEs that support invoking a Java method while at a breakpoint.
 */
public void forceDump(Object object, String format, Object... args) {
    DebugConfig config = currentConfig;
    Collection<DebugDumpHandler> dumpHandlers;
    boolean closeAfterDump;
    if (config != null) {
        dumpHandlers = config.dumpHandlers();
        closeAfterDump = false;
    } else {
        OptionValues options = getOptions();
        dumpHandlers = new ArrayList<>();
        for (DebugHandlersFactory factory : DebugHandlersFactory.LOADER) {
            for (DebugHandler handler : factory.createHandlers(options)) {
                if (handler instanceof DebugDumpHandler) {
                    dumpHandlers.add((DebugDumpHandler) handler);
                }
            }
        }
        closeAfterDump = true;
    }
    for (DebugDumpHandler dumpHandler : dumpHandlers) {
        dumpHandler.dump(this, object, format, args);
        if (closeAfterDump) {
            dumpHandler.close();
        }
    }
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues)

Example 48 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class NodeBitMapTest method before.

@Before
public void before() {
    // Need to initialize HotSpotGraalRuntime before any Node class is initialized.
    Graal.getRuntime();
    OptionValues options = getOptions();
    graph = new Graph(options, getDebug(options));
    for (int i = 0; i < nodes.length; i++) {
        nodes[i] = graph.add(new TestNode());
    }
    map = graph.createNodeBitMap();
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Before(org.junit.Before)

Example 49 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class NodeMapTest method before.

@Before
public void before() {
    // Need to initialize HotSpotGraalRuntime before any Node class is initialized.
    Graal.getRuntime();
    OptionValues options = getOptions();
    graph = new Graph(options, getDebug(options));
    for (int i = 0; i < nodes.length; i++) {
        nodes[i] = graph.add(new TestNode());
    }
    map = new NodeMap<>(graph);
    for (int i = 0; i < nodes.length; i += 2) {
        map.set(nodes[i], i);
    }
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Before(org.junit.Before)

Example 50 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class NodeUsagesTests method testReplaceAtUsagesWithPredicateAll.

@Test
public void testReplaceAtUsagesWithPredicateAll() {
    OptionValues options = getOptions();
    Graph graph = new Graph(options, getDebug(options));
    Def def0 = graph.add(new Def());
    Def def1 = graph.add(new Def());
    Use use0 = graph.add(new Use(def0, null, null));
    Use use1 = graph.add(new Use(null, def0, null));
    Use use2 = graph.add(new Use(null, null, def0));
    assertEquals(3, def0.getUsageCount());
    assertThat(def0.usages(), contains(use0));
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), isNotEmpty());
    assertThat(def1.usages(), isEmpty());
    def0.replaceAtMatchingUsages(def1, u -> true);
    assertThat(def0.usages(), isEmpty());
    assertEquals(3, def1.getUsageCount());
    assertThat(def1.usages(), contains(use0));
    assertThat(def1.usages(), contains(use1));
    assertThat(def1.usages(), contains(use2));
    assertThat(def1.usages(), isNotEmpty());
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Test(org.junit.Test)

Aggregations

OptionValues (org.graalvm.compiler.options.OptionValues)158 Test (org.junit.Test)65 DebugContext (org.graalvm.compiler.debug.DebugContext)50 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)36 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)30 Graph (org.graalvm.compiler.graph.Graph)22 OptionKey (org.graalvm.compiler.options.OptionKey)16 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)13 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)11 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)10 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)10 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)10 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)9 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)9 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)9 Providers (org.graalvm.compiler.phases.util.Providers)9 IOException (java.io.IOException)8 Method (java.lang.reflect.Method)8 CompilationResult (org.graalvm.compiler.code.CompilationResult)7 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)7