Search in sources :

Example 11 with Scope

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

the class GraphResetDebugTest method test1.

@SuppressWarnings("try")
@Test
public void test1() {
    EconomicMap<OptionKey<?>, Object> map = EconomicMap.create();
    // Configure with an option that enables scopes
    map.put(DebugOptions.DumpOnError, true);
    DebugContext debug = getDebugContext(new OptionValues(map));
    StructuredGraph graph = parseEager("testSnippet", AllowAssumptions.YES, debug);
    boolean resetSucceeded = false;
    try (Scope scope = debug.scope("some scope")) {
        graph.resetDebug(DebugContext.DISABLED);
        resetSucceeded = true;
    } catch (AssertionError expected) {
    }
    Assert.assertFalse(resetSucceeded);
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Scope(org.graalvm.compiler.debug.DebugContext.Scope) OptionKey(org.graalvm.compiler.options.OptionKey) DebugContext(org.graalvm.compiler.debug.DebugContext) Test(org.junit.Test)

Example 12 with Scope

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

the class DerivedOopTest method testFieldOffsetMergeLiveBasePointer.

@Test
@SuppressWarnings("try")
public void testFieldOffsetMergeLiveBasePointer() {
    thrown.expect(GraalError.class);
    thrown.expectMessage(UNKNOWN_REFERENCE_AT_SAFEPOINT_MSG);
    DebugContext debug = getDebugContext();
    try (Scope s = debug.disable()) {
        // Run a couple times to encourage objects to move
        for (int i = 0; i < 4; i++) {
            Result r = new Result();
            test("fieldOffsetMergeSnippet03", r, new Result(), new Result(), 8L, 16L);
            Assert.assertEquals(r.beforeGC.delta(), r.afterGC.delta());
        }
    }
}
Also used : Scope(org.graalvm.compiler.debug.DebugContext.Scope) DebugContext(org.graalvm.compiler.debug.DebugContext) Test(org.junit.Test)

Example 13 with Scope

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

the class DebugContextTest method testEnabledSandbox.

@Test
public void testEnabledSandbox() {
    EconomicMap<OptionKey<?>, Object> map = EconomicMap.create();
    // Configure with an option that enables scopes
    map.put(DebugOptions.DumpOnError, true);
    OptionValues options = new OptionValues(map);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DebugContext debug = DebugContext.create(options, NO_DESCRIPTION, NO_GLOBAL_METRIC_VALUES, new PrintStream(baos), DebugHandlersFactory.LOADER);
    Exception e = new Exception("testEnabledSandbox");
    String scopeName = "";
    try {
        try (DebugContext.Scope d = debug.sandbox("TestExceptionHandling", debug.getConfig())) {
            scopeName = d.getQualifiedName();
            throw e;
        } catch (Throwable t) {
            assert e == t;
            debug.handle(t);
        }
    } catch (Throwable t) {
        // The exception object should propagate all the way out through
        // a enabled sandbox scope
        Assert.assertEquals(e, t);
    }
    String logged = baos.toString();
    String expected = String.format("Exception raised in scope %s: %s", scopeName, e);
    String line = "-------------------------------------------------------";
    Assert.assertTrue(String.format("Could not find \"%s\" in content between lines below:%n%s%n%s%s", expected, line, logged, line), logged.contains(expected));
}
Also used : PrintStream(java.io.PrintStream) OptionValues(org.graalvm.compiler.options.OptionValues) Scope(org.graalvm.compiler.debug.DebugContext.Scope) OptionKey(org.graalvm.compiler.options.OptionKey) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DebugContext(org.graalvm.compiler.debug.DebugContext) IOException(java.io.IOException) Test(org.junit.Test)

Example 14 with Scope

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

the class GraphPrinter method getScheduleOrNull.

@SuppressWarnings("try")
static StructuredGraph.ScheduleResult getScheduleOrNull(Graph graph) {
    if (graph instanceof StructuredGraph) {
        StructuredGraph sgraph = (StructuredGraph) graph;
        StructuredGraph.ScheduleResult scheduleResult = sgraph.getLastSchedule();
        if (scheduleResult == null) {
            DebugContext debug = graph.getDebug();
            try (Scope scope = debug.disable()) {
                SchedulePhase schedule = new SchedulePhase(graph.getOptions());
                schedule.apply(sgraph);
                scheduleResult = sgraph.getLastSchedule();
            } catch (Throwable t) {
            }
        }
        return scheduleResult;
    }
    return null;
}
Also used : SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Scope(org.graalvm.compiler.debug.DebugContext.Scope) DebugContext(org.graalvm.compiler.debug.DebugContext)

Aggregations

DebugContext (org.graalvm.compiler.debug.DebugContext)14 Scope (org.graalvm.compiler.debug.DebugContext.Scope)14 Test (org.junit.Test)9 OptionValues (org.graalvm.compiler.options.OptionValues)5 IOException (java.io.IOException)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 OptionKey (org.graalvm.compiler.options.OptionKey)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)2 GraalError (org.graalvm.compiler.debug.GraalError)2 TruffleOptionsOverrideScope (org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope)2 List (java.util.List)1 ServiceConfigurationError (java.util.ServiceConfigurationError)1 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 SPARC (jdk.vm.ci.sparc.SPARC)1 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)1 PermanentBailoutException (org.graalvm.compiler.core.common.PermanentBailoutException)1 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)1