# HG changeset patch # User Doug Simon # Date 1404422915 -7200 # Node ID 4481cf549cfc7d47cb281f1b7300388905f18e90 # Parent c5ab3fbec257eb366feebd09c7de782e38cafd61 removed (Java based) CompilationQueue diff -r c5ab3fbec257 -r 4481cf549cfc CHANGELOG.md --- a/CHANGELOG.md Thu Jul 03 21:47:59 2014 +0200 +++ b/CHANGELOG.md Thu Jul 03 23:28:35 2014 +0200 @@ -6,6 +6,8 @@ * Added supported for new 'jrelibrary' dependency type in mx/projects. * Java projects with compliance level higher than the JDKs specified by JAVA_HOME and EXTRA_JAVA_HOMES are ignored once mx/projects has been processed. * ResolvedJavaType.resolveMethod now takes a context type used to perform access checks. It now works correctly regarding default methods. +* Removed Java based compilation queue (CompilationQueue.java). +* Enabled use of separate class loader (via -XX:+UseGraalClassLoader) for classes loaded from graal.jar to hide them from application classes. ### Truffle * `truffle.jar`: strip out build-time only dependency into a seperated JAR file (`truffle-dsl-processor.jar`) diff -r c5ab3fbec257 -r 4481cf549cfc graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java Thu Jul 03 21:47:59 2014 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java Thu Jul 03 23:28:35 2014 +0200 @@ -174,11 +174,7 @@ public static final OptionValue DecompileAfterPhase = new OptionValue<>(null); // HotSpot command line options - @Option(help = "") - public static final OptionValue HotSpotPrintCompilation = new OptionValue<>(false); - @Option(help = "") - public static final OptionValue HotSpotCIPrintCompilerName = new OptionValue<>(false); - @Option(help = "") + @Option(help = "Print inlining optimizations") public static final OptionValue HotSpotPrintInlining = new OptionValue<>(false); // Register allocator debugging diff -r c5ab3fbec257 -r 4481cf549cfc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationQueue.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationQueue.java Thu Jul 03 21:47:59 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,295 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.hotspot; - -import static com.oracle.graal.compiler.GraalDebugConfig.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static com.oracle.graal.hotspot.CompilationQueue.Options.*; -import static com.oracle.graal.hotspot.InitTimer.*; - -import java.lang.reflect.*; -import java.util.concurrent.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.*; -import com.oracle.graal.compiler.CompilerThreadFactory.DebugConfigAccess; -import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.CompilationTask.Enqueueing; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.options.*; -import com.oracle.graal.printer.*; - -//JaCoCo Exclude - -/** - * A queue for running {@link CompilationTask}s on background compilation thread(s). The singleton - * {@linkplain #queue() instance} is created the first time this class is accessed. - *

- * Note that this is independent of the HotSpot C++ {@code CompileQueue} used by the - * {@code CompileBroker}. - */ -public class CompilationQueue { - - static { - try (InitTimer t = timer("initialize CompilationQueue")) { - - // The Graal runtime needs to be initialized here to avoid - // issues re-entering Java code during compilation scheduling. - HotSpotGraalRuntime.runtime(); - - // Must be first to ensure any options accessed by the rest of the class - // initializer are initialized from the command line. - HotSpotOptions.initialize(); - - // The singleton queue instance is created the first time this class - queue = new CompilationQueue(); - } - } - - public static class Options { - - //@formatter:off - @Option(help = "Print compilation queue activity periodically") - private static final OptionValue PrintQueue = new OptionValue<>(false); - - @Option(help = "Interval in milliseconds at which to print compilation rate periodically. " + - "The compilation statistics are reset after each print out so this option " + - "is incompatible with -XX:+CITime and -XX:+CITimeEach.") - public static final OptionValue PrintCompRate = new OptionValue<>(0); - - @Option(help = "Print bootstrap progress and summary") - static final OptionValue PrintBootstrap = new OptionValue<>(true); - - @Option(help = "Time limit in milliseconds for bootstrap (-1 for no limit)") - static final OptionValue TimedBootstrap = new OptionValue<>(-1); - - @Option(help = "Number of compilation threads to use") - static final StableOptionValue Threads = new StableOptionValue() { - - @Override - public Integer initialValue() { - return Runtime.getRuntime().availableProcessors(); - } - }; - //@formatter:on - - } - - /** - * Prints and resets the Graal compilation rate statistics. - */ - private static native void printAndResetCompRate(); - - /** - * The singleton queue instance. - */ - private static final CompilationQueue queue; - - /** - * Gets the singleton queue instance. - */ - public static final CompilationQueue queue() { - assert queue != null; - return queue; - } - - /** - * The thread pool used to service the queue. - * - * Most access to the thread pool is wrapped to ensure that - * {@link CompilationTask#isWithinEnqueue} is in the proper state. - */ - final ThreadPoolExecutor executor; - - private CompilationQueue() { - CompilerThreadFactory factory = new CompilerThreadFactory("GraalCompilerThread", new DebugConfigAccess() { - public GraalDebugConfig getDebugConfig() { - return Debug.isEnabled() ? DebugEnvironment.initialize(HotSpotGraalRuntime.Options.LogFile.getStream()) : null; - } - }); - - executor = new ThreadPoolExecutor(Options.Threads.getValue(), Options.Threads.getValue(), 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue(), factory); - - // Create queue status printing thread. - if (Options.PrintQueue.getValue()) { - Thread t = new Thread() { - - @Override - public void run() { - while (true) { - TTY.println(CompilationQueue.this.toString()); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } - } - }; - t.setDaemon(true); - t.start(); - } - - if (Options.PrintCompRate.getValue() != 0) { - Thread t = new Thread() { - - @Override - public void run() { - while (true) { - printAndResetCompRate(); - try { - Thread.sleep(Options.PrintCompRate.getValue()); - } catch (InterruptedException e) { - } - } - } - }; - t.setDaemon(true); - t.start(); - } - } - - public long getCompletedTaskCount() { - try (Enqueueing enqueueing = new Enqueueing()) { - // Don't allow new enqueues while reading the state of queue. - return executor.getCompletedTaskCount(); - } - } - - public long getTaskCount() { - try (Enqueueing enqueueing = new Enqueueing()) { - // Don't allow new enqueues while reading the state of queue. - return executor.getTaskCount(); - } - } - - public void execute(CompilationTask task) { - // The caller is expected to have set the within enqueue state. - assert CompilationTask.isWithinEnqueue(); - executor.execute(task); - } - - /** - * Shuts down the compilation queue. - * - * Called from VM. - */ - private static void shutdown() throws Exception { - queue.executor.shutdownNow(); - if (Debug.isEnabled() && (Dump.getValue() != null || areMetricsOrTimersEnabled())) { - // Wait up to 2 seconds to flush out all graph dumps and stop metrics/timers - // being updated. - queue.executor.awaitTermination(2, TimeUnit.SECONDS); - } - } - - /** - * This method is the first method compiled during {@linkplain #bootstrap() bootstrapping}. Put - * any code in there that warms up compiler paths that are otherwise not exercised during - * bootstrapping and lead to later deoptimization when application code is compiled. - */ - @Deprecated - private synchronized void compileWarmup() { - // Method is synchronized to exercise the synchronization code in the compiler. - } - - /** - * Adds some compilation tasks to the queue and then loops until the queue has completed all its - * scheduled tasks or the timeout specified by {@link Options#TimedBootstrap} expires. - * - * Called from VM. - */ - private static void bootstrap() throws Throwable { - if (PrintBootstrap.getValue()) { - TTY.print("Bootstrapping Graal"); - TTY.flush(); - } - - long boostrapStartTime = System.currentTimeMillis(); - - boolean firstRun = true; - do { - // Initialize compile queue with a selected set of methods. - Class objectKlass = Object.class; - if (firstRun) { - enqueue(CompilationQueue.class.getDeclaredMethod("compileWarmup")); - enqueue(objectKlass.getDeclaredMethod("equals", Object.class)); - enqueue(objectKlass.getDeclaredMethod("toString")); - firstRun = false; - } else { - for (int i = 0; i < 100; i++) { - enqueue(CompilationQueue.class.getDeclaredMethod("bootstrap")); - } - } - - // Compile until the queue is empty. - int z = 0; - while (true) { - if (queue().getCompletedTaskCount() >= Math.max(3, queue().getTaskCount())) { - break; - } - - Thread.sleep(100); - while (z < queue().getCompletedTaskCount() / 100) { - ++z; - if (PrintBootstrap.getValue()) { - TTY.print("."); - TTY.flush(); - } - } - - // Are we out of time? - final int timedBootstrap = TimedBootstrap.getValue(); - if (timedBootstrap != -1) { - if ((System.currentTimeMillis() - boostrapStartTime) > timedBootstrap) { - break; - } - } - } - } while ((System.currentTimeMillis() - boostrapStartTime) <= TimedBootstrap.getValue()); - - if (ResetDebugValuesAfterBootstrap.getValue()) { - new DebugValuesPrinter().printDebugValues("bootstrap", true); - runtime().getCompilerToVM().resetCompilationStatistics(); - } - phaseTransition("bootstrap"); - - if (PrintBootstrap.getValue()) { - TTY.println(" in %d ms (compiled %d methods)", System.currentTimeMillis() - boostrapStartTime, queue().getCompletedTaskCount()); - } - - System.gc(); - phaseTransition("bootstrap2"); - } - - private static void enqueue(Method m) throws Throwable { - JavaMethod javaMethod = runtime().getHostProviders().getMetaAccess().lookupJavaMethod(m); - assert !((HotSpotResolvedJavaMethod) javaMethod).isAbstract() && !((HotSpotResolvedJavaMethod) javaMethod).isNative() : javaMethod; - CompilationTask.compileMethod((HotSpotResolvedJavaMethod) javaMethod, StructuredGraph.INVOCATION_ENTRY_BCI, 0L, false); - } - - @Override - public String toString() { - return executor.toString(); - } -} diff -r c5ab3fbec257 -r 4481cf549cfc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Jul 03 21:47:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Jul 03 23:28:35 2014 +0200 @@ -27,30 +27,24 @@ import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.compiler.common.UnsafeAccess.*; -import static com.oracle.graal.hotspot.CompilationQueue.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import static com.oracle.graal.hotspot.InitTimer.*; import static com.oracle.graal.nodes.StructuredGraph.*; import static com.oracle.graal.phases.common.inlining.InliningUtil.*; -import java.io.*; import java.lang.management.*; -import java.security.*; import java.util.*; import java.util.concurrent.*; -import java.util.concurrent.atomic.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; import com.oracle.graal.baseline.*; -import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.debug.internal.*; -import com.oracle.graal.hotspot.CompilationQueue.Options; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.events.*; import com.oracle.graal.hotspot.events.EventProvider.CompilationEvent; @@ -65,11 +59,9 @@ import com.oracle.graal.phases.tiers.*; import com.oracle.graal.printer.*; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - //JaCoCo Exclude -public class CompilationTask implements Runnable, Comparable { +public class CompilationTask { static { try (InitTimer t = timer("initialize CompilationTask")) { @@ -79,92 +71,33 @@ } } - // Keep static finals in a group with withinEnqueue as the last one. CompilationTask can be - // called from within it's own clinit so it needs to be careful about accessing state. Once - // withinEnqueue is non-null we assume that CompilationTask is fully initialized. - private static final AtomicLong uniqueTaskIds = new AtomicLong(); - private static final DebugMetric BAILOUTS = Debug.metric("Bailouts"); - private static final ThreadLocal withinEnqueue = new ThreadLocal() { - - @Override - protected Boolean initialValue() { - return Boolean.valueOf(Thread.currentThread() instanceof CompilerThread); - } - }; - - public static final boolean isWithinEnqueue() { - // It's possible this can be called before the has completed so check for null - return withinEnqueue == null || withinEnqueue.get(); - } - - public static class Enqueueing implements Closeable { - public Enqueueing() { - assert !withinEnqueue.get(); - withinEnqueue.set(Boolean.TRUE); - } - - public void close() { - withinEnqueue.set(Boolean.FALSE); - } - } - - private enum CompilationStatus { - Queued, - Running, - Finished - } - private final HotSpotBackend backend; private final HotSpotResolvedJavaMethod method; private final int entryBCI; private final int id; - private final AtomicReference status; - - /** - * The executor processing the Graal compilation queue this task was placed on. This will be - * null for blocking compilations or if compilations are scheduled as native HotSpot - * {@linkplain #ctask CompileTask}s. - */ - private final ExecutorService executor; private StructuredGraph graph; /** - * A long representing the sequence number of this task. Used for sorting the compile queue. - */ - private long taskId; - - private boolean blocking; - - /** * A {@link com.sun.management.ThreadMXBean} to be able to query some information about the * current compiler thread, e.g. total allocated bytes. */ private static final com.sun.management.ThreadMXBean threadMXBean = (com.sun.management.ThreadMXBean) ManagementFactory.getThreadMXBean(); /** - * The address of the native CompileTask associated with this compilation. If 0L, then this - * compilation is being managed by a Graal compilation queue otherwise its managed by a native - * HotSpot compilation queue. + * The address of the native CompileTask associated with this compilation or 0L if no such + * association exists. */ private final long ctask; - public CompilationTask(ExecutorService executor, HotSpotBackend backend, HotSpotResolvedJavaMethod method, int entryBCI, long ctask, boolean blocking) { - this.executor = executor; + public CompilationTask(HotSpotBackend backend, HotSpotResolvedJavaMethod method, int entryBCI, long ctask, int id) { this.backend = backend; this.method = method; this.entryBCI = entryBCI; - if (ctask == 0L) { - this.id = method.allocateCompileId(entryBCI); - } else { - this.id = unsafe.getInt(ctask + backend.getRuntime().getConfig().compileTaskCompileIdOffset); - } + this.id = id; this.ctask = ctask; - this.blocking = blocking; - this.taskId = uniqueTaskIds.incrementAndGet(); - this.status = new AtomicReference<>(CompilationStatus.Queued); } public ResolvedJavaMethod getMethod() { @@ -184,49 +117,6 @@ return entryBCI; } - @SuppressFBWarnings(value = "NN_NAKED_NOTIFY") - public void run() { - withinEnqueue.set(Boolean.FALSE); - try { - runCompilation(); - } finally { - withinEnqueue.set(Boolean.TRUE); - status.set(CompilationStatus.Finished); - synchronized (this) { - notifyAll(); - } - } - } - - /** - * Block waiting till the compilation completes. - */ - public synchronized void block() { - while (status.get() != CompilationStatus.Finished) { - try { - wait(); - } catch (InterruptedException e) { - // Ignore and retry - } - } - } - - /** - * Sort blocking tasks before non-blocking ones and then by lowest taskId within the group. - */ - public int compareTo(Object o) { - if (!(o instanceof CompilationTask)) { - return 1; - } - CompilationTask task2 = (CompilationTask) o; - if (this.blocking != task2.blocking) { - // Blocking CompilationTasks are always higher than CompilationTasks - return task2.blocking ? 1 : -1; - } - // Within the two groups sort by sequence id, so they are processed in insertion order. - return this.taskId > task2.taskId ? 1 : -1; - } - /** * Time spent in compilation. */ @@ -264,18 +154,6 @@ } public void runCompilation() { - if (executor != null && executor.isShutdown()) { - // We don't want to do any unnecessary compilation if the Graal compilation - // queue has been shutdown. Note that we leave the JVM_ACC_QUEUED bit set - // for the method so that it won't be re-scheduled for compilation. - return; - } - - /* - * no code must be outside this try/finally because it could happen otherwise that - * clearQueuedForCompilation() is not executed - */ - HotSpotVMConfig config = backend.getRuntime().getConfig(); final long threadId = Thread.currentThread().getId(); long previousInlinedBytecodes = InlinedBytecodes.getCurrentValue(); @@ -288,10 +166,6 @@ CompilationEvent compilationEvent = eventProvider.newCompilationEvent(); try (TimerCloseable a = CompilationTime.start()) { - if (!tryToChangeStatus(CompilationStatus.Queued, CompilationStatus.Running)) { - return; - } - // If there is already compiled code for this method on our level we simply return. // Graal compiles are always at the highest compile level, even in non-tiered mode so we // only need to check for that value. @@ -304,9 +178,6 @@ if (printCompilation) { TTY.println(getMethodDescription() + "..."); } - if (HotSpotPrintCompilation.getValue()) { - printCompilation(); - } CompilationResult result = null; TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method); @@ -426,21 +297,16 @@ compilationEvent.commit(); } - if (ctask != 0L) { + if (ctask != 0) { unsafe.putInt(ctask + config.compileTaskNumInlinedBytecodesOffset, processedBytes); } - if ((config.ciTime || config.ciTimeEach || Options.PrintCompRate.getValue() != 0) && installedCode != null) { + if ((config.ciTime || config.ciTimeEach) && installedCode != null) { long time = CompilationTime.getCurrentValue() - previousCompilationTime; TimeUnit timeUnit = CompilationTime.getTimeUnit(); long timeUnitsPerSecond = timeUnit.convert(1, TimeUnit.SECONDS); CompilerToVM c2vm = backend.getRuntime().getCompilerToVM(); c2vm.notifyCompilationStatistics(id, method, entryBCI != INVOCATION_ENTRY_BCI, processedBytes, time, timeUnitsPerSecond, installedCode); } - - if (executor != null) { - assert method.isQueuedForCompilation(); - method.clearQueuedForCompilation(); - } } } @@ -449,32 +315,6 @@ entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") "); } - /** - * Print a HotSpot-style compilation message to the console. - */ - private void printCompilation() { - final boolean isOSR = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; - String compilerName = ""; - if (HotSpotCIPrintCompilerName.getValue()) { - compilerName = "Graal:"; - } - HotSpotVMConfig config = backend.getRuntime().getConfig(); - int compLevel = config.compilationLevelFullOptimization; - String compLevelString; - if (config.tieredCompilation) { - compLevelString = "- "; - if (compLevel != -1) { - compLevelString = (char) ('0' + compLevel) + " "; - } - } else { - compLevelString = ""; - } - boolean hasExceptionHandlers = method.getExceptionHandlers().length > 0; - TTY.println(String.format("%s%7d %4d %c%c%c%c%c %s %s %s(%d bytes)", compilerName, backend.getRuntime().compilerToVm.getTimeStamp(), id, isOSR ? '%' : ' ', method.isSynchronized() ? 's' - : ' ', hasExceptionHandlers ? '!' : ' ', blocking ? 'b' : ' ', method.isNative() ? 'n' : ' ', compLevelString, MetaUtil.format("%H::%n(%p)", method), isOSR ? "@ " + entryBCI + - " " : "", method.getCodeSize())); - } - private InstalledCode installMethod(final CompilationResult compResult) { final HotSpotCodeCacheProvider codeCache = backend.getProviders().getCodeCache(); InstalledCode installedCode = null; @@ -486,10 +326,6 @@ return installedCode; } - private boolean tryToChangeStatus(CompilationStatus from, CompilationStatus to) { - return status.compareAndSet(from, to); - } - @Override public String toString() { return "Compilation[id=" + id + ", " + MetaUtil.format("%H.%n(%p)", method) + (entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "@" + entryBCI) + "]"; @@ -499,74 +335,34 @@ * Schedules compilation of a metaspace Method. * * Called from the VM. + * + * @param metaspaceMethod + * @param entryBCI + * @param ctask address of native CompileTask object + * @param id CompileTask::_compile_id */ @SuppressWarnings("unused") - private static void compileMetaspaceMethod(long metaspaceMethod, final int entryBCI, long ctask, final boolean blocking) { - if (ctask != 0L) { - // Ensure a Graal runtime is initialized prior to Debug being initialized as the former - // may include processing command line options used by the latter. - Graal.getRuntime(); - - // Ensure a debug configuration for this thread is initialized - if (Debug.isEnabled() && DebugScope.getConfig() == null) { - DebugEnvironment.initialize(System.out); - } + private static void compileMetaspaceMethod(long metaspaceMethod, int entryBCI, long ctask, int id) { + // Ensure a Graal runtime is initialized prior to Debug being initialized as the former + // may include processing command line options used by the latter. + Graal.getRuntime(); - // This is on a VM CompilerThread - no user frames exist - final HotSpotResolvedJavaMethod method = HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod); - compileMethod(method, entryBCI, ctask, false); - } else { - // We have to use a privileged action here because compilations are - // enqueued from user code which very likely contains unprivileged frames. - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - final HotSpotResolvedJavaMethod method = HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod); - compileMethod(method, entryBCI, 0L, blocking); - return null; - } - }); + // Ensure a debug configuration for this thread is initialized + if (Debug.isEnabled() && DebugScope.getConfig() == null) { + DebugEnvironment.initialize(System.out); } + + HotSpotResolvedJavaMethod method = HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod); + compileMethod(method, entryBCI, ctask, id); } /** * Compiles a method to machine code. */ - static void compileMethod(final HotSpotResolvedJavaMethod method, final int entryBCI, long ctask, final boolean blocking) { - if (ctask != 0L) { - HotSpotBackend backend = runtime().getHostBackend(); - CompilationTask task = new CompilationTask(null, backend, method, entryBCI, ctask, false); - task.runCompilation(); - return; - } - - if (isWithinEnqueue()) { - // This is required to avoid deadlocking a compiler thread. The issue is that a - // java.util.concurrent.BlockingQueue is used to implement the compilation worker - // queues. If a compiler thread triggers a compilation, then it may be blocked trying - // to add something to its own queue. - return; - } - - // Don't allow blocking compiles from CompilerThreads - boolean block = blocking && !(Thread.currentThread() instanceof CompilerThread); - try (Enqueueing enqueueing = new Enqueueing()) { - if (method.tryToQueueForCompilation()) { - assert method.isQueuedForCompilation(); - - try { - CompilationQueue queue = queue(); - if (!queue.executor.isShutdown()) { - HotSpotBackend backend = runtime().getHostBackend(); - CompilationTask task = new CompilationTask(queue.executor, backend, method, entryBCI, ctask, block); - queue.execute(task); - if (block) { - task.block(); - } - } - } catch (RejectedExecutionException e) { - // The compile queue was already shut down. - } - } - } + static void compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long ctask, int id) { + HotSpotBackend backend = runtime().getHostBackend(); + CompilationTask task = new CompilationTask(backend, method, entryBCI, ctask, id); + task.runCompilation(); + return; } } diff -r c5ab3fbec257 -r 4481cf549cfc 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 Thu Jul 03 21:47:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Thu Jul 03 23:28:35 2014 +0200 @@ -289,7 +289,7 @@ if (classFileCounter >= startAt) { println("CompileTheWorld (%d) : %s", classFileCounter, className); - // Enqueue each constructor/method in the class for compilation. + // Compile each constructor/method in the class. for (Constructor constructor : javaClass.getDeclaredConstructors()) { HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaConstructor(constructor); if (canBeCompiled(javaMethod, constructor.getModifiers())) { @@ -317,7 +317,7 @@ class CTWCompilationTask extends CompilationTask { CTWCompilationTask(HotSpotBackend backend, HotSpotResolvedJavaMethod method) { - super(null, backend, method, INVOCATION_ENTRY_BCI, 0L, false); + super(backend, method, INVOCATION_ENTRY_BCI, 0L, method.allocateCompileId(INVOCATION_ENTRY_BCI)); } /** diff -r c5ab3fbec257 -r 4481cf549cfc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Thu Jul 03 21:47:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Thu Jul 03 23:28:35 2014 +0200 @@ -276,17 +276,10 @@ CompileTheWorld.Options.overrideWithNativeOptions(config); - // Only set HotSpotPrintCompilation and HotSpotPrintInlining if they still have their - // default value (false). - if (HotSpotPrintCompilation.getValue() == false) { - HotSpotPrintCompilation.setValue(config.printCompilation); - } + // Only set HotSpotPrintInlining if it still has its default value (false). if (HotSpotPrintInlining.getValue() == false) { HotSpotPrintInlining.setValue(config.printInlining); } - if (HotSpotCIPrintCompilerName.getValue() == false) { - HotSpotCIPrintCompilerName.setValue(config.printCompilerName); - } if (Boolean.valueOf(System.getProperty("graal.printconfig"))) { printConfig(config); diff -r c5ab3fbec257 -r 4481cf549cfc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Thu Jul 03 21:47:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Thu Jul 03 23:28:35 2014 +0200 @@ -23,7 +23,6 @@ package com.oracle.graal.hotspot; import static com.oracle.graal.compiler.GraalDebugConfig.*; -import static com.oracle.graal.hotspot.CompilationQueue.Options.*; import static com.oracle.graal.hotspot.HotSpotOptionsLoader.*; import static java.lang.Double.*; @@ -53,10 +52,7 @@ static { boolean timeCompilations = parseVMOptions(); - if (timeCompilations || PrintCompRate.getValue() != 0) { - if (timeCompilations && PrintCompRate.getValue() != 0) { - throw new GraalInternalError("PrintCompRate is incompatible with CITime and CITimeEach"); - } + if (timeCompilations) { unconditionallyEnableTimerOrMetric(InliningUtil.class, "InlinedBytecodes"); unconditionallyEnableTimerOrMetric(CompilationTask.class, "CompilationTime"); } diff -r c5ab3fbec257 -r 4481cf549cfc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Jul 03 21:47:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Jul 03 23:28:35 2014 +0200 @@ -711,19 +711,14 @@ @HotSpotVMFlag(name = "CITime") @Stable public boolean ciTime; @HotSpotVMFlag(name = "CITimeEach") @Stable public boolean ciTimeEach; @HotSpotVMFlag(name = "CompileThreshold") @Stable public long compileThreshold; - @HotSpotVMFlag(name = "CompileTheWorld") @Stable public boolean compileTheWorld; @HotSpotVMFlag(name = "CompileTheWorldStartAt", optional = true) @Stable public int compileTheWorldStartAt; @HotSpotVMFlag(name = "CompileTheWorldStopAt", optional = true) @Stable public int compileTheWorldStopAt; @HotSpotVMFlag(name = "DontCompileHugeMethods") @Stable public boolean dontCompileHugeMethods; @HotSpotVMFlag(name = "HugeMethodLimit") @Stable public int hugeMethodLimit; - @HotSpotVMFlag(name = "PrintCompilation") @Stable public boolean printCompilation; - @HotSpotVMFlag(name = "CIPrintCompilerName") @Stable public boolean printCompilerName; @HotSpotVMFlag(name = "PrintInlining") @Stable public boolean printInlining; @HotSpotVMFlag(name = "GraalUseFastLocking") @Stable public boolean useFastLocking; - @HotSpotVMFlag(name = "UseGraalCompilationQueue", optional = true) @Stable public boolean useGraalCompilationQueue; @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable; @HotSpotVMFlag(name = "GPUOffload") @Stable public boolean gpuOffload; - @HotSpotVMFlag(name = "TieredCompilation") @Stable public boolean tieredCompilation; @HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB; @HotSpotVMFlag(name = "UseBiasedLocking") @Stable public boolean useBiasedLocking; @@ -1068,11 +1063,6 @@ */ @HotSpotVMConstant(name = "markOopDesc::no_hash") @Stable public int uninitializedIdentityHashCodeValue; - /** - * Used for marking a Method object as queued for compilation. - */ - @HotSpotVMConstant(name = "JVM_ACC_QUEUED") @Stable public int methodQueuedForCompilationBit; - @HotSpotVMField(name = "Method::_access_flags", type = "AccessFlags", get = HotSpotVMField.Type.OFFSET) @Stable public int methodAccessFlagsOffset; @HotSpotVMField(name = "Method::_constMethod", type = "ConstMethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodConstMethodOffset; @HotSpotVMField(name = "Method::_intrinsic_id", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodIntrinsicIdOffset; @@ -1090,7 +1080,6 @@ @HotSpotVMConstant(name = "JVM_ACC_MONITOR_MATCH") @Stable public int jvmAccMonitorMatch; @HotSpotVMConstant(name = "JVM_ACC_HAS_MONITOR_BYTECODES") @Stable public int jvmAccHasMonitorBytecodes; - @HotSpotVMField(name = "CompileTask::_compile_id", type = "uint", get = HotSpotVMField.Type.OFFSET) @Stable public int compileTaskCompileIdOffset; @HotSpotVMField(name = "CompileTask::_num_inlined_bytecodes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int compileTaskNumInlinedBytecodesOffset; /** diff -r c5ab3fbec257 -r 4481cf549cfc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/InitTimer.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/InitTimer.java Thu Jul 03 21:47:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/InitTimer.java Thu Jul 03 23:28:35 2014 +0200 @@ -27,9 +27,9 @@ import edu.umd.cs.findbugs.annotations.*; /** - * A facility for timing a step in the runtime or compilation queue initialization sequence. This - * exists separate from {@link DebugTimer} as it must be independent from all other Graal code so as - * to not perturb the initialization sequence. + * A facility for timing a step in the runtime initialization sequence. This exists separate from + * {@link DebugTimer} as it must be independent from all other Graal code so as to not perturb the + * initialization sequence. */ public class InitTimer implements AutoCloseable { final String name; diff -r c5ab3fbec257 -r 4481cf549cfc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Thu Jul 03 21:47:59 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Thu Jul 03 23:28:35 2014 +0200 @@ -738,45 +738,6 @@ return runtime().getCompilerToVM().allocateCompileId(metaspaceMethod, entryBCI); } - public boolean tryToQueueForCompilation() { - // other threads may update certain bits of the access flags field concurrently. So, the - // loop ensures that this method only returns false when another thread has set the - // queuedForCompilation bit. - do { - long address = getAccessFlagsAddress(); - int actualValue = unsafe.getInt(address); - int expectedValue = actualValue & ~runtime().getConfig().methodQueuedForCompilationBit; - if (actualValue != expectedValue) { - return false; - } else { - int newValue = expectedValue | runtime().getConfig().methodQueuedForCompilationBit; - boolean success = unsafe.compareAndSwapInt(null, address, expectedValue, newValue); - if (success) { - return true; - } - } - } while (true); - } - - public void clearQueuedForCompilation() { - long address = getAccessFlagsAddress(); - boolean success; - do { - int actualValue = unsafe.getInt(address); - int newValue = actualValue & ~runtime().getConfig().methodQueuedForCompilationBit; - assert isQueuedForCompilation() : "queued for compilation must be set"; - success = unsafe.compareAndSwapInt(null, address, actualValue, newValue); - } while (!success); - } - - public boolean isQueuedForCompilation() { - return (unsafe.getInt(getAccessFlagsAddress()) & runtime().getConfig().methodQueuedForCompilationBit) != 0; - } - - private long getAccessFlagsAddress() { - return metaspaceMethod + runtime().getConfig().methodAccessFlagsOffset; - } - public boolean hasCodeAtLevel(int entryBCI, int level) { if (entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI) { return hasCompiledCodeAtLevel(level); diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Thu Jul 03 23:28:35 2014 +0200 @@ -350,7 +350,7 @@ GRAAL_ONLY(template(com_oracle_graal_api_code_SpeculationLog, "com/oracle/graal/api/code/SpeculationLog")) \ GRAAL_ONLY(template(com_oracle_graal_gpu_ExternalCompilationResult, "com/oracle/graal/gpu/ExternalCompilationResult")) \ GRAAL_ONLY(template(compileMetaspaceMethod_name, "compileMetaspaceMethod")) \ - GRAAL_ONLY(template(compileMetaspaceMethod_signature, "(JIJZ)V")) \ + GRAAL_ONLY(template(compileMetaspaceMethod_signature, "(JIJI)V")) \ GRAAL_ONLY(template(graal_mirror_name, "graal_mirror")) \ \ /* common method and field names */ \ diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/compiler/compileBroker.cpp --- a/src/share/vm/compiler/compileBroker.cpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/compiler/compileBroker.cpp Thu Jul 03 23:28:35 2014 +0200 @@ -805,18 +805,13 @@ #if defined(COMPILERGRAAL) _compilers[1] = graal; - if (UseGraalCompilationQueue) { - c2_count = 0; + if (FLAG_IS_DEFAULT(GraalThreads)) { + if (!TieredCompilation && FLAG_IS_DEFAULT(BootstrapGraal) || BootstrapGraal) { + // Graal will bootstrap so give it more threads + c2_count = os::active_processor_count(); + } } else { - if (FLAG_IS_DEFAULT(GraalThreads)) { - if (!TieredCompilation && FLAG_IS_DEFAULT(BootstrapGraal) || BootstrapGraal) { - // Graal will bootstrap so give it the same number of threads - // as we would give the Java based compilation queue. - c2_count = os::active_processor_count(); - } - } else { - c2_count = GraalThreads; - } + c2_count = GraalThreads; } #endif // COMPILERGRAAL @@ -1156,26 +1151,6 @@ return; } -#ifdef COMPILERGRAAL - if (UseGraalCompilationQueue) { - // In tiered mode we want to only handle highest tier compiles and - // in non-tiered mode the default level should be - // CompLevel_full_optimization which equals CompLevel_highest_tier. - assert(TieredCompilation || comp_level == CompLevel_full_optimization, "incorrect compile level"); - assert(CompLevel_full_optimization == CompLevel_highest_tier, "incorrect level definition"); - if (comp_level == CompLevel_full_optimization) { - JavaThread* javaThread = JavaThread::current(); - if (javaThread->can_schedule_graal_compilation()) { - bool blockingCompilation = is_compile_blocking(method, osr_bci); - NoGraalCompilationScheduling ngcs(javaThread); - GraalCompiler::instance()->compile_method(method, osr_bci, NULL, blockingCompilation); - } - return; - } - assert(TieredCompilation, "should only reach here in tiered mode"); - } -#endif // COMPILERGRAAL - // Outputs from the following MutexLocker block: CompileTask* task = NULL; bool blocking = false; @@ -1984,13 +1959,12 @@ #ifdef COMPILERGRAAL if (comp != NULL && comp->is_graal()) { - assert(!UseGraalCompilationQueue, "should not reach here"); GraalCompiler* graal = (GraalCompiler*) comp; TraceTime t1("compilation", &time); EventCompilation event; - graal->compile_method(target_handle, osr_bci, task, false); + graal->compile_method(target_handle, osr_bci, task); post_compile(thread, task, event, task->code() != NULL, NULL); } else diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/graal/graalCompiler.cpp Thu Jul 03 23:28:35 2014 +0200 @@ -35,7 +35,7 @@ GraalCompiler::GraalCompiler() : AbstractCompiler(graal) { #ifdef COMPILERGRAAL _bootstrapping = false; - _compiled = 0; + _methodsCompiled = 0; #endif assert(_instance == NULL, "only one instance allowed"); _instance = this; @@ -49,44 +49,19 @@ } BufferBlob* buffer_blob = GraalRuntime::initialize_buffer_blob(); - if (!UseGraalCompilationQueue) { - // This path is used for initialization both by the native queue and the graal queue - // but set_state acquires a lock which might not be safe during JVM_CreateJavaVM, so - // only update the state flag for the native queue. - if (buffer_blob == NULL) { - set_state(failed); - } else { - set_state(initialized); - } + if (buffer_blob == NULL) { + set_state(failed); + } else { + set_state(initialized); } { HandleMark hm; - bool bootstrap_now = UseGraalCompilationQueue && (FLAG_IS_DEFAULT(BootstrapGraal) ? !TieredCompilation : BootstrapGraal); - - if (UseGraalCompilationQueue) { - _bootstrapping = bootstrap_now; - start_compilation_queue(); - } - // Graal is considered as application code so we need to // stop the VM deferring compilation now. CompilationPolicy::completed_vm_startup(); - if (bootstrap_now) { - // Avoid -Xcomp and -Xbatch problems by turning on interpreter and background compilation for bootstrapping. - FlagSetting a(UseInterpreter, true); - FlagSetting b(BackgroundCompilation, true); -#ifndef PRODUCT - // Turn off CompileTheWorld during bootstrap so that a counter overflow event - // triggers further compilation (see NonTieredCompPolicy::event()) hence - // allowing a complete bootstrap - FlagSetting c(CompileTheWorld, false); -#endif - bootstrap(); - } - #ifndef PRODUCT if (CompileTheWorld) { compile_the_world(); @@ -97,83 +72,50 @@ } #ifdef COMPILERGRAAL -void GraalCompiler::start_compilation_queue() { - JavaThread* THREAD = JavaThread::current(); - HandleMark hm(THREAD); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/CompilationQueue", THREAD); - KlassHandle klass = GraalRuntime::load_required_class(name); - NoGraalCompilationScheduling ngcs(THREAD); - klass->initialize(THREAD); - GUARANTEE_NO_PENDING_EXCEPTION("Error while calling start_compilation_queue"); -} - - -void GraalCompiler::shutdown_compilation_queue() { - JavaThread* THREAD = JavaThread::current(); - HandleMark hm(THREAD); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/CompilationQueue", THREAD); - KlassHandle klass = GraalRuntime::load_required_class(name); - JavaValue result(T_VOID); - JavaCallArguments args; - JavaCalls::call_static(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, THREAD); - GUARANTEE_NO_PENDING_EXCEPTION("Error while calling shutdown_compilation_queue"); -} - void GraalCompiler::bootstrap() { JavaThread* THREAD = JavaThread::current(); _bootstrapping = true; - if (!UseGraalCompilationQueue) { - ResourceMark rm; - HandleMark hm; - if (PrintBootstrap) { - tty->print("Bootstrapping Graal"); - } - jlong start = os::javaTimeMillis(); + ResourceMark rm; + HandleMark hm; + if (PrintBootstrap) { + tty->print("Bootstrapping Graal"); + } + jlong start = os::javaTimeMillis(); - Array* objectMethods = InstanceKlass::cast(SystemDictionary::Object_klass())->methods(); - // Initialize compile queue with a selected set of methods. - int len = objectMethods->length(); - for (int i = 0; i < len; i++) { - methodHandle mh = objectMethods->at(i); - if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) { - ResourceMark rm; - int hot_count = 10; // TODO: what's the appropriate value? - CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, "bootstrap", THREAD); + Array* objectMethods = InstanceKlass::cast(SystemDictionary::Object_klass())->methods(); + // Initialize compile queue with a selected set of methods. + int len = objectMethods->length(); + for (int i = 0; i < len; i++) { + methodHandle mh = objectMethods->at(i); + if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) { + ResourceMark rm; + int hot_count = 10; // TODO: what's the appropriate value? + CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, "bootstrap", THREAD); + } + } + + int qsize; + jlong sleep_time = 1000; + int z = 0; + do { + os::sleep(THREAD, sleep_time, true); + sleep_time = 100; + qsize = CompileBroker::queue_size(CompLevel_full_optimization); + if (PrintBootstrap) { + while (z < (_methodsCompiled / 100)) { + ++z; + tty->print_raw("."); } } + } while (qsize != 0); - int qsize; - jlong sleep_time = 1000; - int z = 0; - do { - os::sleep(THREAD, sleep_time, true); - sleep_time = 100; - qsize = CompileBroker::queue_size(CompLevel_full_optimization); - if (PrintBootstrap) { - while (z < (_compiled / 100)) { - ++z; - tty->print_raw("."); - } - } - } while (qsize != 0); - - if (PrintBootstrap) { - tty->print_cr(" in %d ms (compiled %d methods)", os::javaTimeMillis() - start, _compiled); - } - } else { - - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/CompilationQueue", THREAD); - KlassHandle klass = GraalRuntime::load_required_class(name); - JavaValue result(T_VOID); - TempNewSymbol bootstrap = SymbolTable::new_symbol("bootstrap", THREAD); - NoGraalCompilationScheduling ngcs(THREAD); - JavaCalls::call_static(&result, klass, bootstrap, vmSymbols::void_method_signature(), THREAD); - GUARANTEE_NO_PENDING_EXCEPTION("Error while calling bootstrap"); + if (PrintBootstrap) { + tty->print_cr(" in %d ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled); } _bootstrapping = false; } -void GraalCompiler::compile_method(methodHandle method, int entry_bci, CompileTask* task, jboolean blocking) { +void GraalCompiler::compile_method(methodHandle method, int entry_bci, CompileTask* task) { GRAAL_EXCEPTION_CONTEXT bool is_osr = entry_bci != InvocationEntryBci; @@ -190,11 +132,11 @@ args.push_long((jlong) (address) method()); args.push_int(entry_bci); args.push_long((jlong) (address) task); - args.push_int(blocking); + args.push_int(task->compile_id()); JavaCalls::call_static(&result, SystemDictionary::CompilationTask_klass(), vmSymbols::compileMetaspaceMethod_name(), vmSymbols::compileMetaspaceMethod_signature(), &args, THREAD); GUARANTEE_NO_PENDING_EXCEPTION("Error while calling compile_method"); - _compiled++; + _methodsCompiled++; } @@ -203,12 +145,6 @@ ShouldNotReachHere(); } -void GraalCompiler::shutdown() { - if (UseGraalCompilationQueue) { - shutdown_compilation_queue(); - } -} - // Print compilation timers and statistics void GraalCompiler::print_timers() { TRACE_graal_1("GraalCompiler::print_timers"); diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/graal/graalCompiler.hpp --- a/src/share/vm/graal/graalCompiler.hpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/graal/graalCompiler.hpp Thu Jul 03 23:28:35 2014 +0200 @@ -32,10 +32,13 @@ #ifdef COMPILERGRAAL bool _bootstrapping; - volatile int _compiled; // no synchronization so may not be 100% accurate - void start_compilation_queue(); - void shutdown_compilation_queue(); + /** + * Number of methods compiled by Graal. This is not synchronized + * so may not be 100% accurate. + */ + volatile int _methodsCompiled; + #endif static GraalCompiler* _instance; @@ -67,15 +70,13 @@ // Compilation entry point for methods virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci); - void compile_method(methodHandle target, int entry_bci, CompileTask* task, jboolean blocking); + void compile_method(methodHandle target, int entry_bci, CompileTask* task); // Print compilation timers and statistics virtual void print_timers(); // Print compilation statistics void reset_compilation_stats(); - - void shutdown(); #endif // COMPILERGRAAL #ifndef PRODUCT @@ -83,35 +84,4 @@ #endif }; -#ifdef COMPILERGRAAL -/** - * Creates a scope in which scheduling a Graal compilation is disabled. - * Scheduling a compilation can happen anywhere a counter can overflow and - * calling back into the Java code for scheduling a compilation (i.e., - * CompilationTask.compileMetaspaceMethod()) from such arbitrary locations - * can cause objects to be in an unexpected state. - * - * In addition, it can be useful to disable compilation scheduling in - * other circumstances such as when initializing the Graal compilation - * queue or when running the Graal bootstrap process. - */ -class NoGraalCompilationScheduling: public StackObj { - private: - JavaThread* _thread; - public: - - NoGraalCompilationScheduling(JavaThread *thread) { - assert(thread == JavaThread::current(), "not the current thread"); - assert(thread->can_schedule_graal_compilation(), "recursive Graal compilation scheduling"); - _thread = thread; - thread->set_can_schedule_graal_compilation(false); - } - - ~NoGraalCompilationScheduling() { - assert(!_thread->can_schedule_graal_compilation(), "unexpected Graal compilation scheduling state"); - _thread->set_can_schedule_graal_compilation(true); - } -}; -#endif // COMPILERGRAAL - #endif // SHARE_VM_GRAAL_GRAAL_COMPILER_HPP diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/graal/graalGlobals.hpp --- a/src/share/vm/graal/graalGlobals.hpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/graal/graalGlobals.hpp Thu Jul 03 23:28:35 2014 +0200 @@ -61,12 +61,6 @@ COMPILERGRAAL_PRESENT(product(intx, GraalThreads, 1, \ "Force number of Graal compiler threads to use")) \ \ - COMPILERGRAAL_PRESENT(product(bool, UseGraalCompilationQueue, false, \ - "Use non-native compilation queue for Graal")) \ - \ - product(bool, ForceGraalInitialization, false, \ - "Force VM to initialize the compiler even if not used") \ - \ product(intx, TraceGraal, 0, \ "Trace level for Graal") \ \ diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/graal/graalRuntime.cpp --- a/src/share/vm/graal/graalRuntime.cpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/graal/graalRuntime.cpp Thu Jul 03 23:28:35 2014 +0200 @@ -690,17 +690,6 @@ return GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK_false); JVM_END -#ifdef COMPILERGRAAL -// private static boolean CompilationQueue.printAndResetCompRate() -JVM_ENTRY(void, JVM_PrintAndResetGraalCompRate(JNIEnv *env, jclass c)) - GraalCompiler* comp = GraalCompiler::instance(); - CompileBroker::print_times(comp); - CompilerStatistics* stats = comp->stats(); - stats->_standard.reset(); - stats->_osr.reset(); -JVM_END -#endif - jint GraalRuntime::check_arguments(TRAPS) { KlassHandle nullHandle; parse_arguments(nullHandle, THREAD); diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/prims/jni.cpp Thu Jul 03 23:28:35 2014 +0200 @@ -5175,22 +5175,9 @@ *(JNIEnv**)penv = thread->jni_environment(); #ifdef COMPILERGRAAL - if (UseGraalCompilationQueue) { - // GraalCompiler may have been created in compileBroker.cpp - GraalCompiler* graal_compiler = GraalCompiler::instance(); - if (ForceGraalInitialization && graal_compiler == NULL) { - graal_compiler = new GraalCompiler(); - } - if (graal_compiler != NULL) { - graal_compiler->initialize(); - } else { - assert(!UseCompiler, "why isn't there any compiler?"); - } - } else { - // Graal is initialized on a CompilerThread - if (FLAG_IS_DEFAULT(BootstrapGraal) ? !TieredCompilation : BootstrapGraal) { - GraalCompiler::instance()->bootstrap(); - } + // Graal is initialized on a CompilerThread + if (FLAG_IS_DEFAULT(BootstrapGraal) ? !TieredCompilation : BootstrapGraal) { + GraalCompiler::instance()->bootstrap(); } #endif diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/prims/nativeLookup.cpp --- a/src/share/vm/prims/nativeLookup.cpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/prims/nativeLookup.cpp Thu Jul 03 23:28:35 2014 +0200 @@ -149,9 +149,6 @@ { CC"Java_com_oracle_truffle_api_Truffle_createRuntime", NULL, FN_PTR(JVM_CreateTruffleRuntime) }, { CC"Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_init", NULL, FN_PTR(JVM_InitializeGraalNatives) }, { CC"Java_com_oracle_graal_hotspot_HotSpotOptions_parseVMOptions", NULL, FN_PTR(JVM_ParseGraalOptions) }, -#ifdef COMPILERGRAAL - { CC"Java_com_oracle_graal_hotspot_CompilationQueue_printAndResetCompRate", NULL, FN_PTR(JVM_PrintAndResetGraalCompRate)}, -#endif #endif }; diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/runtime/java.cpp --- a/src/share/vm/runtime/java.cpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/runtime/java.cpp Thu Jul 03 23:28:35 2014 +0200 @@ -484,11 +484,6 @@ } #ifdef GRAAL -#ifdef COMPILERGRAAL - if (GraalCompiler::instance() != NULL) { - GraalCompiler::instance()->shutdown(); - } -#endif GraalRuntime::shutdown(); #endif diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/runtime/thread.cpp Thu Jul 03 23:28:35 2014 +0200 @@ -1490,7 +1490,6 @@ #ifdef GRAAL _graal_alternate_call_target = NULL; _graal_implicit_exception_pc = NULL; - _graal_can_schedule_compilation = true; if (GraalCounterSize > 0) { _graal_counters = NEW_C_HEAP_ARRAY(jlong, GraalCounterSize, mtInternal); memset(_graal_counters, 0, sizeof(jlong) * GraalCounterSize); diff -r c5ab3fbec257 -r 4481cf549cfc src/share/vm/runtime/thread.hpp --- a/src/share/vm/runtime/thread.hpp Thu Jul 03 21:47:59 2014 +0200 +++ b/src/share/vm/runtime/thread.hpp Thu Jul 03 23:28:35 2014 +0200 @@ -923,7 +923,6 @@ #ifdef GRAAL address _graal_alternate_call_target; address _graal_implicit_exception_pc; // pc at which the most recent implicit exception occurred - bool _graal_can_schedule_compilation; // see NoGraalCompilationScheduling jlong* _graal_counters; @@ -1319,8 +1318,6 @@ #ifdef GRAAL void set_graal_alternate_call_target(address a) { _graal_alternate_call_target = a; } void set_graal_implicit_exception_pc(address a) { _graal_implicit_exception_pc = a; } - bool can_schedule_graal_compilation() { return _graal_can_schedule_compilation; } - void set_can_schedule_graal_compilation(bool b) { _graal_can_schedule_compilation = b; } #endif // Exception handling for compiled methods