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");
}
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;
}
}
}
}
}
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);
}
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);
}
}
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);
}
Aggregations