# HG changeset patch # User Christian Wirth # Date 1382096981 -7200 # Node ID b4b7d39cdf73b58c727a9a485532c139a9ed77c7 # Parent a5d83166dca6e56d89ba46a56e1283fad7974bb8 Truffle: Update for the CompilationPolicy diff -r a5d83166dca6 -r b4b7d39cdf73 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationPolicy.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationPolicy.java Thu Oct 17 19:59:25 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationPolicy.java Fri Oct 18 13:49:41 2013 +0200 @@ -31,17 +31,21 @@ private int loopAndInvokeCounter; private long prevTimestamp; - private final int initialInvokeCounter; private final int compilationThreshold; + private final String name; - public CompilationPolicy(final int compilationThreshold, final int initialInvokeCounter) { + public CompilationPolicy(final int compilationThreshold, final int initialInvokeCounter, final String name) { this.invokeCounter = initialInvokeCounter; this.loopAndInvokeCounter = compilationThreshold; this.originalInvokeCounter = compilationThreshold; - this.prevTimestamp = System.currentTimeMillis(); + this.prevTimestamp = System.nanoTime(); this.compilationThreshold = compilationThreshold; - this.initialInvokeCounter = initialInvokeCounter; + this.name = name; + } + + public String getName() { + return this.name; } public int getInvokeCounter() { @@ -91,19 +95,23 @@ public boolean compileOrInline() { if (invokeCounter <= 0 && loopAndInvokeCounter <= 0) { if (TruffleUseTimeForCompilationDecision.getValue()) { - long timestamp = System.currentTimeMillis(); - if ((timestamp - prevTimestamp) < TruffleCompilationDecisionTime.getValue()) { + long timestamp = System.nanoTime(); + long timespan = (timestamp - prevTimestamp); + if (timespan < (TruffleCompilationDecisionTime.getValue())) { return true; } - this.invokeCounter = initialInvokeCounter; this.loopAndInvokeCounter = compilationThreshold; this.originalInvokeCounter = compilationThreshold; this.prevTimestamp = timestamp; + if (TruffleCompilationDecisionTimePrintFail.getValue()) { + // Checkstyle: stop + System.out.println(name + ": timespan " + (timespan / 1000000) + " ms larger than threshold"); + // Checkstyle: resume + } } else { return true; } } return false; } - } diff -r a5d83166dca6 -r b4b7d39cdf73 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Thu Oct 17 19:59:25 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Fri Oct 18 13:49:41 2013 +0200 @@ -46,7 +46,7 @@ protected OptimizedCallTarget(RootNode rootNode, FrameDescriptor descriptor, TruffleCompiler compiler, int invokeCounter, int compilationThreshold) { super(rootNode, descriptor); this.compiler = compiler; - this.compilationPolicy = new CompilationPolicy(compilationThreshold, invokeCounter); + this.compilationPolicy = new CompilationPolicy(compilationThreshold, invokeCounter, rootNode.toString()); this.rootNode.setCallTarget(this); if (TruffleCallTargetProfiling.getValue()) { diff -r a5d83166dca6 -r b4b7d39cdf73 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java Thu Oct 17 19:59:25 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java Fri Oct 18 13:49:41 2013 +0200 @@ -70,7 +70,12 @@ @Option(help = "") public static final OptionValue TruffleUseTimeForCompilationDecision = new OptionValue<>(false); @Option(help = "") - public static final OptionValue TruffleCompilationDecisionTime = new OptionValue<>(100); + public static final OptionValue TruffleCompilationDecisionTime = new OptionValue<>(100 * 1000000L); + @Option(help = "") + public static final OptionValue TruffleCompilationDecisionTimePrintFail = new OptionValue<>(false); + @Option(help = "") + public static final OptionValue TruffleBackgroundCompilation = new OptionValue<>(true); + // tracing @Option(help = "") public static final OptionValue TraceTruffleCompilation = new OptionValue<>(true);