Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java @ 5176:af59b4dfc9e4
compilation queue changes:
* new CiCompilationStatistics
* added new HotSpot compilation policy (-XX:CompilationPolicyChoice=4)
* compile queue prioritizing (-G:+PriorityCompileQueue)
* low-priority compilation threads (-G:+SlowCompileThreads)
* dynamic compilation thread priority adjustment (-G:+DynamicCompilePriority)
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Thu, 29 Mar 2012 18:43:30 +0200 |
parents | 4d8ebb0fc484 |
children | a26b6248d398 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Mar 29 13:23:34 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Mar 29 18:43:30 2012 +0200 @@ -22,40 +22,73 @@ */ package com.oracle.graal.hotspot; +import java.io.*; import java.util.concurrent.*; import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.phases.*; import com.oracle.graal.debug.*; +import com.oracle.graal.hotspot.ri.*; import com.oracle.graal.nodes.*; import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.max.criutils.*; -public final class CompilationTask implements Runnable { +public final class CompilationTask implements Runnable, Comparable<CompilationTask> { + + private volatile boolean cancelled; private final Compiler compiler; private final PhasePlan plan; - private final RiResolvedMethod method; + private final HotSpotMethodResolved method; private final OptimisticOptimizations optimisticOpts; + private final int id; + private final int priority; - public static CompilationTask create(Compiler compiler, PhasePlan plan, OptimisticOptimizations optimisticOpts, RiResolvedMethod method) { - return new CompilationTask(compiler, plan, optimisticOpts, method); + public static CompilationTask create(Compiler compiler, PhasePlan plan, OptimisticOptimizations optimisticOpts, HotSpotMethodResolved method, int id, int priority) { + return new CompilationTask(compiler, plan, optimisticOpts, method, id, priority); } - private CompilationTask(Compiler compiler, PhasePlan plan, OptimisticOptimizations optimisticOpts, RiResolvedMethod method) { + private CompilationTask(Compiler compiler, PhasePlan plan, OptimisticOptimizations optimisticOpts, HotSpotMethodResolved method, int id, int priority) { this.compiler = compiler; this.plan = plan; this.method = method; this.optimisticOpts = optimisticOpts; + this.id = id; + this.priority = priority; + } + + public RiResolvedMethod method() { + return method; + } + + public int priority() { + return priority; } + public void cancel() { + cancelled = true; + } + + private static PrintStream out = System.out; + public void run() { + if (cancelled) { + return; + } + if (GraalOptions.DynamicCompilePriority) { + int threadPriority = priority < GraalOptions.SlowQueueCutoff ? Thread.NORM_PRIORITY : Thread.MIN_PRIORITY; + if (Thread.currentThread().getPriority() != threadPriority) { +// out.print(threadPriority); + Thread.currentThread().setPriority(threadPriority); + } + } + CiCompilationStatistics stats = CiCompilationStatistics.create(method); try { final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed(); if (printCompilation) { - TTY.println(String.format("Graal %-70s %-45s %-50s ...", method.holder().name(), method.name(), method.signature().asString())); + TTY.println(String.format("%-6d Graal %-70s %-45s %-50s ...", id, method.holder().name(), method.name(), method.signature().asString())); } CiTargetMethod result = null; @@ -72,7 +105,7 @@ } finally { filter.remove(); if (printCompilation) { - TTY.println(String.format("Graal %-70s %-45s %-50s | %4dnodes %5dB", "", "", "", 0, (result != null ? result.targetCodeSize() : -1))); + TTY.println(String.format("%-6d Graal %-70s %-45s %-50s | %4dnodes %5dB", id, "", "", "", 0, (result != null ? result.targetCodeSize() : -1))); } } compiler.getRuntime().installMethod(method, result); @@ -88,6 +121,21 @@ System.exit(-1); } } + stats.finish(method); + if (method.currentTask() == this) { + method.setCurrentTask(null); + } + } + + @Override + public int compareTo(CompilationTask o) { + if (priority < o.priority) { + return -1; + } + if (priority > o.priority) { + return 1; + } + return id < o.id ? -1 : (id > o.id ? 1 : 0); } }