# HG changeset patch # User Tom Rodriguez # Date 1427138485 25200 # Node ID dab7f071220a7b0cc723d57eb4a8de3f240bad6c # Parent 8ea3dde07ff710ba0ed177aa9d4985c02157a709 Wait until all classes are loaded before compiling in multithreaded CTW diff -r 8ea3dde07ff7 -r dab7f071220a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Mon Mar 23 12:20:49 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Mon Mar 23 12:21:25 2015 -0700 @@ -160,6 +160,11 @@ private boolean verbose; private final Config config; + /** + * Signal that the threads should start compiling in multithreaded mode. + */ + private boolean running; + private ThreadPoolExecutor threadPool; /** @@ -327,6 +332,7 @@ } if (threadPool != null) { + startThreads(); while (threadPool.getCompletedTaskCount() != threadPool.getTaskCount()) { System.out.println("CompileTheWorld : Waiting for " + (threadPool.getTaskCount() - threadPool.getCompletedTaskCount()) + " compiles"); try { @@ -344,6 +350,21 @@ compileTime.get(), memoryUsed.get()); } + private synchronized void startThreads() { + running = true; + // Wake up any waiting threads + notifyAll(); + } + + private synchronized void waitToRun() { + while (!running) { + try { + wait(); + } catch (InterruptedException e) { + } + } + } + class CTWCompilationTask extends CompilationTask { CTWCompilationTask(HotSpotBackend backend, HotSpotResolvedJavaMethod method) { @@ -364,6 +385,7 @@ if (threadPool != null) { threadPool.submit(new Runnable() { public void run() { + waitToRun(); try (OverrideScope s = config.apply()) { compileMethod(method, classFileCounter); }