# HG changeset patch # User Thomas Wuerthinger # Date 1326232817 -3600 # Node ID 176d60b77d3100c836b675c924b6f0e7ab48277d # Parent 504bc518a58256038fe7d211e7dc89b37cecef0e Moved PrintCompilation logic from graal.compiler to graal.hotspot. Made bootclasspath generated from the GRAAL environment option more generic (such that adding/removing a project requires no changes in the C++ part). diff -r 504bc518a582 -r 176d60b77d31 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java Tue Jan 10 20:14:08 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java Tue Jan 10 23:00:17 2012 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler; +import static com.oracle.max.graal.debug.Debug.*; + import java.util.*; import com.oracle.max.cri.ci.*; @@ -32,6 +34,7 @@ import com.oracle.max.graal.compiler.stub.*; import com.oracle.max.graal.compiler.target.*; import com.oracle.max.graal.cri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.nodes.*; public class GraalCompiler { @@ -81,20 +84,7 @@ } public CiTargetMethod compileMethod(RiResolvedMethod method, StructuredGraph graph, int osrBCI, CiStatistics stats, CiCompiler.DebugInfoLevel debugInfoLevel, PhasePlan plan) { - context.timers.startScope(getClass()); - try { - long startTime = 0; - int index = context.metrics.CompiledMethods++; - final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed(); - if (printCompilation) { - TTY.println(String.format("Graal %4d %-70s %-45s %-50s ...", - index, - method.holder().name(), - method.name(), - method.signature().asString())); - startTime = System.nanoTime(); - } - + try (Scope scope = openScope("CompileMethod", method)) { CiTargetMethod result = null; TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method); GraalCompilation compilation = new GraalCompilation(context, this, method, graph, osrBCI, stats, debugInfoLevel); @@ -102,23 +92,8 @@ result = compilation.compile(plan); } finally { filter.remove(); - if (printCompilation) { - long time = (System.nanoTime() - startTime) / 100000; - TTY.println(String.format("Graal %4d %-70s %-45s %-50s | %3d.%dms %4dnodes %5dB", - index, - "", - "", - "", - time / 10, - time % 10, - compilation.graph.getNodeCount(), - (result != null ? result.targetCodeSize() : -1))); - } } - return result; - } finally { - context.timers.endScope(); } } diff -r 504bc518a582 -r 176d60b77d31 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java --- a/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java Tue Jan 10 20:14:08 2012 +0100 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java Tue Jan 10 23:00:17 2012 +0100 @@ -44,7 +44,7 @@ private static final Scope VOID_SCOPE = new Scope(null); - public static final class Scope implements Closeable { + public static final class Scope implements AutoCloseable { private String name; private Object[] context; @@ -54,7 +54,7 @@ } @Override - public void close() throws IOException { + public void close() { } } diff -r 504bc518a582 -r 176d60b77d31 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Tue Jan 10 20:14:08 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Tue Jan 10 23:00:17 2012 +0100 @@ -46,6 +46,7 @@ public class VMToCompilerImpl implements VMToCompiler, Remote { private final Compiler compiler; + private int compiledMethodCount; public final HotSpotTypePrimitive typeBoolean; public final HotSpotTypePrimitive typeChar; @@ -170,7 +171,37 @@ PhasePlan plan = new PhasePlan(); GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime(), null); plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); - CiTargetMethod result = compiler.getCompiler().compileMethod(method, -1, null, DebugInfoLevel.FULL, plan); + long startTime = 0; + int index = compiledMethodCount++; + final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed(); + if (printCompilation) { + TTY.println(String.format("Graal %4d %-70s %-45s %-50s ...", + index, + method.holder().name(), + method.name(), + method.signature().asString())); + startTime = System.nanoTime(); + } + + CiTargetMethod result = null; + TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method); + try { + result = compiler.getCompiler().compileMethod(method, -1, null, DebugInfoLevel.FULL, plan); + } finally { + filter.remove(); + if (printCompilation) { + long time = (System.nanoTime() - startTime) / 100000; + TTY.println(String.format("Graal %4d %-70s %-45s %-50s | %3d.%dms %4dnodes %5dB", + index, + "", + "", + "", + time / 10, + time % 10, + 0, + (result != null ? result.targetCodeSize() : -1))); + } + } HotSpotTargetMethod.installMethod(compiler, method, result, true); } catch (CiBailout bailout) { if (GraalOptions.ExitVMOnBailout) { diff -r 504bc518a582 -r 176d60b77d31 src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Tue Jan 10 20:14:08 2012 +0100 +++ b/src/share/vm/runtime/arguments.cpp Tue Jan 10 23:00:17 2012 +0100 @@ -2096,20 +2096,22 @@ } } if (PrintVMOptions) tty->print_cr("GRAAL=%s", graal_dir); - + SysClassPath scp_compiler(Arguments::get_sysclasspath()); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.cri"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.criutils"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.base"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.asmdis"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.asm"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.graph"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.compiler"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.nodes"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.snippets"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.hotspot"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.printer"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.java"); + struct dirent* dentry; + char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(graal_dir)); + errno = 0; + DIR* graal_dir_handle = os::opendir(graal_dir); + while ((dentry = os::readdir(graal_dir_handle, (struct dirent *)tdbuf)) != NULL) { + if (strcmp(dentry->d_name, ".") != 0 && strcmp(dentry->d_name, "..")) { + prepend_to_graal_classpath(scp_compiler, graal_dir, dentry->d_name); + if (PrintVMOptions) { + tty->print_cr("Adding project directory %s to bootclasspath", dentry->d_name); + } + } + } + os::closedir(graal_dir_handle); + FREE_C_HEAP_ARRAY(char, tdbuf); scp_compiler.expand_endorsed(); Arguments::set_compilerclasspath(scp_compiler.combined_path());