# HG changeset patch # User Michael Van De Vanter # Date 1433206048 25200 # Node ID 1c76a5662753d4c5da271a744cc46d5dfd7b4907 # Parent 610d76a131cdd54be7b096516f96a46771e37867# Parent 645f170013a451083414ff695412c465e9d2ebf0 Merge with 645f170013a451083414ff695412c465e9d2ebf0 diff -r 610d76a131cd -r 1c76a5662753 .hgignore --- a/.hgignore Sun May 31 17:23:14 2015 -0700 +++ b/.hgignore Mon Jun 01 17:47:28 2015 -0700 @@ -11,6 +11,7 @@ ^mx/includes ^build/ ^build-nograal/ +^build-nojvmci/ ^dist/ ^java/ ^lib/ diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java --- a/graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.api.directives/src/com/oracle/graal/api/directives/GraalDirectives.java Mon Jun 01 17:47:28 2015 -0700 @@ -276,4 +276,11 @@ public static T opaque(T value) { return value; } + + public static T guardingNonNull(T value) { + if (value == null) { + deoptimize(); + } + return value; + } } diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Jun 01 17:47:28 2015 -0700 @@ -25,18 +25,11 @@ import com.oracle.jvmci.code.Architecture; import com.oracle.jvmci.code.CompilationResult; import com.oracle.jvmci.code.TargetDescription; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.InstalledCode; import com.oracle.jvmci.code.CallingConvention; import com.oracle.jvmci.code.CodeCacheProvider; -import com.oracle.jvmci.meta.DeoptimizationReason; -import com.oracle.jvmci.meta.ResolvedJavaMethod; -import com.oracle.jvmci.meta.Kind; -import com.oracle.jvmci.meta.ConstantReflectionProvider; -import com.oracle.jvmci.meta.JavaType; -import com.oracle.jvmci.meta.ResolvedJavaType; -import com.oracle.jvmci.meta.ProfilingInfo; -import com.oracle.jvmci.meta.MetaAccessProvider; +import com.oracle.jvmci.meta.*; + import static com.oracle.jvmci.code.CodeUtil.*; import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.compiler.common.GraalOptions.*; diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java Mon Jun 01 17:47:28 2015 -0700 @@ -120,21 +120,13 @@ } } // total : root = 1 exit, nested = 6, innermost = 4 - private static boolean a() { - return false; - } + private static native boolean a(); - private static boolean b() { - return false; - } + private static native boolean b(); - private static boolean c() { - return false; - } + private static native boolean c(); - private static boolean d() { - return false; - } + private static native boolean d(); private static Invoke getInvoke(String name, StructuredGraph graph) { for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.TYPE)) { @@ -150,7 +142,7 @@ Debug.dump(graph, "Graph"); ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true); - Assert.assertTrue(cfg.getLoops().size() == 3); + Assert.assertEquals(3, cfg.getLoops().size()); Loop rootLoop = cfg.getLoops().get(0); Loop nestedLoop = cfg.getLoops().get(1); Loop innerMostLoop = cfg.getLoops().get(2); diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java Mon Jun 01 17:47:28 2015 -0700 @@ -25,13 +25,11 @@ import com.oracle.jvmci.code.CodeUtil; import com.oracle.jvmci.code.CompilationResult; import com.oracle.jvmci.code.TargetDescription; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.InstalledCode; import com.oracle.jvmci.code.CallingConvention; import com.oracle.jvmci.code.CodeCacheProvider; -import com.oracle.jvmci.meta.ResolvedJavaMethod; -import com.oracle.jvmci.meta.ProfilingInfo; -import com.oracle.jvmci.meta.MetaAccessProvider; +import com.oracle.jvmci.meta.*; + import java.lang.reflect.*; import java.util.concurrent.atomic.*; diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Mon Jun 01 17:47:28 2015 -0700 @@ -25,16 +25,9 @@ import com.oracle.jvmci.code.CompilationResult; import com.oracle.jvmci.code.TargetDescription; import com.oracle.jvmci.code.RegisterConfig; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.CallingConvention; -import com.oracle.jvmci.meta.Assumptions; -import com.oracle.jvmci.meta.Kind; -import com.oracle.jvmci.meta.JavaConstant; -import com.oracle.jvmci.meta.ProfilingInfo; -import com.oracle.jvmci.meta.TriState; -import com.oracle.jvmci.meta.ResolvedJavaMethod; -import com.oracle.jvmci.meta.DefaultProfilingInfo; -import com.oracle.jvmci.meta.VMConstant; +import com.oracle.jvmci.meta.*; + import static com.oracle.graal.compiler.GraalCompiler.Options.*; import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.compiler.common.alloc.RegisterAllocationConfig.*; diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.hotspot.jfr/src/com/oracle/graal/hotspot/jfr/events/JFREventProvider.java --- a/graal/com.oracle.graal.hotspot.jfr/src/com/oracle/graal/hotspot/jfr/events/JFREventProvider.java Sun May 31 17:23:14 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,158 +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.jfr.events; - -import java.net.*; - -import com.oracle.graal.hotspot.events.*; -import com.oracle.jrockit.jfr.*; -import com.oracle.jvmci.service.*; - -/** - * A JFR implementation for {@link EventProvider}. This implementation is used when Flight Recorder - * is turned on. - */ -@ServiceProvider(EventProvider.class) -public final class JFREventProvider implements EventProvider { - - @SuppressWarnings("deprecation") private final Producer producer; - - @SuppressWarnings("deprecation") - public JFREventProvider() { - try { - /* - * The "HotSpot JVM" producer is a native producer and we cannot use it. So we create - * our own. This has the downside that Mission Control is confused and doesn't show - * Graal's events in the "Code" tab. There are plans to revise the JFR code for JDK 9. - */ - producer = new Producer("HotSpot JVM", "Oracle Hotspot JVM", "http://www.oracle.com/hotspot/jvm/"); - producer.register(); - } catch (URISyntaxException e) { - throw new InternalError(e); - } - - // Register event classes with Producer. - for (Class c : JFREventProvider.class.getDeclaredClasses()) { - if (c.isAnnotationPresent(EventDefinition.class)) { - assert com.oracle.jrockit.jfr.InstantEvent.class.isAssignableFrom(c) : c; - registerEvent(c); - } - } - } - - /** - * Register an event class with the {@link Producer}. - * - * @param c event class - * @return the {@link EventToken event token} - */ - @SuppressWarnings({"deprecation", "javadoc", "unchecked"}) - private EventToken registerEvent(Class c) { - try { - return producer.addEvent((Class) c); - } catch (InvalidEventDefinitionException | InvalidValueException e) { - throw new InternalError(e); - } - } - - public CompilationEvent newCompilationEvent() { - return new JFRCompilationEvent(); - } - - /** - * A JFR compilation event. - * - *

- * See: event {@code Compilation} in {@code src/share/vm/trace/trace.xml} - */ - @SuppressWarnings("deprecation") - @EventDefinition(name = "Compilation", path = "vm/compiler/compilation") - public static class JFRCompilationEvent extends com.oracle.jrockit.jfr.DurationEvent implements CompilationEvent { - - /* - * FIXME method should be a Method* but we can't express that in Java. - */ - @ValueDefinition(name = "Java Method") public String method; - @ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; - @ValueDefinition(name = "Compilation Level") public short compileLevel; - @ValueDefinition(name = "Succeeded") public boolean succeeded; - @ValueDefinition(name = "On Stack Replacement") public boolean isOsr; - @ValueDefinition(name = "Compiled Code Size", contentType = ContentType.Bytes) public int codeSize; - @ValueDefinition(name = "Inlined Code Size", contentType = ContentType.Bytes) public int inlinedBytes; - - public void setMethod(String method) { - this.method = method; - } - - public void setCompileId(int id) { - this.compileId = id; - } - - public void setCompileLevel(int compileLevel) { - this.compileLevel = (short) compileLevel; - } - - public void setSucceeded(boolean succeeded) { - this.succeeded = succeeded; - } - - public void setIsOsr(boolean isOsr) { - this.isOsr = isOsr; - } - - public void setCodeSize(int codeSize) { - this.codeSize = codeSize; - } - - public void setInlinedBytes(int inlinedBytes) { - this.inlinedBytes = inlinedBytes; - } - } - - public CompilerFailureEvent newCompilerFailureEvent() { - return new JFRCompilerFailureEvent(); - } - - /** - * A JFR compiler failure event. - * - *

- * See: event {@code CompilerFailure} in {@code src/share/vm/trace/trace.xml} - */ - @SuppressWarnings("deprecation") - @EventDefinition(name = "Compilation Failure", path = "vm/compiler/failure") - public static class JFRCompilerFailureEvent extends com.oracle.jrockit.jfr.InstantEvent implements CompilerFailureEvent { - - @ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; - @ValueDefinition(name = "Message", description = "The failure message") public String failure; - - public void setCompileId(int id) { - this.compileId = id; - } - - public void setMessage(String message) { - this.failure = message; - } - } - -} diff -r 610d76a131cd -r 1c76a5662753 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 Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Mon Jun 01 17:47:28 2015 -0700 @@ -36,9 +36,6 @@ import java.util.concurrent.*; import com.oracle.graal.api.runtime.*; -import com.oracle.graal.hotspot.events.*; -import com.oracle.graal.hotspot.events.EventProvider.CompilationEvent; -import com.oracle.graal.hotspot.events.EventProvider.CompilerFailureEvent; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.phases.*; import com.oracle.graal.lir.asm.*; @@ -55,13 +52,26 @@ import com.oracle.jvmci.debug.Debug.Scope; import com.oracle.jvmci.debug.internal.*; import com.oracle.jvmci.hotspot.*; +import com.oracle.jvmci.hotspot.events.*; +import com.oracle.jvmci.hotspot.events.EventProvider.*; import com.oracle.jvmci.meta.*; +import com.oracle.jvmci.service.*; //JaCoCo Exclude public class CompilationTask { private static final DebugMetric BAILOUTS = Debug.metric("Bailouts"); + private static final EventProvider eventProvider; + static { + EventProvider provider = Services.loadSingle(EventProvider.class, false); + if (provider == null) { + eventProvider = new EmptyEventProvider(); + } else { + eventProvider = provider; + } + } + private final HotSpotBackend backend; private final HotSpotResolvedJavaMethod method; private final int entryBCI; @@ -149,7 +159,7 @@ protected ProfilingInfo getProfilingInfo() { boolean osrCompilation = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; - return method.getCompilationProfilingInfo(osrCompilation); + return method.getProfilingInfo(!osrCompilation, osrCompilation); } public void runCompilation() { @@ -160,7 +170,6 @@ final boolean isOSR = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; // Log a compilation event. - EventProvider eventProvider = Graal.getRequiredCapability(EventProvider.class); CompilationEvent compilationEvent = eventProvider.newCompilationEvent(); // If there is already compiled code for this method on our level we simply return. diff -r 610d76a131cd -r 1c76a5662753 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 Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Jun 01 17:47:28 2015 -0700 @@ -37,7 +37,6 @@ import com.oracle.graal.compiler.target.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.debug.*; -import com.oracle.graal.hotspot.events.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.printer.*; import com.oracle.graal.replacements.*; @@ -246,10 +245,6 @@ registerBackend(factory.createBackend(this, null, hostBackend)); } } - - try (InitTimer t = timer("createEventProvider")) { - eventProvider = createEventProvider(); - } } /** @@ -355,22 +350,6 @@ private final NodeCollectionsProvider nodeCollectionsProvider = new DefaultNodeCollectionsProvider(); - private final EventProvider eventProvider; - - private EventProvider createEventProvider() { - if (getConfig().flightRecorder) { - Iterable sl = Services.load(EventProvider.class); - EventProvider singleProvider = null; - for (EventProvider ep : sl) { - assert singleProvider == null : String.format("multiple %s service implementations found: %s and %s", EventProvider.class.getName(), singleProvider.getClass().getName(), - ep.getClass().getName()); - singleProvider = ep; - } - return singleProvider; - } - return new EmptyEventProvider(); - } - @SuppressWarnings("unchecked") @Override public T getCapability(Class clazz) { @@ -382,8 +361,6 @@ return (T) this; } else if (clazz == SnippetReflectionProvider.class) { return (T) getHostProviders().getSnippetReflection(); - } else if (clazz == EventProvider.class) { - return (T) eventProvider; } return null; } diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/events/EmptyEventProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/events/EmptyEventProvider.java Sun May 31 17:23:14 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +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.events; - -import com.oracle.jvmci.common.*; - -/** - * An empty implementation for {@link EventProvider}. This implementation is used when no logging is - * requested. - */ -public final class EmptyEventProvider implements EventProvider { - - public CompilationEvent newCompilationEvent() { - return new EmptyCompilationEvent(); - } - - class EmptyCompilationEvent implements CompilationEvent { - public void commit() { - throw JVMCIError.shouldNotReachHere(); - } - - public boolean shouldWrite() { - // Events of this class should never been written. - return false; - } - - public void begin() { - } - - public void end() { - } - - public void setMethod(String method) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setCompileId(int compileId) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setCompileLevel(int compileLevel) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setSucceeded(boolean succeeded) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setIsOsr(boolean isOsr) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setCodeSize(int codeSize) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setInlinedBytes(int inlinedBytes) { - throw JVMCIError.shouldNotReachHere(); - } - } - - public CompilerFailureEvent newCompilerFailureEvent() { - return new EmptyCompilerFailureEvent(); - } - - class EmptyCompilerFailureEvent implements CompilerFailureEvent { - public void commit() { - throw JVMCIError.shouldNotReachHere(); - } - - public boolean shouldWrite() { - // Events of this class should never been written. - return false; - } - - public void setCompileId(int compileId) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setMessage(String message) { - throw JVMCIError.shouldNotReachHere(); - } - } - -} diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/events/EventProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/events/EventProvider.java Sun May 31 17:23:14 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +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.events; - -/** - * A provider that provides a specific implementation for events that can be logged in the compiler. - */ -public interface EventProvider { - - /** - * An instant event is an event that is not considered to have taken any time. - */ - interface InstantEvent { - /** - * Commits the event. - */ - void commit(); - - /** - * Determines if this particular event instance would be committed to the data stream right - * now if application called {@link #commit()}. This in turn depends on whether the event is - * enabled and possible other factors. - * - * @return if this event would be committed on a call to {@link #commit()}. - */ - boolean shouldWrite(); - } - - /** - * Timed events describe an operation that somehow consumes time. - */ - interface TimedEvent extends InstantEvent { - /** - * Starts the timing for this event. - */ - void begin(); - - /** - * Ends the timing period for this event. - */ - void end(); - } - - /** - * Creates a new {@link CompilationEvent}. - * - * @return a compilation event - */ - CompilationEvent newCompilationEvent(); - - /** - * A compilation event. - */ - interface CompilationEvent extends TimedEvent { - void setMethod(String method); - - void setCompileId(int compileId); - - void setCompileLevel(int compileLevel); - - void setSucceeded(boolean succeeded); - - void setIsOsr(boolean isOsr); - - void setCodeSize(int codeSize); - - void setInlinedBytes(int inlinedBytes); - } - - /** - * Creates a new {@link CompilerFailureEvent}. - * - * @return a compiler failure event - */ - CompilerFailureEvent newCompilerFailureEvent(); - - /** - * A compiler failure event. - */ - interface CompilerFailureEvent extends InstantEvent { - void setCompileId(int compileId); - - void setMessage(String message); - } -} diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneSnippets.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneSnippets.java Mon Jun 01 17:47:28 2015 -0700 @@ -23,11 +23,12 @@ package com.oracle.graal.hotspot.replacements; import com.oracle.jvmci.meta.Kind; + import java.lang.reflect.*; import java.util.*; +import com.oracle.graal.api.directives.*; import com.oracle.graal.hotspot.replacements.arraycopy.*; -import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.replacements.*; import com.oracle.jvmci.common.*; @@ -114,7 +115,7 @@ @Snippet(removeAllFrameStates = true) public static Object[] objectArrayClone(Object[] src) { - Object[] result = (Object[]) DynamicNewArrayNode.newUninitializedArray(GuardingPiNode.asNonNullClass(src.getClass().getComponentType()), src.length, Kind.Object); + Object[] result = (Object[]) DynamicNewArrayNode.newUninitializedArray(GraalDirectives.guardingNonNull(src.getClass().getComponentType()), src.length, Kind.Object); ArrayCopyCallNode.disjointUninitializedArraycopy(src, 0, result, 0, src.length, Kind.Object); return result; } diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionSubstitutions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionSubstitutions.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionSubstitutions.java Mon Jun 01 17:47:28 2015 -0700 @@ -26,9 +26,9 @@ import java.lang.reflect.*; +import com.oracle.graal.api.directives.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.hotspot.word.*; -import com.oracle.graal.nodes.*; /** * Substitutions for {@link sun.reflect.Reflection} methods. @@ -38,7 +38,7 @@ @MethodSubstitution public static int getClassAccessFlags(Class aClass) { - KlassPointer klass = ClassGetHubNode.readClass(GuardingPiNode.asNonNullClass(aClass)); + KlassPointer klass = ClassGetHubNode.readClass(GraalDirectives.guardingNonNull(aClass)); if (klass.isNull()) { // Class for primitive type return Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC; diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopySnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopySnippets.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopySnippets.java Mon Jun 01 17:47:28 2015 -0700 @@ -30,14 +30,15 @@ import com.oracle.jvmci.meta.ResolvedJavaMethod; import com.oracle.jvmci.meta.DeoptimizationAction; import com.oracle.jvmci.meta.Kind; + import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; -import static com.oracle.graal.nodes.GuardingPiNode.*; import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*; import java.lang.reflect.*; import java.util.*; +import com.oracle.graal.api.directives.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.meta.*; @@ -98,8 +99,8 @@ @Snippet public static void arraycopyZeroLengthIntrinsic(Object src, int srcPos, Object dest, int destPos, int length) { - Object nonNullSrc = guardingNonNull(src); - Object nonNullDest = guardingNonNull(dest); + Object nonNullSrc = GraalDirectives.guardingNonNull(src); + Object nonNullDest = GraalDirectives.guardingNonNull(dest); KlassPointer srcHub = loadHub(nonNullSrc); KlassPointer destHub = loadHub(nonNullDest); checkArrayType(srcHub); @@ -110,8 +111,8 @@ @Snippet public static void arraycopyExactIntrinsic(Object src, int srcPos, Object dest, int destPos, int length, @ConstantParameter Kind elementKind, @ConstantParameter SnippetCounter counter) { - Object nonNullSrc = guardingNonNull(src); - Object nonNullDest = guardingNonNull(dest); + Object nonNullSrc = GraalDirectives.guardingNonNull(src); + Object nonNullDest = GraalDirectives.guardingNonNull(dest); checkLimits(nonNullSrc, srcPos, nonNullDest, destPos, length); counter.inc(); ArrayCopyCallNode.arraycopy(nonNullSrc, srcPos, nonNullDest, destPos, length, elementKind); @@ -128,8 +129,8 @@ */ @Snippet public static void arraycopyPredictedExactIntrinsic(Object src, int srcPos, Object dest, int destPos, int length, @ConstantParameter Kind elementKind, @ConstantParameter SnippetCounter counter) { - Object nonNullSrc = guardingNonNull(src); - Object nonNullDest = guardingNonNull(dest); + Object nonNullSrc = GraalDirectives.guardingNonNull(src); + Object nonNullDest = GraalDirectives.guardingNonNull(dest); KlassPointer srcHub = loadHub(nonNullSrc); KlassPointer destHub = loadHub(nonNullDest); if (probability(SLOW_PATH_PROBABILITY, srcHub != destHub)) { @@ -167,8 +168,8 @@ */ @Snippet public static void arraycopySlowPathIntrinsic(Object src, int srcPos, Object dest, int destPos, int length, @ConstantParameter Kind elementKind, @ConstantParameter SnippetInfo slowPath) { - Object nonNullSrc = guardingNonNull(src); - Object nonNullDest = guardingNonNull(dest); + Object nonNullSrc = GraalDirectives.guardingNonNull(src); + Object nonNullDest = GraalDirectives.guardingNonNull(dest); KlassPointer srcHub = loadHub(nonNullSrc); KlassPointer destHub = loadHub(nonNullDest); checkArrayType(srcHub); @@ -210,8 +211,8 @@ @Snippet public static void arraycopyGeneric(Object src, int srcPos, Object dest, int destPos, int length) { - Object nonNullSrc = guardingNonNull(src); - Object nonNullDest = guardingNonNull(dest); + Object nonNullSrc = GraalDirectives.guardingNonNull(src); + Object nonNullDest = GraalDirectives.guardingNonNull(dest); KlassPointer srcHub = loadHub(nonNullSrc); KlassPointer destHub = loadHub(nonNullDest); if (probability(FAST_PATH_PROBABILITY, srcHub.equal(destHub)) && probability(FAST_PATH_PROBABILITY, nonNullSrc != nonNullDest)) { diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.java.test/src/com/oracle/graal/java/test/TestResolvedJavaMethod.java --- a/graal/com.oracle.graal.java.test/src/com/oracle/graal/java/test/TestResolvedJavaMethod.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.java.test/src/com/oracle/graal/java/test/TestResolvedJavaMethod.java Mon Jun 01 17:47:28 2015 -0700 @@ -358,6 +358,7 @@ "isInVirtualMethodTable", "toParameterTypes", "getParameterAnnotation", + "getSpeculationLog", "$jacocoInit" }; // @formatter:on diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Mon Jun 01 17:47:28 2015 -0700 @@ -77,7 +77,7 @@ public static final OptionValue TraceBytecodeParserLevel = new OptionValue<>(0); @Option(help = "Inlines trivial methods during bytecode parsing.", type = OptionType.Expert)// - public static final StableOptionValue InlineDuringParsing = new StableOptionValue<>(false); + public static final StableOptionValue InlineDuringParsing = new StableOptionValue<>(true); @Option(help = "Inlines intrinsic methods during bytecode parsing.", type = OptionType.Expert)// public static final StableOptionValue InlineIntrinsicsDuringParsing = new StableOptionValue<>(true); @@ -377,7 +377,7 @@ stream.setBCI(0); BciBlock startBlock = blockMap.getStartBlock(); - if (startInstruction == graph.start()) { + if (this.parent == null) { StartNode startNode = graph.start(); if (method.isSynchronized()) { assert !parsingIntrinsic(); diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Mon Jun 01 17:47:28 2015 -0700 @@ -113,7 +113,7 @@ nodeToBlock = n -> schedule.getNodeToBlockMap().get(n); startBlock = cfg.getStartBlock(); } else { - ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true); + ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true); cfg.computePostdominators(); BlockMap> nodes = new BlockMap<>(cfg); for (Block b : cfg.getBlocks()) { @@ -136,8 +136,8 @@ private static class Instance { - private final NodeMap map; - private final Deque loopExits; + private NodeMap map; + private Deque loopExits; private final Function> blockToNodes; private final Function nodeToBlock; @@ -187,6 +187,18 @@ LoopExitNode loopExitNode = (LoopExitNode) beginNode; this.loopExits.push(loopExitNode); undoOperations.add(() -> loopExits.pop()); + } else if (block.getDominator() != null && + (block.getDominator().getLoopDepth() > block.getLoopDepth() || (block.getDominator().getLoopDepth() == block.getLoopDepth() && block.getDominator().getLoop() != block.getLoop()))) { + // We are exiting the loop, but there is not a single loop exit block along our + // dominator tree (e.g., we are a merge of two loop exits). + final NodeMap oldMap = map; + final Deque oldLoopExits = loopExits; + map = map.graph().createNodeMap(); + loopExits = new ArrayDeque<>(); + undoOperations.add(() -> { + map = oldMap; + loopExits = oldLoopExits; + }); } for (Node n : blockToNodes.apply(block)) { if (n.isAlive()) { diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Jun 01 17:47:28 2015 -0700 @@ -202,8 +202,8 @@ } private static boolean checkLatestEarliestRelation(Node currentNode, Block earliestBlock, Block latestBlock) { - assert AbstractControlFlowGraph.dominates(earliestBlock, latestBlock) || (currentNode instanceof VirtualState && latestBlock == earliestBlock.getDominator()) : String.format("%s %s %s", - currentNode, earliestBlock, latestBlock); + assert AbstractControlFlowGraph.dominates(earliestBlock, latestBlock) || (currentNode instanceof VirtualState && latestBlock == earliestBlock.getDominator()) : String.format( + "%s %s (%s) %s (%s)", currentNode, earliestBlock, earliestBlock.getBeginNode(), latestBlock, latestBlock.getBeginNode()); return true; } @@ -658,18 +658,23 @@ stack.push(input); } } + } else if (current instanceof ProxyNode) { + ProxyNode proxyNode = (ProxyNode) current; + for (Node input : proxyNode.inputs()) { + if (input != proxyNode.proxyPoint()) { + stack.push(input); + } + } + } else if (current instanceof FrameState) { + for (Node input : current.inputs()) { + if (input instanceof StateSplit && ((StateSplit) input).stateAfter() == current) { + // Ignore the cycle. + } else { + stack.push(input); + } + } } else { - if (current instanceof FrameState) { - for (Node input : current.inputs()) { - if (input instanceof StateSplit && ((StateSplit) input).stateAfter() == current) { - // Ignore the cycle. - } else { - stack.push(input); - } - } - } else { - current.pushInputs(stack); - } + current.pushInputs(stack); } } else { @@ -683,7 +688,7 @@ for (Node input : current.inputs()) { Block inputEarliest = nodeToBlock.get(input); if (inputEarliest == null) { - assert current instanceof FrameState && input instanceof StateSplit && ((StateSplit) input).stateAfter() == current; + assert current instanceof FrameState && input instanceof StateSplit && ((StateSplit) input).stateAfter() == current : current; } else { assert inputEarliest != null; if (inputEarliest.getEndNode() == input) { diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java Mon Jun 01 17:47:28 2015 -0700 @@ -22,9 +22,8 @@ */ package com.oracle.graal.phases.tiers; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.TargetDescription; -import com.oracle.jvmci.meta.ProfilingInfo; +import com.oracle.jvmci.meta.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.util.*; diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java Mon Jun 01 17:47:28 2015 -0700 @@ -48,8 +48,8 @@ return graph; } - private static void raiseException(String s) { - throw new RuntimeException(s); + private static void raiseExceptionSimple(String s) { + throw new RuntimeException("Raising exception with message \"" + s + "\""); } @Test @@ -67,7 +67,7 @@ public static String test1Snippet(String message) { if (message != null) { try { - raiseException(message); + raiseExceptionSimple(message); } catch (Exception e) { return message + e.getMessage(); } diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java Mon Jun 01 17:47:28 2015 -0700 @@ -24,6 +24,7 @@ import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*; +import com.oracle.graal.api.directives.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; import com.oracle.jvmci.meta.*; @@ -44,7 +45,7 @@ if (probability(SLOW_PATH_PROBABILITY, componentType == void.class)) { DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint); } - return DynamicNewArrayNode.newArray(GuardingPiNode.asNonNullClass(componentType), length); + return DynamicNewArrayNode.newArray(GraalDirectives.guardingNonNull(componentType), length); } public static int getLength(Object array) { diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InlineDuringParsingPlugin.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InlineDuringParsingPlugin.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InlineDuringParsingPlugin.java Mon Jun 01 17:47:28 2015 -0700 @@ -33,9 +33,14 @@ @Override public InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args, JavaType returnType) { - if (method.hasBytecodes() && !method.isSynchronized() && method.getCode().length <= TrivialInliningSize.getValue() && b.getDepth() < InlineDuringParsingMaxDepth.getValue()) { + if (method.hasBytecodes() && method.canBeInlined() && !method.isSynchronized() && checkSize(method, args) && b.getDepth() < InlineDuringParsingMaxDepth.getValue()) { return new InlineInfo(method, false); } return null; } + + private static boolean checkSize(ResolvedJavaMethod method, @SuppressWarnings("unused") ValueNode[] args) { + int bonus = 1; + return method.getCode().length <= TrivialInliningSize.getValue() * bonus; + } } diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodHandlePlugin.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodHandlePlugin.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodHandlePlugin.java Mon Jun 01 17:47:28 2015 -0700 @@ -57,11 +57,10 @@ } else { CallTargetNode callTarget = invoke.callTarget(); NodeInputList argumentsList = callTarget.arguments(); - ValueNode[] newArgs = argumentsList.toArray(new ValueNode[argumentsList.size()]); - for (ValueNode arg : newArgs) { - b.recursiveAppend(arg); + for (int i = 0; i < argumentsList.size(); ++i) { + argumentsList.initialize(i, b.recursiveAppend(argumentsList.get(i))); } - b.handleReplacedInvoke(invoke.getInvokeKind(), callTarget.targetMethod(), newArgs); + b.handleReplacedInvoke(invoke.getInvokeKind(), callTarget.targetMethod(), argumentsList.toArray(new ValueNode[argumentsList.size()])); } return true; } diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Mon Jun 01 17:47:28 2015 -0700 @@ -625,6 +625,24 @@ }); } } + + r.register1("guardingNonNull", Object.class, new InvocationPlugin() { + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { + ObjectStamp objectStamp = (ObjectStamp) value.stamp(); + if (objectStamp.nonNull()) { + b.addPush(value.getKind(), value); + return true; + } else if (objectStamp.alwaysNull()) { + b.add(new DeoptimizeNode(DeoptimizationAction.None, DeoptimizationReason.NullCheckException)); + return true; + } + IsNullNode isNull = b.add(new IsNullNode(value)); + FixedGuardNode fixedGuard = b.add(new FixedGuardNode(isNull, DeoptimizationReason.NullCheckException, DeoptimizationAction.None, true)); + Stamp newStamp = objectStamp.improveWith(StampFactory.objectNonNull()); + b.addPush(value.getKind(), new PiNode(value, newStamp, fixedGuard)); + return true; + } + }); } private static void registerJMHBlackholePlugins(InvocationPlugins plugins) { diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java --- a/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java Mon Jun 01 17:47:28 2015 -0700 @@ -104,7 +104,7 @@ } } try { - classes.add(Class.forName(each)); + classes.add(Class.forName(each, false, GraalJUnitCore.class.getClassLoader())); } catch (ClassNotFoundException e) { system.out().println("Could not find class: " + each); Description description = Description.createSuiteDescription(each); diff -r 610d76a131cd -r 1c76a5662753 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 Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Mon Jun 01 17:47:28 2015 -0700 @@ -23,8 +23,8 @@ package com.oracle.graal.truffle; import com.oracle.jvmci.code.InstalledCode; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.BailoutException; + import static com.oracle.graal.truffle.TruffleCompilerOptions.*; import java.io.*; @@ -36,6 +36,7 @@ import com.oracle.graal.truffle.debug.*; import com.oracle.jvmci.common.*; import com.oracle.jvmci.debug.*; +import com.oracle.jvmci.meta.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.frame.*; diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java Mon Jun 01 17:47:28 2015 -0700 @@ -25,11 +25,9 @@ import com.oracle.jvmci.code.CallingConvention; import com.oracle.jvmci.code.CodeCacheProvider; import com.oracle.jvmci.code.InstalledCode; -import com.oracle.jvmci.code.SpeculationLog; import com.oracle.jvmci.code.CompilationResult; -import com.oracle.jvmci.meta.MetaAccessProvider; -import com.oracle.jvmci.meta.ResolvedJavaType; -import com.oracle.jvmci.meta.ConstantReflectionProvider; +import com.oracle.jvmci.meta.*; + import static com.oracle.jvmci.code.CodeUtil.*; import static com.oracle.graal.compiler.GraalCompiler.*; diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/CodeCacheProvider.java --- a/graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/CodeCacheProvider.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/CodeCacheProvider.java Mon Jun 01 17:47:28 2015 -0700 @@ -22,9 +22,7 @@ */ package com.oracle.jvmci.code; -import com.oracle.jvmci.meta.Constant; -import com.oracle.jvmci.meta.ResolvedJavaMethod; -import com.oracle.jvmci.meta.JavaConstant; +import com.oracle.jvmci.meta.*; import com.oracle.jvmci.code.CompilationResult.DataPatch; import com.oracle.jvmci.code.DataSection.Data; diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/SpeculationLog.java --- a/graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/SpeculationLog.java Sun May 31 17:23:14 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2012, 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.jvmci.code; - -import com.oracle.jvmci.meta.JavaConstant; -import java.util.*; -import java.util.concurrent.*; - -/** - * Manages a list of unique deoptimization reasons. - * - */ -public abstract class SpeculationLog { - private volatile Object lastFailed; - private volatile Collection speculations; - private Set failedSpeculations; - - public synchronized void collectFailedSpeculations() { - if (lastFailed != null) { - if (failedSpeculations == null) { - failedSpeculations = new HashSet<>(2); - } - failedSpeculations.add(lastFailed); - lastFailed = null; - speculations = null; - } - } - - public boolean maySpeculate(Object reason) { - if (failedSpeculations != null && failedSpeculations.contains(reason)) { - return false; - } - return true; - } - - protected void addSpeculation(Object reason) { - assert maySpeculate(reason); - if (speculations == null) { - synchronized (this) { - if (speculations == null) { - speculations = new ConcurrentLinkedQueue<>(); - } - } - } - speculations.add(reason); - } - - public abstract JavaConstant speculate(Object reason); -} diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/package-info.java --- a/graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/package-info.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/package-info.java Mon Jun 01 17:47:28 2015 -0700 @@ -23,7 +23,7 @@ /** * Package that defines the interface between a Java application that wants to install code and the runtime. * The runtime provides in implementation of the {@link com.oracle.jvmci.code.CodeCacheProvider} interface. - * The method {@link com.oracle.jvmci.code.CodeCacheProvider#addMethod(com.oracle.jvmci.meta.ResolvedJavaMethod, CompilationResult, SpeculationLog, InstalledCode)} + * The method {@link com.oracle.jvmci.code.CodeCacheProvider#addMethod(com.oracle.jvmci.meta.ResolvedJavaMethod, CompilationResult, com.oracle.jvmci.meta.SpeculationLog, InstalledCode)} * can be used to install code for a given method. */ package com.oracle.jvmci.code; diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.hotspot.jfr/src/com/oracle/jvmci/hotspot/jfr/events/JFREventProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.jvmci.hotspot.jfr/src/com/oracle/jvmci/hotspot/jfr/events/JFREventProvider.java Mon Jun 01 17:47:28 2015 -0700 @@ -0,0 +1,170 @@ +/* + * 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.jvmci.hotspot.jfr.events; + +import java.net.*; + +import com.oracle.jrockit.jfr.*; +import com.oracle.jvmci.hotspot.*; +import com.oracle.jvmci.hotspot.events.*; +import com.oracle.jvmci.hotspot.events.EmptyEventProvider.EmptyCompilerFailureEvent; +import com.oracle.jvmci.hotspot.events.EmptyEventProvider.EmptyCompilationEvent; +import com.oracle.jvmci.service.*; + +/** + * A JFR implementation for {@link EventProvider}. This implementation is used when Flight Recorder + * is turned on. + */ +@ServiceProvider(EventProvider.class) +public final class JFREventProvider implements EventProvider { + + private final boolean enabled; + + @SuppressWarnings("deprecation") + public JFREventProvider() { + enabled = HotSpotJVMCIRuntime.runtime().getConfig().flightRecorder; + if (enabled) { + try { + /* + * The "HotSpot JVM" producer is a native producer and we cannot use it. So we + * create our own. This has the downside that Mission Control is confused and + * doesn't show Graal's events in the "Code" tab. There are plans to revise the JFR + * code for JDK 9. + */ + Producer producer = new Producer("HotSpot JVM", "Oracle Hotspot JVM", "http://www.oracle.com/hotspot/jvm/"); + producer.register(); + // Register event classes with Producer. + for (Class c : JFREventProvider.class.getDeclaredClasses()) { + if (c.isAnnotationPresent(EventDefinition.class)) { + assert com.oracle.jrockit.jfr.InstantEvent.class.isAssignableFrom(c) : c; + registerEvent(producer, c); + } + } + } catch (URISyntaxException e) { + throw new InternalError(e); + } + } + } + + /** + * Register an event class with the {@link Producer}. + * + * @param c event class + * @return the {@link EventToken event token} + */ + @SuppressWarnings({"deprecation", "javadoc", "unchecked"}) + private static EventToken registerEvent(Producer producer, Class c) { + try { + return producer.addEvent((Class) c); + } catch (InvalidEventDefinitionException | InvalidValueException e) { + throw new InternalError(e); + } + } + + public CompilationEvent newCompilationEvent() { + if (enabled) { + return new JFRCompilationEvent(); + } + return new EmptyCompilationEvent(); + } + + /** + * A JFR compilation event. + * + *

+ * See: event {@code Compilation} in {@code src/share/vm/trace/trace.xml} + */ + @SuppressWarnings("deprecation") + @EventDefinition(name = "Compilation", path = "vm/compiler/compilation") + public static class JFRCompilationEvent extends com.oracle.jrockit.jfr.DurationEvent implements CompilationEvent { + + /* + * FIXME method should be a Method* but we can't express that in Java. + */ + @ValueDefinition(name = "Java Method") public String method; + @ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; + @ValueDefinition(name = "Compilation Level") public short compileLevel; + @ValueDefinition(name = "Succeeded") public boolean succeeded; + @ValueDefinition(name = "On Stack Replacement") public boolean isOsr; + @ValueDefinition(name = "Compiled Code Size", contentType = ContentType.Bytes) public int codeSize; + @ValueDefinition(name = "Inlined Code Size", contentType = ContentType.Bytes) public int inlinedBytes; + + public void setMethod(String method) { + this.method = method; + } + + public void setCompileId(int id) { + this.compileId = id; + } + + public void setCompileLevel(int compileLevel) { + this.compileLevel = (short) compileLevel; + } + + public void setSucceeded(boolean succeeded) { + this.succeeded = succeeded; + } + + public void setIsOsr(boolean isOsr) { + this.isOsr = isOsr; + } + + public void setCodeSize(int codeSize) { + this.codeSize = codeSize; + } + + public void setInlinedBytes(int inlinedBytes) { + this.inlinedBytes = inlinedBytes; + } + } + + public CompilerFailureEvent newCompilerFailureEvent() { + if (enabled) { + return new JFRCompilerFailureEvent(); + } + return new EmptyCompilerFailureEvent(); + } + + /** + * A JFR compiler failure event. + * + *

+ * See: event {@code CompilerFailure} in {@code src/share/vm/trace/trace.xml} + */ + @SuppressWarnings("deprecation") + @EventDefinition(name = "Compilation Failure", path = "vm/compiler/failure") + public static class JFRCompilerFailureEvent extends com.oracle.jrockit.jfr.InstantEvent implements CompilerFailureEvent { + + @ValueDefinition(name = "Compilation ID", relationKey = "COMP_ID") public int compileId; + @ValueDefinition(name = "Message", description = "The failure message") public String failure; + + public void setCompileId(int id) { + this.compileId = id; + } + + public void setMessage(String message) { + this.failure = message; + } + } + +} diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/CompilerToVMImpl.java --- a/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/CompilerToVMImpl.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/CompilerToVMImpl.java Mon Jun 01 17:47:28 2015 -0700 @@ -26,6 +26,7 @@ import static com.oracle.jvmci.hotspot.InitTimer.*; import com.oracle.jvmci.code.*; +import com.oracle.jvmci.meta.*; /** * Entries into the HotSpot VM from Java code. diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotConstantReflectionProvider.java --- a/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotConstantReflectionProvider.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotConstantReflectionProvider.java Mon Jun 01 17:47:28 2015 -0700 @@ -97,7 +97,7 @@ /** * Try to convert {@code offset} into an an index into {@code array}. * - * @return -1 if the offset isn't within the array or the computed index + * @return the computed index or -1 if the offset isn't within the array */ private int indexForOffset(JavaConstant array, long offset) { if (array.getKind() != Kind.Object || array.isNull()) { diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethod.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethod.java Mon Jun 01 17:47:28 2015 -0700 @@ -24,7 +24,6 @@ import java.lang.reflect.*; -import com.oracle.jvmci.code.*; import com.oracle.jvmci.meta.*; /** @@ -85,8 +84,6 @@ */ boolean hasCompiledCodeAtLevel(int level); - ProfilingInfo getCompilationProfilingInfo(boolean isOSR); - default boolean isDefault() { if (isConstructor()) { return false; @@ -116,6 +113,4 @@ int allocateCompileId(int entryBCI); boolean hasCodeAtLevel(int entryBCI, int level); - - SpeculationLog getSpeculationLog(); } diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java --- a/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Mon Jun 01 17:47:28 2015 -0700 @@ -30,7 +30,6 @@ import java.lang.reflect.*; import java.util.*; -import com.oracle.jvmci.code.*; import com.oracle.jvmci.common.*; import com.oracle.jvmci.debug.*; import com.oracle.jvmci.meta.*; @@ -411,15 +410,7 @@ private static final String TraceMethodDataFilter = System.getProperty("graal.traceMethodDataFilter"); @Override - public ProfilingInfo getProfilingInfo() { - return getProfilingInfo(true, true); - } - - public ProfilingInfo getCompilationProfilingInfo(boolean isOSR) { - return getProfilingInfo(!isOSR, isOSR); - } - - private ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) { + public ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) { ProfilingInfo info; if (UseProfilingInformation.getValue() && methodData == null) { diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotSpeculationLog.java --- a/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotSpeculationLog.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotSpeculationLog.java Mon Jun 01 17:47:28 2015 -0700 @@ -22,7 +22,6 @@ */ package com.oracle.jvmci.hotspot; -import com.oracle.jvmci.code.*; import com.oracle.jvmci.meta.*; public class HotSpotSpeculationLog extends SpeculationLog { diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/events/EmptyEventProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/events/EmptyEventProvider.java Mon Jun 01 17:47:28 2015 -0700 @@ -0,0 +1,105 @@ +/* + * 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.jvmci.hotspot.events; + +import com.oracle.jvmci.common.*; + +/** + * An empty implementation for {@link EventProvider}. This implementation is used when no logging is + * requested. + */ +public final class EmptyEventProvider implements EventProvider { + + public CompilationEvent newCompilationEvent() { + return new EmptyCompilationEvent(); + } + + public static class EmptyCompilationEvent implements CompilationEvent { + public void commit() { + throw JVMCIError.shouldNotReachHere(); + } + + public boolean shouldWrite() { + // Events of this class should never been written. + return false; + } + + public void begin() { + } + + public void end() { + } + + public void setMethod(String method) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setCompileId(int compileId) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setCompileLevel(int compileLevel) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setSucceeded(boolean succeeded) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setIsOsr(boolean isOsr) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setCodeSize(int codeSize) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setInlinedBytes(int inlinedBytes) { + throw JVMCIError.shouldNotReachHere(); + } + } + + public CompilerFailureEvent newCompilerFailureEvent() { + return new EmptyCompilerFailureEvent(); + } + + public static class EmptyCompilerFailureEvent implements CompilerFailureEvent { + public void commit() { + throw JVMCIError.shouldNotReachHere(); + } + + public boolean shouldWrite() { + // Events of this class should never been written. + return false; + } + + public void setCompileId(int compileId) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setMessage(String message) { + throw JVMCIError.shouldNotReachHere(); + } + } + +} diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/events/EventProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/events/EventProvider.java Mon Jun 01 17:47:28 2015 -0700 @@ -0,0 +1,107 @@ +/* + * 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.jvmci.hotspot.events; + +import com.oracle.jvmci.service.*; + +/** + * A provider that provides a specific implementation for events that can be logged in the compiler. + */ +public interface EventProvider extends Service { + + /** + * An instant event is an event that is not considered to have taken any time. + */ + interface InstantEvent { + /** + * Commits the event. + */ + void commit(); + + /** + * Determines if this particular event instance would be committed to the data stream right + * now if application called {@link #commit()}. This in turn depends on whether the event is + * enabled and possible other factors. + * + * @return if this event would be committed on a call to {@link #commit()}. + */ + boolean shouldWrite(); + } + + /** + * Timed events describe an operation that somehow consumes time. + */ + interface TimedEvent extends InstantEvent { + /** + * Starts the timing for this event. + */ + void begin(); + + /** + * Ends the timing period for this event. + */ + void end(); + } + + /** + * Creates a new {@link CompilationEvent}. + * + * @return a compilation event + */ + CompilationEvent newCompilationEvent(); + + /** + * A compilation event. + */ + interface CompilationEvent extends TimedEvent { + void setMethod(String method); + + void setCompileId(int compileId); + + void setCompileLevel(int compileLevel); + + void setSucceeded(boolean succeeded); + + void setIsOsr(boolean isOsr); + + void setCodeSize(int codeSize); + + void setInlinedBytes(int inlinedBytes); + } + + /** + * Creates a new {@link CompilerFailureEvent}. + * + * @return a compiler failure event + */ + CompilerFailureEvent newCompilerFailureEvent(); + + /** + * A compiler failure event. + */ + interface CompilerFailureEvent extends InstantEvent { + void setCompileId(int compileId); + + void setMessage(String message); + } +} diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ConstantReflectionProvider.java --- a/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ConstantReflectionProvider.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ConstantReflectionProvider.java Mon Jun 01 17:47:28 2015 -0700 @@ -64,7 +64,7 @@ /** * Reads a value from the given array at the given offset if it is a stable array. The offset - * will decoded relative to the platform addressing into an index into the array. Returns + * will be decoded relative to the platform addressing into an index into the array. Returns * {@code null} if the constant is not a stable array, if it is a default value, if the offset * is out of bounds, or if the value is not available at this point. */ diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaMethod.java --- a/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaMethod.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaMethod.java Mon Jun 01 17:47:28 2015 -0700 @@ -128,7 +128,23 @@ /** * Returns an object that provides access to the profiling information recorded for this method. */ - ProfilingInfo getProfilingInfo(); + default ProfilingInfo getProfilingInfo() { + return getProfilingInfo(true, true); + } + + /** + * Returns an object that provides access to the profiling information recorded for this method. + * + * @param includeNormal if true, + * {@linkplain ProfilingInfo#getDeoptimizationCount(DeoptimizationReason) + * deoptimization counts} will include deoptimization that happened during execution + * of standard non-osr methods. + * @param includeOSR if true, + * {@linkplain ProfilingInfo#getDeoptimizationCount(DeoptimizationReason) + * deoptimization counts} will include deoptimization that happened during execution + * of on-stack-replacement methods. + */ + ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR); /** * Invalidates the profiling information and restarts profiling upon the next invocation. @@ -295,4 +311,6 @@ default boolean isJavaLangObjectInit() { return getDeclaringClass().isJavaLangObject() && getName().equals(""); } + + SpeculationLog getSpeculationLog(); } diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/SpeculationLog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/SpeculationLog.java Mon Jun 01 17:47:28 2015 -0700 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2012, 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.jvmci.meta; + +import java.util.*; +import java.util.concurrent.*; + +/** + * Manages a list of unique deoptimization reasons. + * + */ +public abstract class SpeculationLog { + private volatile Object lastFailed; + private volatile Collection speculations; + private Set failedSpeculations; + + public synchronized void collectFailedSpeculations() { + if (lastFailed != null) { + if (failedSpeculations == null) { + failedSpeculations = new HashSet<>(2); + } + failedSpeculations.add(lastFailed); + lastFailed = null; + speculations = null; + } + } + + public boolean maySpeculate(Object reason) { + if (failedSpeculations != null && failedSpeculations.contains(reason)) { + return false; + } + return true; + } + + protected void addSpeculation(Object reason) { + assert maySpeculate(reason); + if (speculations == null) { + synchronized (this) { + if (speculations == null) { + speculations = new ConcurrentLinkedQueue<>(); + } + } + } + speculations.add(reason); + } + + public abstract JavaConstant speculate(Object reason); +} diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.jvmci.service/src/com/oracle/jvmci/service/Services.java --- a/graal/com.oracle.jvmci.service/src/com/oracle/jvmci/service/Services.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.jvmci.service/src/com/oracle/jvmci/service/Services.java Mon Jun 01 17:47:28 2015 -0700 @@ -22,8 +22,6 @@ */ package com.oracle.jvmci.service; -import static java.lang.String.*; - import java.util.*; import sun.reflect.*; @@ -39,23 +37,23 @@ private static final ClassValue> cache = new ClassValue>() { @Override protected List computeValue(Class type) { - Service[] names = getServiceImpls(type); - if (names == null || names.length == 0) { - throw new InternalError( - format("No implementations for %s found (ensure %s extends %s and that in suite.py the \"annotationProcessors\" attribute for the project enclosing %s includes \"com.oracle.jvmci.service.processor\")", - type.getSimpleName(), type.getSimpleName(), Service.class, type.getSimpleName())); - } - return Arrays.asList(names); + return Arrays.asList(getServiceImpls(type)); } }; /** * Gets an {@link Iterable} of the implementations available for a given service. + * + * @throws SecurityException if a security manager is present and it denies + * {@link RuntimePermission}("jvmciServices") */ @SuppressWarnings("unchecked") @CallerSensitive public static Iterable load(Class service) { - // TODO(ds): add SecurityManager checks + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission("jvmciServices")); + } if (Service.class.isAssignableFrom(service)) { try { return (Iterable) cache.get(service); @@ -76,11 +74,16 @@ * @param service the service whose implementation is being requested * @param required specifies if an {@link InternalError} should be thrown if no implementation * of {@code service} is available + * @throws SecurityException if a security manager is present and it denies + * {@link RuntimePermission}("jvmciServices") */ @SuppressWarnings("unchecked") @CallerSensitive public static S loadSingle(Class service, boolean required) { - // TODO(ds): add SecurityManager checks + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission("jvmciServices")); + } Iterable impls = null; if (Service.class.isAssignableFrom(service)) { try { @@ -114,5 +117,10 @@ return singleImpl; } + static { + Reflection.registerMethodsToFilter(Services.class, "getServiceImpls"); + Reflection.registerFieldsToFilter(Services.class, "cache"); + } + private static native S[] getServiceImpls(Class service); } diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java Mon Jun 01 17:47:28 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, 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 @@ -38,7 +38,7 @@ * implementation of this type and registering it using {@link Registration} annotation, your * language becomes accessible to users of the {@link TruffleVM Truffle virtual machine} - all they * will need to do is to include your JAR into their application and all the Truffle goodies (multi - * language support, multi tennat hosting, debugging, etc.) will be made available to them. + * language support, multitenant hosting, debugging, etc.) will be made available to them. */ public abstract class TruffleLanguage { private final Env env; @@ -56,7 +56,7 @@ /** * The annotation to use to register your language to the {@link TruffleVM Truffle} system. By * annotating your implementation of {@link TruffleLanguage} by this annotation you are just a - * one JAR drop to the classpath away from your users. Once they include your JAR in + * one JAR drop to the class path away from your users. Once they include your JAR in * their application, your language will be available to the {@link TruffleVM Truffle virtual * machine}. */ @@ -72,11 +72,11 @@ String name(); /** - * List of mimetypes associated with your language. Users will use them (directly or - * inderectly) when {@link TruffleVM#eval(java.lang.String, java.lang.String) executing} + * List of MIME types associated with your language. Users will use them (directly or + * indirectly) when {@link TruffleVM#eval(java.lang.String, java.lang.String) executing} * their code snippets or their {@link TruffleVM#eval(java.net.URI) files}. * - * @return array of mime types assigned to your language files + * @return array of MIME types assigned to your language files */ String[] mimeType(); } diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/vm/TruffleVM.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/vm/TruffleVM.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/vm/TruffleVM.java Mon Jun 01 17:47:28 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, 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 @@ -40,12 +40,12 @@ /** * Virtual machine for Truffle based languages. Use {@link #newVM()} to create new isolated virtual * machine ready for execution of various languages. All the languages in a single virtual machine - * see each other exported global symbols and can co-operate. Use {@link #newVM()} multiple times to + * see each other exported global symbols and can cooperate. Use {@link #newVM()} multiple times to * create different, isolated virtual machines completely separated from each other. *

* Once instantiated use {@link #eval(java.net.URI)} with a reference to a file or URL or directly * pass code snippet into the virtual machine via {@link #eval(java.lang.String, java.lang.String)}. - * Support for individual languages is initialized on demand - e.g. once a file of certain mime type + * Support for individual languages is initialized on demand - e.g. once a file of certain MIME type * is about to be processed, its appropriate engine (if found), is initialized. Once an engine gets * initialized, it remains so, until the virtual machine isn't garbage collected. *

@@ -190,7 +190,7 @@ } /** - * Changes the defaut input for languages running in to be created + * Changes the default input for languages running in to be created * {@link TruffleVM virtual machine}. The default is to use {@link System#out}. * * @param r the reader to use as input @@ -224,7 +224,7 @@ /** * Descriptions of languages supported in this Truffle virtual machine. * - * @return an immutable map with keys being mimetypes and values the {@link Language + * @return an immutable map with keys being MIME types and values the {@link Language * descriptions} of associated languages */ public Map getLanguages() { @@ -233,7 +233,7 @@ /** * Evaluates file located on a given URL. Is equivalent to loading the content of a file and - * executing it via {@link #eval(java.lang.String, java.lang.String)} with a mime type guess + * executing it via {@link #eval(java.lang.String, java.lang.String)} with a MIME type guess * based on the file's extension and/or content. * * @param location the location of a file to execute @@ -263,43 +263,43 @@ } TruffleLanguage l = getTruffleLang(mimeType); if (l == null) { - throw new IOException("No language for " + location + " with mime type " + mimeType + " found. Supported types: " + langs.keySet()); + throw new IOException("No language for " + location + " with MIME type " + mimeType + " found. Supported types: " + langs.keySet()); } return SPI.eval(l, s); } /** - * Evaluates code snippet. Chooses a language registered for a given mime type (throws + * Evaluates code snippet. Chooses a language registered for a given MIME type (throws * {@link IOException} if there is none). And passes the specified code to it for execution. * - * @param mimeType mime type of the code snippet - chooses the right language + * @param mimeType MIME type of the code snippet - chooses the right language * @param reader the source of code snippet to execute - * @return result of an exceution, possibly null + * @return result of an execution, possibly null * @throws IOException thrown to signal errors while processing the code */ public Object eval(String mimeType, Reader reader) throws IOException { checkThread(); TruffleLanguage l = getTruffleLang(mimeType); if (l == null) { - throw new IOException("No language for mime type " + mimeType + " found. Supported types: " + langs.keySet()); + throw new IOException("No language for MIME type " + mimeType + " found. Supported types: " + langs.keySet()); } return SPI.eval(l, Source.fromReader(reader, mimeType)); } /** - * Evaluates code snippet. Chooses a language registered for a given mime type (throws + * Evaluates code snippet. Chooses a language registered for a given MIME type (throws * {@link IOException} if there is none). And passes the specified code to it for execution. * - * @param mimeType mime type of the code snippet - chooses the right language + * @param mimeType MIME type of the code snippet - chooses the right language * @param code the code snippet to execute - * @return result of an exceution, possibly null + * @return result of an execution, possibly null * @throws IOException thrown to signal errors while processing the code */ public Object eval(String mimeType, String code) throws IOException { checkThread(); TruffleLanguage l = getTruffleLang(mimeType); if (l == null) { - throw new IOException("No language for mime type " + mimeType + " found. Supported types: " + langs.keySet()); + throw new IOException("No language for MIME type " + mimeType + " found. Supported types: " + langs.keySet()); } return SPI.eval(l, Source.fromText(code, mimeType)); } @@ -309,13 +309,13 @@ * program via one of your {@link #eval(java.lang.String, java.lang.String)} and then look * expected symbol up using this method. *

- * The names of the symbols are language dependant, but for example the Java language bindings + * The names of the symbols are language dependent, but for example the Java language bindings * follow the specification for method references: *

    *
  • "java.lang.Exception::new" is a reference to constructor of {@link Exception} *
  • "java.lang.Integer::valueOf" is a reference to static method in {@link Integer} class *
- * Once an symbol is obtained, it remembers values for fast acces and is ready for being + * Once an symbol is obtained, it remembers values for fast access and is ready for being * invoked. * * @param globalName the name of the symbol to find @@ -391,8 +391,8 @@ * Description of a language registered in {@link TruffleVM Truffle virtual machine}. Languages * are registered by {@link Registration} annotation which stores necessary information into a * descriptor inside of the language's JAR file. When a new {@link TruffleVM} is created, it - * reads all available descritors and creates {@link Language} objects to represent them. One - * can obtain a {@link #getName() name} or list of supported {@link #getMimeTypes() mimetypes} + * reads all available descriptors and creates {@link Language} objects to represent them. One + * can obtain a {@link #getName() name} or list of supported {@link #getMimeTypes() MIME types} * for each language. The actual language implementation is not initialized until * {@link TruffleVM#eval(java.lang.String, java.lang.String) a code is evaluated} in it. */ @@ -405,9 +405,9 @@ } /** - * Mimetypes recognized by the language. + * MIME types recognized by the language. * - * @return returns immutable set of recognized mimetypes + * @return returns immutable set of recognized MIME types */ public Set getMimeTypes() { TreeSet ts = new TreeSet<>(); diff -r 610d76a131cd -r 1c76a5662753 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java Mon Jun 01 17:47:28 2015 -0700 @@ -139,6 +139,11 @@ private static List> builtins = Collections.emptyList(); private final SLContext context; + /* Small tools that can be demonstrated */ + NodeExecCounter nodeExecCounter = null; + NodeExecCounter statementExecCounter = null; + CoverageTracker coverageTracker = null; + public SLMain(Env env) { super(env); context = SLContextFactory.create(new BufferedReader(env().stdIn()), new PrintWriter(env().stdOut(), true)); @@ -157,7 +162,10 @@ /** * The main entry point. Use the mx command "mx sl" to run it with the correct class path setup. + *

+ * Obsolete: being replaced with new TruffleLanguage API */ + @Deprecated public static void main(String[] args) throws IOException { TruffleVM vm = TruffleVM.newVM().build(); assert vm.getLanguages().containsKey("application/x-sl"); @@ -181,6 +189,9 @@ } } + /** + * Temporary method during API evolution, supports debugger integration. + */ public static void run(Source source) throws IOException { TruffleVM vm = TruffleVM.newVM().build(); assert vm.getLanguages().containsKey("application/x-sl"); @@ -204,28 +215,6 @@ // logOutput.println("Source = " + source.getCode()); } - if (statementCounts || coverage) { - Probe.registerASTProber(new SLStandardASTProber()); - } - - NodeExecCounter nodeExecCounter = null; - if (nodeExecCounts) { - nodeExecCounter = new NodeExecCounter(); - nodeExecCounter.install(); - } - - NodeExecCounter statementExecCounter = null; - if (statementCounts) { - statementExecCounter = new NodeExecCounter(StandardSyntaxTag.STATEMENT); - statementExecCounter.install(); - } - - CoverageTracker coverageTracker = null; - if (coverage) { - coverageTracker = new CoverageTracker(); - coverageTracker.install(); - } - /* Parse the SL source file. */ Object result = context.eval(source); if (result != null) { @@ -272,18 +261,6 @@ } finally { printScript("after execution", LAST.context, logOutput, printASTToLog, printSourceAttributionToLog, dumpASTToIGV); } - if (nodeExecCounter != null) { - nodeExecCounter.print(System.out); - nodeExecCounter.dispose(); - } - if (statementExecCounter != null) { - statementExecCounter.print(System.out); - statementExecCounter.dispose(); - } - if (coverageTracker != null) { - coverageTracker.print(System.out); - coverageTracker.dispose(); - } return totalRuntime; } @@ -382,7 +359,10 @@ @Override protected Object eval(Source code) throws IOException { + + setupToolDemos(); context.executeMain(code); + reportToolDemos(); return null; } @@ -406,4 +386,39 @@ return object instanceof SLFunction; } + private void setupToolDemos() { + if (statementCounts || coverage) { + Probe.registerASTProber(new SLStandardASTProber()); + } + if (nodeExecCounts) { + nodeExecCounter = new NodeExecCounter(); + nodeExecCounter.install(); + } + + if (statementCounts) { + statementExecCounter = new NodeExecCounter(StandardSyntaxTag.STATEMENT); + statementExecCounter.install(); + } + + if (coverage) { + coverageTracker = new CoverageTracker(); + coverageTracker.install(); + } + } + + private void reportToolDemos() { + if (nodeExecCounter != null) { + nodeExecCounter.print(System.out); + nodeExecCounter.dispose(); + } + if (statementExecCounter != null) { + statementExecCounter.print(System.out); + statementExecCounter.dispose(); + } + if (coverageTracker != null) { + coverageTracker.print(System.out); + coverageTracker.dispose(); + } + } + } diff -r 610d76a131cd -r 1c76a5662753 graal/findbugs-SuppressFBWarnings.jar Binary file graal/findbugs-SuppressFBWarnings.jar has changed diff -r 610d76a131cd -r 1c76a5662753 lib/findbugs-SuppressFBWarnings.jar Binary file lib/findbugs-SuppressFBWarnings.jar has changed diff -r 610d76a131cd -r 1c76a5662753 make/Makefile --- a/make/Makefile Sun May 31 17:23:14 2015 -0700 +++ b/make/Makefile Mon Jun 01 17:47:28 2015 -0700 @@ -63,6 +63,10 @@ # Default is build both product fastdebug and create export area + +# Directory for shared code (e.g. jvmci.jar) +SHARED_DIR=$(OUTPUTDIR)/shared + # Allow to build HotSpot in local directory from sources specified by GAMMADIR. # After make/defs.make GAMMADIR is defined. ifdef GAMMADIR @@ -84,9 +88,6 @@ ALT_OUT= endif -# Directory for shared code (e.g. jvmci.jar) -SHARED_DIR=$(OUTPUTDIR)/shared - # Typical C1/C2 targets made available with this Makefile C1_VM_TARGETS=product1 fastdebug1 optimized1 debug1 C2_VM_TARGETS=product fastdebug optimized debug diff -r 610d76a131cd -r 1c76a5662753 make/defs.make --- a/make/defs.make Sun May 31 17:23:14 2015 -0700 +++ b/make/defs.make Mon Jun 01 17:47:28 2015 -0700 @@ -343,6 +343,7 @@ EXPORT_JRE_LIB_EXT_DIR = $(EXPORT_JRE_LIB_DIR)/ext EXPORT_JRE_LIB_JVMCI_DIR = $(EXPORT_JRE_LIB_DIR)/jvmci EXPORT_JRE_LIB_JVMCI_SERVICES_DIR = $(EXPORT_JRE_LIB_JVMCI_DIR)/services +EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR = $(EXPORT_JRE_LIB_JVMCI_DIR)/options EXPORT_JRE_LIB_ARCH_DIR = $(EXPORT_JRE_LIB_DIR)/$(LIBARCH) # non-universal macosx builds need to appear universal @@ -369,6 +370,10 @@ EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.jvmci.hotspot.HotSpotVMEventListener EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.jvmci.debug.DebugInitializationPropertyProvider +ifneq ("$(wildcard $(SHARED_DIR)/services/com.oracle.jvmci.hotspot.events.EventProvider)","") +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.jvmci.hotspot.events.EventProvider +endif + EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.graal.api.runtime.GraalRuntimeAccess EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.graal.compiler.match.MatchStatementSet EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.graal.hotspot.HotSpotBackendFactory @@ -398,7 +403,6 @@ EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/com.oracle.graal.hotspot.replacements.InstanceOfSnippets EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/com.oracle.graal.hotspot.replacements.MonitorSnippets EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/com.oracle.graal.hotspot.replacements.NewObjectSnippets -EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/com.oracle.graal.java.AbstractBytecodeParser EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/com.oracle.graal.lir.alloc.lsra.LinearScan EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/com.oracle.graal.lir.alloc.lsra.LocationMarker EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/com.oracle.graal.lir.alloc.lsra.OptimizingLinearScanWalker diff -r 610d76a131cd -r 1c76a5662753 make/solaris/makefiles/debug.make diff -r 610d76a131cd -r 1c76a5662753 make/solaris/makefiles/fastdebug.make diff -r 610d76a131cd -r 1c76a5662753 make/solaris/makefiles/mapfile-vers-GRAAL --- a/make/solaris/makefiles/mapfile-vers-GRAAL Sun May 31 17:23:14 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -# - -# -# Copyright (c) 2006, 2008, 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. -# -# - -# Define public interface. -SUNWprivate_1.1 { - global: -}; diff -r 610d76a131cd -r 1c76a5662753 make/solaris/makefiles/mapfile-vers-JVMCI --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/solaris/makefiles/mapfile-vers-JVMCI Mon Jun 01 17:47:28 2015 -0700 @@ -0,0 +1,30 @@ +# + +# +# Copyright (c) 2006, 2008, 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. +# +# + +# Define public interface. +SUNWprivate_1.1 { + global: +}; diff -r 610d76a131cd -r 1c76a5662753 make/solaris/makefiles/optimized.make diff -r 610d76a131cd -r 1c76a5662753 make/solaris/makefiles/product.make diff -r 610d76a131cd -r 1c76a5662753 make/solaris/makefiles/reorder_GRAAL_amd64 diff -r 610d76a131cd -r 1c76a5662753 make/solaris/makefiles/reorder_JVMCI_amd64 diff -r 610d76a131cd -r 1c76a5662753 mx/FilterTypes.java --- a/mx/FilterTypes.java Sun May 31 17:23:14 2015 -0700 +++ b/mx/FilterTypes.java Mon Jun 01 17:47:28 2015 -0700 @@ -34,8 +34,8 @@ StringBuilder buf = new StringBuilder(); for (int i = 1; i < args.length; ++i) { String serviceName = args[i]; - Class service = Class.forName(serviceName, false, FilterTypes.class.getClassLoader()); - if (jvmciServiceInterface.isAssignableFrom(service)) { + Class service = lookupService(serviceName); + if (service != null && jvmciServiceInterface.isAssignableFrom(service)) { if (buf.length() != 0) { buf.append('|'); } @@ -45,4 +45,19 @@ } System.out.print(buf); } + + private static Class lookupService(String serviceName) { + try { + // This can fail in the case of running against a JDK + // with out of date JVMCI jars. In that case, just print + // a warning sinc the expectation is that the jars will be + // updated later on. + return Class.forName(serviceName, false, FilterTypes.class.getClassLoader()); + } catch (ClassNotFoundException e) { + // Must be stderr to avoid polluting the result being + // written to stdout. + System.err.println(e); + return null; + } + } } diff -r 610d76a131cd -r 1c76a5662753 mx/mx_graal.py --- a/mx/mx_graal.py Sun May 31 17:23:14 2015 -0700 +++ b/mx/mx_graal.py Mon Jun 01 17:47:28 2015 -0700 @@ -54,6 +54,8 @@ 'client-nojvmci' : None, # all compilation with client compiler, JVMCI omitted 'original' : None, # default VM copied from bootstrap JDK 'graal' : None, # alias for jvmci + 'server-nograal' : None, # alias for server-nojvmci + 'client-nograal' : None, # alias for client-nojvmci } """ The VM that will be run by the 'vm' command and built by default by the 'build' command. @@ -121,12 +123,12 @@ return _vm vm = mx.get_env('DEFAULT_VM') envPath = join(_graal_home, 'mx', 'env') - if vm == 'graal': + if vm and 'graal' in vm: if exists(envPath): with open(envPath) as fp: - if 'DEFAULT_VM=graal' in fp.read(): - mx.log('Please update the DEFAULT_VM entry in ' + envPath + ' to use "jvmci" instead of "graal" as the value') - vm = 'jvmci' + if 'DEFAULT_VM=' + vm in fp.read(): + mx.log('Please update the DEFAULT_VM value in ' + envPath + ' to replace "graal" with "jvmci"') + vm = vm.replace('graal', 'jvmci') if vm is None: if not mx.is_interactive(): mx.abort('Need to specify VM with --vm option or DEFAULT_VM environment variable') @@ -555,7 +557,7 @@ """ _, binDir = mx._compile_mx_class('FilterTypes', os.pathsep.join(classpath), myDir=dirname(__file__)) cmd = [mx.java().java, '-cp', mx._cygpathU2W(os.pathsep.join([binDir] + classpath)), 'FilterTypes', 'com.oracle.jvmci.service.Service'] + serviceImplNames - services = subprocess.check_output(cmd, stderr=subprocess.PIPE) + services = subprocess.check_output(cmd) if len(services) == 0: return [] return services.split('|') @@ -1296,7 +1298,7 @@ if _get_vm() != 'jvmci': prefixArgs = ['-esa', '-ea'] else: - prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea'] + prefixArgs = ['-XX:-BootstrapJVMCI', '-esa', '-ea'] if gc_after_test: prefixArgs.append('-XX:-DisableExplicitGC') with open(testfile) as fp: @@ -1523,11 +1525,18 @@ # a non-None value from __enter__. The body of a 'with Task(...) as t' # statement should check 't' and exit immediately if it is None. filters = None + filtersExclude = False def __init__(self, title, tasks=None): self.tasks = tasks self.title = title - self.skipped = tasks is not None and Task.filters is not None and not any([f in title for f in Task.filters]) + if tasks is not None and Task.filters is not None: + if Task.filtersExclude: + self.skipped = any([f in title for f in Task.filters]) + else: + self.skipped = not any([f in title for f in Task.filters]) + else: + self.skipped = False if not self.skipped: self.start = time.time() self.end = None @@ -1710,6 +1719,7 @@ parser.add_argument('-i', '--omit-ide-clean', action='store_false', dest='cleanIde', help='omit cleaning the ide project files') parser.add_argument('-g', '--only-build-jvmci', action='store_false', dest='buildNonJVMCI', help='only build the JVMCI VM') parser.add_argument('-t', '--task-filter', help='comma separated list of substrings to select subset of tasks to be run') + parser.add_argument('-x', action='store_true', help='makes --task-filter an exclusion instead of inclusion filter') parser.add_argument('--jacocout', help='specify the output directory for jacoco report') args = parser.parse_args(args) @@ -1717,6 +1727,9 @@ global _jacoco if args.task_filter: Task.filters = args.task_filter.split(',') + Task.filtersExclude = args.x + elif args.x: + mx.abort('-x option cannot be used without --task-filter option') # Force if not mx._opts.strict_compliance: @@ -2651,8 +2664,7 @@ if hasattr(opts, 'vm') and opts.vm is not None: global _vm _vm = opts.vm - if _vm == 'graal': - _vm = 'jvmci' + _vm = _vm.replace('graal', 'jvmci') if hasattr(opts, 'vmbuild') and opts.vmbuild is not None: global _vmbuild _vmbuild = opts.vmbuild diff -r 610d76a131cd -r 1c76a5662753 mx/suite.py --- a/mx/suite.py Sun May 31 17:23:14 2015 -0700 +++ b/mx/suite.py Mon Jun 01 17:47:28 2015 -0700 @@ -81,7 +81,7 @@ }, "FINDBUGS" : { - "path" : "lib/findbugs-SuppressFBWarnings.jar", + "path" : "graal/findbugs-SuppressFBWarnings.jar", "sha1" : "fb78822d27c68fabf2cb2e5e573b3cdb5f9cae2d", }, @@ -166,7 +166,7 @@ "sourceDirs" : ["src"], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8", - "workingSets" : "API,Graal", + "workingSets" : "API,JVMCI", }, "com.oracle.jvmci.runtime" : { @@ -177,7 +177,7 @@ ], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8", - "workingSets" : "API,Graal", + "workingSets" : "API,JVMCI", }, "com.oracle.jvmci.hotspot" : { @@ -197,7 +197,7 @@ ], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8", - "workingSets" : "API,Graal", + "workingSets" : "JVMCI", }, "com.oracle.nfi" : { @@ -275,7 +275,7 @@ "sourceDirs" : ["src"], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8", - "workingSets" : "API,Graal", + "workingSets" : "API,JVMCI", }, "com.oracle.jvmci.code" : { @@ -284,7 +284,7 @@ "dependencies" : ["com.oracle.jvmci.meta"], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8", - "workingSets" : "API,Graal", + "workingSets" : "API,JVMCI", }, "com.oracle.graal.api.replacements" : { @@ -328,7 +328,7 @@ "sourceDirs" : ["src"], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8", - "workingSets" : "Graal,HotSpot", + "workingSets" : "JVMCI,HotSpot", }, "com.oracle.jvmci.hotspotvmconfig.processor" : { @@ -358,18 +358,18 @@ "workingSets" : "Graal,HotSpot", }, - "com.oracle.graal.hotspot.jfr" : { + "com.oracle.jvmci.hotspot.jfr" : { "subDir" : "graal", "sourceDirs" : ["src"], "dependencies" : [ - "com.oracle.graal.hotspot", + "com.oracle.jvmci.hotspot", "JFR", ], "checkstyle" : "com.oracle.graal.graph", "annotationProcessors" : ["com.oracle.jvmci.service.processor"], "javaCompliance" : "1.8", "profile" : "", - "workingSets" : "Graal,HotSpot", + "workingSets" : "JVMCI,HotSpot", }, "com.oracle.graal.hotspot.amd64" : { @@ -431,7 +431,7 @@ ], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8", - "workingSets" : "Graal", + "workingSets" : "JVMCI", }, "com.oracle.jvmci.options.processor" : { @@ -442,7 +442,7 @@ ], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8", - "workingSets" : "Graal,Codegen", + "workingSets" : "JVMCI,Codegen", }, "com.oracle.jvmci.options.test" : { @@ -455,7 +455,7 @@ "checkstyle" : "com.oracle.graal.graph", "annotationProcessors" : ["com.oracle.jvmci.options.processor"], "javaCompliance" : "1.8", - "workingSets" : "Graal", + "workingSets" : "JVMCI", }, "com.oracle.graal.nodeinfo" : { @@ -512,7 +512,7 @@ "com.oracle.jvmci.service", ], "javaCompliance" : "1.8", - "workingSets" : "Graal,Debug", + "workingSets" : "JVMCI,Debug", }, "com.oracle.jvmci.debug.test" : { @@ -524,7 +524,7 @@ ], "checkstyle" : "com.oracle.graal.graph", "javaCompliance" : "1.8", - "workingSets" : "Graal,Debug,Test", + "workingSets" : "JVMCI,Debug,Test", }, "com.oracle.graal.lir" : { @@ -1268,7 +1268,10 @@ "path" : "build/jvmci-hotspot.jar", "subDir" : "graal", "sourcesPath" : "build/jvmci-hotspot.src.zip", - "dependencies" : ["com.oracle.jvmci.hotspot"], + "dependencies" : [ + "com.oracle.jvmci.hotspot", + "com.oracle.jvmci.hotspot.jfr", + ], "distDependencies" : [ "JVMCI_API", ], @@ -1282,7 +1285,6 @@ "com.oracle.graal.hotspot.amd64", "com.oracle.graal.hotspot.sparc", "com.oracle.graal.hotspot", - "com.oracle.graal.hotspot.jfr", ], "exclude" : ["FINDBUGS"], "distDependencies" : [ diff -r 610d76a131cd -r 1c76a5662753 mxtool/mx.py --- a/mxtool/mx.py Sun May 31 17:23:14 2015 -0700 +++ b/mxtool/mx.py Mon Jun 01 17:47:28 2015 -0700 @@ -1214,6 +1214,7 @@ # # Removed projects and libraries are also removed from # distributions in they are listed as dependencies. + ommittedDeps = set() for d in sorted_deps(includeLibs=True): if d.isLibrary(): if d.optional: @@ -1226,11 +1227,13 @@ d.optional = True if not path: logv('[omitting optional library {0} as {1} does not exist]'.format(d, d.path)) + ommittedDeps.add(d.name) del _libs[d.name] self.libs.remove(d) elif d.isProject(): if java(d.javaCompliance, cancel='some projects will be omitted which may result in errrors') is None: logv('[omitting project {0} as Java compliance {1} cannot be satisfied by configured JDKs]'.format(d, d.javaCompliance)) + ommittedDeps.add(d.name) del _projects[d.name] self.projects.remove(d) else: @@ -1240,17 +1243,19 @@ if not jreLib.is_present_in_jdk(java(d.javaCompliance)): if jreLib.optional: logv('[omitting project {0} as dependency {1} is missing]'.format(d, name)) + ommittedDeps.add(d.name) del _projects[d.name] self.projects.remove(d) else: abort('JRE library {0} required by {1} not found'.format(jreLib, d)) elif not dependency(name, fatalIfMissing=False): logv('[omitting project {0} as dependency {1} is missing]'.format(d, name)) + ommittedDeps.add(d.name) del _projects[d.name] self.projects.remove(d) for dist in _dists.itervalues(): for name in list(dist.deps): - if not dependency(name, fatalIfMissing=False): + if name in ommittedDeps: logv('[omitting {0} from distribution {1}]'.format(name, dist)) dist.deps.remove(name) diff -r 610d76a131cd -r 1c76a5662753 src/os/solaris/vm/thread_solaris.inline.hpp --- a/src/os/solaris/vm/thread_solaris.inline.hpp Sun May 31 17:23:14 2015 -0700 +++ b/src/os/solaris/vm/thread_solaris.inline.hpp Mon Jun 01 17:47:28 2015 -0700 @@ -47,7 +47,7 @@ uintptr_t raw = pd_raw_thread_id(); int ix = pd_cache_index(raw); Thread* candidate = ThreadLocalStorage::_get_thread_cache[ix]; - if (candidate->self_raw_id() == raw) { + if (candidate != NULL && candidate->self_raw_id() == raw) { // hit return candidate; } else { diff -r 610d76a131cd -r 1c76a5662753 src/share/vm/classfile/systemDictionary.hpp --- a/src/share/vm/classfile/systemDictionary.hpp Sun May 31 17:23:14 2015 -0700 +++ b/src/share/vm/classfile/systemDictionary.hpp Mon Jun 01 17:47:28 2015 -0700 @@ -239,7 +239,7 @@ JVMCI_ONLY(do_klass(StackSlot_klass, com_oracle_jvmci_code_StackSlot, Jvmci)) \ JVMCI_ONLY(do_klass(StackLockValue_klass, com_oracle_jvmci_code_StackLockValue, Jvmci)) \ JVMCI_ONLY(do_klass(VirtualObject_klass, com_oracle_jvmci_code_VirtualObject, Jvmci)) \ - JVMCI_ONLY(do_klass(SpeculationLog_klass, com_oracle_jvmci_code_SpeculationLog, Jvmci)) \ + JVMCI_ONLY(do_klass(SpeculationLog_klass, com_oracle_jvmci_meta_SpeculationLog, Jvmci)) \ JVMCI_ONLY(do_klass(JavaConstant_klass, com_oracle_jvmci_meta_JavaConstant, Jvmci)) \ JVMCI_ONLY(do_klass(PrimitiveConstant_klass, com_oracle_jvmci_meta_PrimitiveConstant, Jvmci)) \ JVMCI_ONLY(do_klass(RawConstant_klass, com_oracle_jvmci_meta_RawConstant, Jvmci)) \ diff -r 610d76a131cd -r 1c76a5662753 src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Sun May 31 17:23:14 2015 -0700 +++ b/src/share/vm/classfile/vmSymbols.hpp Mon Jun 01 17:47:28 2015 -0700 @@ -331,6 +331,7 @@ JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_NoFinalizableSubclass, "com/oracle/jvmci/meta/Assumptions$NoFinalizableSubclass")) \ JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_ConcreteMethod, "com/oracle/jvmci/meta/Assumptions$ConcreteMethod")) \ JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_CallSiteTargetValue, "com/oracle/jvmci/meta/Assumptions$CallSiteTargetValue")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_SpeculationLog, "com/oracle/jvmci/meta/SpeculationLog")) \ JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_Call, "com/oracle/jvmci/code/CompilationResult$Call")) \ JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_ConstantReference, "com/oracle/jvmci/code/CompilationResult$ConstantReference")) \ JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_DataPatch, "com/oracle/jvmci/code/CompilationResult$DataPatch")) \ @@ -352,7 +353,6 @@ JVMCI_ONLY(template(com_oracle_jvmci_code_VirtualObject, "com/oracle/jvmci/code/VirtualObject")) \ JVMCI_ONLY(template(com_oracle_jvmci_code_RegisterSaveLayout, "com/oracle/jvmci/code/RegisterSaveLayout")) \ JVMCI_ONLY(template(com_oracle_jvmci_code_InvalidInstalledCodeException, "com/oracle/jvmci/code/InvalidInstalledCodeException")) \ - JVMCI_ONLY(template(com_oracle_jvmci_code_SpeculationLog, "com/oracle/jvmci/code/SpeculationLog")) \ JVMCI_ONLY(template(compileMetaspaceMethod_name, "compileMetaspaceMethod")) \ JVMCI_ONLY(template(compileMetaspaceMethod_signature, "(JIJI)V")) \ JVMCI_ONLY(template(com_oracle_jvmci_hotspot_Stable_signature, "Lcom/oracle/jvmci/hotspot/Stable;")) \ diff -r 610d76a131cd -r 1c76a5662753 src/share/vm/jvmci/jvmciCompilerToVM.cpp --- a/src/share/vm/jvmci/jvmciCompilerToVM.cpp Sun May 31 17:23:14 2015 -0700 +++ b/src/share/vm/jvmci/jvmciCompilerToVM.cpp Mon Jun 01 17:47:28 2015 -0700 @@ -1034,7 +1034,7 @@ #define TYPE "Lcom/oracle/jvmci/meta/JavaType;" #define METHOD "Lcom/oracle/jvmci/meta/JavaMethod;" #define FIELD "Lcom/oracle/jvmci/meta/JavaField;" -#define SPECULATION_LOG "Lcom/oracle/jvmci/code/SpeculationLog;" +#define SPECULATION_LOG "Lcom/oracle/jvmci/meta/SpeculationLog;" #define STRING "Ljava/lang/String;" #define OBJECT "Ljava/lang/Object;" #define CLASS "Ljava/lang/Class;" diff -r 610d76a131cd -r 1c76a5662753 src/share/vm/jvmci/jvmciRuntime.cpp --- a/src/share/vm/jvmci/jvmciRuntime.cpp Sun May 31 17:23:14 2015 -0700 +++ b/src/share/vm/jvmci/jvmciRuntime.cpp Mon Jun 01 17:47:28 2015 -0700 @@ -1059,9 +1059,6 @@ JavaCallArguments args; args.push_oop(receiver); JavaCalls::call_special(&result, receiver->klass(), vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK_ABORT); - - JNIHandles::destroy_global(_HotSpotJVMCIRuntime_instance); - _HotSpotJVMCIRuntime_instance = NULL; } } @@ -1114,7 +1111,12 @@ int file_handle = os::open(path, 0, 0); if (file_handle != -1) { char* buffer = NEW_C_HEAP_ARRAY(char, st.st_size + 1, mtInternal); - int num_read = (int) os::read(file_handle, (char*) buffer, st.st_size); + int num_read; + if(ThreadLocalStorage::thread() == NULL) { // Solaris needs a JavaThread for os::read, if no thread started yet, fallback. + num_read = (int) ::read(file_handle, (char*) buffer, st.st_size); + } else { + num_read = (int) os::read(file_handle, (char*) buffer, st.st_size); + } if (num_read == -1) { warning("Error reading file %s due to %s", path, strerror(errno)); } else if (num_read != st.st_size) { @@ -1203,7 +1205,7 @@ char sep = os::file_separator()[0]; sprintf(path, "%s%clib%cjvmci%cservices%c%s", home, sep, sep, sep, sep, serviceName); ServiceParseClosure closure; - parse_lines(path, &closure, true); // TODO(gd) cache parsing results? + parse_lines(path, &closure, false); GrowableArray* implNames = closure.implNames(); objArrayOop servicesOop = oopFactory::new_objArray(serviceKlass(), implNames->length(), CHECK_(objArrayHandle()));