Search in sources :

Example 71 with OptionValues

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

the class MemoryUsageBenchmark method run.

public void run() {
    compileAndTime("simple");
    compileAndTime("complex");
    OptionValues options = CompileTheWorld.loadOptions(getInitialOptions());
    if (CompileTheWorld.Options.Classpath.getValue(options) != CompileTheWorld.SUN_BOOT_CLASS_PATH) {
        HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
        CompileTheWorld ctw = new CompileTheWorld(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), options);
        try {
            ctw.compile();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    allocSpyCompilation("simple");
    allocSpyCompilation("complex");
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) HotSpotJVMCIRuntimeProvider(jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider)

Example 72 with OptionValues

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

the class NoDeadCodeVerifyHandler method verify.

@Override
public void verify(DebugContext debug, Object object, String format, Object... args) {
    OptionValues options = debug.getOptions();
    if (Options.NDCV.getValue(options) != OFF && object instanceof StructuredGraph) {
        StructuredGraph graph = (StructuredGraph) object;
        List<Node> before = graph.getNodes().snapshot();
        new DeadCodeEliminationPhase().run(graph);
        List<Node> after = graph.getNodes().snapshot();
        assert after.size() <= before.size();
        if (before.size() != after.size()) {
            if (discovered.put(format, Boolean.TRUE) == null) {
                before.removeAll(after);
                String prefix = format == null ? "" : format + ": ";
                GraalError error = new GraalError("%sfound dead nodes in %s: %s", prefix, graph, before);
                if (Options.NDCV.getValue(options) == INFO) {
                    System.out.println(error.getMessage());
                } else if (Options.NDCV.getValue(options) == VERBOSE) {
                    error.printStackTrace(System.out);
                } else {
                    assert Options.NDCV.getValue(options) == FATAL;
                    throw error;
                }
            }
        }
    }
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GraalError(org.graalvm.compiler.debug.GraalError) Node(org.graalvm.compiler.graph.Node) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)

Example 73 with OptionValues

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

the class GraalCompilerTest method compile.

/**
 * Compiles a given method.
 *
 * @param installedCodeOwner the method the compiled code will be associated with when installed
 * @param graph the graph to be compiled for {@code installedCodeOwner}. If null, a graph will
 *            be obtained from {@code installedCodeOwner} via
 *            {@link #parseForCompile(ResolvedJavaMethod)}.
 */
protected final CompilationResult compile(ResolvedJavaMethod installedCodeOwner, StructuredGraph graph) {
    OptionValues options = graph == null ? getInitialOptions() : graph.getOptions();
    CompilationIdentifier compilationId = getOrCreateCompilationId(installedCodeOwner, graph);
    return compile(installedCodeOwner, graph, new CompilationResult(compilationId), compilationId, options);
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) OptionValues(org.graalvm.compiler.options.OptionValues) CompilationResult(org.graalvm.compiler.code.CompilationResult)

Example 74 with OptionValues

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

the class GraalDebugHandlersFactoryTest method createUniqueTest.

@Test
public void createUniqueTest() throws Exception {
    Field maxFileNameLengthField = PathUtilities.class.getDeclaredField("MAX_FILE_NAME_LENGTH");
    try {
        maxFileNameLengthField.setAccessible(true);
    } catch (RuntimeException ex) {
        Assume.assumeFalse("If InaccessibleObjectException is thrown, skip the test, we are on JDK9", ex.getClass().getSimpleName().equals("InaccessibleObjectException"));
    }
    int maxFileNameLength = maxFileNameLengthField.getInt(null);
    Method createUniqueMethod = PathUtilities.class.getDeclaredMethod("createUnique", OptionValues.class, OptionKey.class, String.class, String.class, String.class, boolean.class);
    createUniqueMethod.setAccessible(true);
    Path tmpDir = Files.createTempDirectory(Paths.get("."), "createUniqueTest");
    OptionValues options = new OptionValues(OptionValues.asMap(DebugOptions.DumpPath, tmpDir.toString()));
    try {
        for (boolean createDirectory : new boolean[] { true, false }) {
            for (String ext : new String[] { "", ".bgv", ".graph-strings" }) {
                for (int i = 0; i < maxFileNameLength + 5; i++) {
                    String id = new String(new char[i]).replace('\0', 'i');
                    String label = "";
                    createUniqueMethod.invoke(null, options, null, id, label, ext, createDirectory);
                    id = "";
                    label = new String(new char[i]).replace('\0', 'l');
                    createUniqueMethod.invoke(null, options, null, id, label, ext, createDirectory);
                }
            }
        }
    } finally {
        deleteTree(tmpDir);
    }
}
Also used : Path(java.nio.file.Path) Field(java.lang.reflect.Field) OptionValues(org.graalvm.compiler.options.OptionValues) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 75 with OptionValues

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

the class DumpPathTest method testDump.

@Test
public void testDump() throws IOException {
    Path dumpDirectoryPath = Files.createTempDirectory("DumpPathTest");
    String[] extensions = new String[] { ".cfg", ".bgv", ".graph-strings" };
    EconomicMap<OptionKey<?>, Object> overrides = OptionValues.newOptionMap();
    overrides.put(DebugOptions.DumpPath, dumpDirectoryPath.toString());
    overrides.put(DebugOptions.PrintGraphFile, true);
    overrides.put(DebugOptions.PrintCanonicalGraphStrings, true);
    overrides.put(DebugOptions.Dump, "*");
    // Generate dump files.
    test(new OptionValues(getInitialOptions(), overrides), "snippet");
    // Check that Ideal files got created, in the right place.
    checkForFiles(dumpDirectoryPath, extensions);
    // Clean up the generated files.
    scrubDirectory(dumpDirectoryPath);
}
Also used : Path(java.nio.file.Path) OptionValues(org.graalvm.compiler.options.OptionValues) OptionKey(org.graalvm.compiler.options.OptionKey) 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