# HG changeset patch # User Gilles Duboscq # Date 1433171009 -7200 # Node ID 77acf6ba2fc03ede4ae1a3cd491975e7ff3a4727 # Parent 9cc3571ef51dd94c7b5308de1ece48d86749075a Move EventProvider to jvmci.hotspot, make it a JVMCI Service diff -r 9cc3571ef51d -r 77acf6ba2fc0 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 Fri May 29 14:46:49 2015 +0200 +++ /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 9cc3571ef51d -r 77acf6ba2fc0 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 Fri May 29 14:46:49 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Mon Jun 01 17:03:29 2015 +0200 @@ -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; @@ -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 9cc3571ef51d -r 77acf6ba2fc0 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 Fri May 29 14:46:49 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Jun 01 17:03:29 2015 +0200 @@ -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 9cc3571ef51d -r 77acf6ba2fc0 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 Fri May 29 14:46:49 2015 +0200 +++ /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 9cc3571ef51d -r 77acf6ba2fc0 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 Fri May 29 14:46:49 2015 +0200 +++ /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 9cc3571ef51d -r 77acf6ba2fc0 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:03:29 2015 +0200 @@ -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 9cc3571ef51d -r 77acf6ba2fc0 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:03:29 2015 +0200 @@ -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 9cc3571ef51d -r 77acf6ba2fc0 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:03:29 2015 +0200 @@ -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 9cc3571ef51d -r 77acf6ba2fc0 make/Makefile --- a/make/Makefile Fri May 29 14:46:49 2015 +0200 +++ b/make/Makefile Mon Jun 01 17:03:29 2015 +0200 @@ -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 9cc3571ef51d -r 77acf6ba2fc0 make/defs.make --- a/make/defs.make Fri May 29 14:46:49 2015 +0200 +++ b/make/defs.make Mon Jun 01 17:03:29 2015 +0200 @@ -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 9cc3571ef51d -r 77acf6ba2fc0 mx/suite.py --- a/mx/suite.py Fri May 29 14:46:49 2015 +0200 +++ b/mx/suite.py Mon Jun 01 17:03:29 2015 +0200 @@ -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" : { @@ -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" : [