changeset 23363:56479400913e

jdk.vm.ci needs to securely export services (JDK-8155023)
author Doug Simon <doug.simon@oracle.com>
date Thu, 28 Apr 2016 15:16:47 +0200
parents ed9eec30efc1
children 8153a654bd10
files jvmci/jdk.vm.ci.hotspot.jfr/src/jdk/vm/ci/hotspot/jfr/events/JFREventProvider.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/events/EmptyEventProvider.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/events/EventProvider.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EmptyEventProvider.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EventProvider.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompilerFactory.java jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/services/JVMCICompilerFactory.java
diffstat 12 files changed, 443 insertions(+), 358 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.hotspot.jfr/src/jdk/vm/ci/hotspot/jfr/events/JFREventProvider.java	Thu Apr 28 14:55:09 2016 +0200
+++ b/jvmci/jdk.vm.ci.hotspot.jfr/src/jdk/vm/ci/hotspot/jfr/events/JFREventProvider.java	Thu Apr 28 15:16:47 2016 +0200
@@ -26,9 +26,7 @@
 
 import java.net.URISyntaxException;
 
-import jdk.vm.ci.hotspot.events.EmptyEventProvider.EmptyCompilationEvent;
-import jdk.vm.ci.hotspot.events.EmptyEventProvider.EmptyCompilerFailureEvent;
-import jdk.vm.ci.hotspot.events.EventProvider;
+import jdk.vm.ci.hotspot.services.EventProvider;
 
 /**
  * A JFR implementation for {@link EventProvider}. This implementation is used when Flight Recorder
@@ -38,7 +36,7 @@
  * <a href="https://bugs.openjdk.java.net/browse/JDK-8032211">JDK-8032211</a>.
  */
 @SuppressWarnings("deprecation")
-public final class JFREventProvider implements EventProvider {
+public final class JFREventProvider extends EventProvider {
 
     private final boolean enabled;
 
@@ -89,11 +87,12 @@
         }
     }
 
+    @Override
     public CompilationEvent newCompilationEvent() {
         if (enabled) {
             return new JFRCompilationEvent();
         }
-        return new EmptyCompilationEvent();
+        return EventProvider.createEmptyCompilationEvent();
     }
 
     /**
@@ -145,11 +144,12 @@
         }
     }
 
+    @Override
     public CompilerFailureEvent newCompilerFailureEvent() {
         if (enabled) {
             return new JFRCompilerFailureEvent();
         }
-        return new EmptyCompilerFailureEvent();
+        return EventProvider.createEmptyCompilerFailureEvent();
     }
 
     /**
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java	Thu Apr 28 14:55:09 2016 +0200
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java	Thu Apr 28 15:16:47 2016 +0200
@@ -27,8 +27,8 @@
 import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
 import jdk.vm.ci.runtime.JVMCICompiler;
-import jdk.vm.ci.runtime.JVMCICompilerFactory;
 import jdk.vm.ci.runtime.JVMCIRuntime;
+import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
 import jdk.vm.ci.services.Services;
 
 final class HotSpotJVMCICompilerConfig {
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Thu Apr 28 14:55:09 2016 +0200
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Thu Apr 28 15:16:47 2016 +0200
@@ -42,6 +42,7 @@
 import jdk.vm.ci.code.CompiledCode;
 import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
 import jdk.vm.ci.inittimer.InitTimer;
 import jdk.vm.ci.inittimer.SuppressFBWarnings;
 import jdk.vm.ci.meta.JVMCIMetaAccessContext;
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java	Thu Apr 28 14:55:09 2016 +0200
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java	Thu Apr 28 15:16:47 2016 +0200
@@ -130,7 +130,7 @@
 
         /* Load non-public field: LambdaForm MethodHandle.form */
         JavaConstant lambdaForm = constantReflection.readFieldValue(LazyInitialization.methodHandleFormField, methodHandle);
-        if (lambdaForm.isNull()) {
+        if (lambdaForm == null || lambdaForm.isNull()) {
             return null;
         }
 
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java	Thu Apr 28 14:55:09 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, 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 jdk.vm.ci.hotspot;
-
-import jdk.vm.ci.code.CompiledCode;
-import jdk.vm.ci.code.InstalledCode;
-import jdk.vm.ci.meta.JVMCIMetaAccessContext;
-import jdk.vm.ci.meta.ResolvedJavaType;
-
-public interface HotSpotVMEventListener {
-
-    /**
-     * Notifies this client that the VM is shutting down.
-     */
-    default void notifyShutdown() {
-    }
-
-    /**
-     * Notify on successful install into the code cache.
-     *
-     * @param hotSpotCodeCacheProvider
-     * @param installedCode
-     * @param compiledCode
-     */
-    default void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
-    }
-
-    /**
-     * Create a custom {@link JVMCIMetaAccessContext} to be used for managing the lifetime of loaded
-     * metadata. It a custom one isn't created then the default implementation will be a single
-     * context with globally shared instances of {@link ResolvedJavaType} that are never released.
-     *
-     * @param hotSpotJVMCIRuntime
-     * @return a custom context or null
-     */
-    default JVMCIMetaAccessContext createMetaAccessContext(HotSpotJVMCIRuntime hotSpotJVMCIRuntime) {
-        return null;
-    }
-}
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/events/EmptyEventProvider.java	Thu Apr 28 14:55:09 2016 +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 jdk.vm.ci.hotspot.events;
-
-import jdk.vm.ci.common.JVMCIError;
-
-/**
- * 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();
-        }
-    }
-
-}
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/events/EventProvider.java	Thu Apr 28 14:55:09 2016 +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 jdk.vm.ci.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);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EmptyEventProvider.java	Thu Apr 28 15:16:47 2016 +0200
@@ -0,0 +1,113 @@
+/*
+ * 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 jdk.vm.ci.hotspot.services;
+
+/**
+ * An empty implementation for {@link EventProvider}. This implementation is used when no logging is
+ * requested.
+ */
+final class EmptyEventProvider extends EventProvider {
+
+    public EmptyEventProvider() {
+        super(null);
+    }
+
+    static InternalError shouldNotReachHere() {
+        throw new InternalError("should not reach here");
+    }
+
+    @Override
+    public CompilationEvent newCompilationEvent() {
+        return new EmptyCompilationEvent();
+    }
+
+    static class EmptyCompilationEvent implements CompilationEvent {
+        public void commit() {
+            throw 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 shouldNotReachHere();
+        }
+
+        public void setCompileId(int compileId) {
+            throw shouldNotReachHere();
+        }
+
+        public void setCompileLevel(int compileLevel) {
+            throw shouldNotReachHere();
+        }
+
+        public void setSucceeded(boolean succeeded) {
+            throw shouldNotReachHere();
+        }
+
+        public void setIsOsr(boolean isOsr) {
+            throw shouldNotReachHere();
+        }
+
+        public void setCodeSize(int codeSize) {
+            throw shouldNotReachHere();
+        }
+
+        public void setInlinedBytes(int inlinedBytes) {
+            throw shouldNotReachHere();
+        }
+    }
+
+    @Override
+    public CompilerFailureEvent newCompilerFailureEvent() {
+        return new EmptyCompilerFailureEvent();
+    }
+
+    static class EmptyCompilerFailureEvent implements CompilerFailureEvent {
+        public void commit() {
+            throw shouldNotReachHere();
+        }
+
+        public boolean shouldWrite() {
+            // Events of this class should never been written.
+            return false;
+        }
+
+        public void setCompileId(int compileId) {
+            throw shouldNotReachHere();
+        }
+
+        public void setMessage(String message) {
+            throw shouldNotReachHere();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EventProvider.java	Thu Apr 28 15:16:47 2016 +0200
@@ -0,0 +1,151 @@
+/*
+ * 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 jdk.vm.ci.hotspot.services;
+
+import jdk.vm.ci.hotspot.services.EmptyEventProvider.EmptyCompilationEvent;
+import jdk.vm.ci.hotspot.services.EmptyEventProvider.EmptyCompilerFailureEvent;
+
+/**
+ * Service-provider class for logging compiler related events.
+ */
+public abstract class EventProvider {
+
+    private static Void checkPermission() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null)
+            sm.checkPermission(new RuntimePermission("jvmci"));
+        return null;
+    }
+
+    @SuppressWarnings("unused")
+    EventProvider(Void ignore) {
+    }
+
+    /**
+     * Initializes a new instance of this class.
+     *
+     * @throws SecurityException if a security manager has been installed and it denies
+     *             {@code RuntimePermission("jvmci")}
+     */
+    protected EventProvider() {
+        this(checkPermission());
+    }
+
+    /**
+     * Creates and returns an empty implementation for {@link EventProvider}. This implementation
+     * can be used when no logging is requested.
+     */
+    public static EventProvider createEmptyEventProvider() {
+        return new EmptyEventProvider();
+    }
+
+    /**
+     * Creates and returns an empty implementation for {@link CompilationEvent}.
+     */
+    public static CompilationEvent createEmptyCompilationEvent() {
+        return new EmptyCompilationEvent();
+    }
+
+    /**
+     * Creates and returns an empty implementation for {@link CompilationEvent}.
+     */
+    public static CompilerFailureEvent createEmptyCompilerFailureEvent() {
+        return new EmptyCompilerFailureEvent();
+    }
+
+    /**
+     * An instant event is an event that is not considered to have taken any time.
+     */
+    public 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.
+     */
+    public 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
+     */
+    public abstract CompilationEvent newCompilationEvent();
+
+    /**
+     * A compilation event.
+     */
+    public 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
+     */
+    public abstract CompilerFailureEvent newCompilerFailureEvent();
+
+    /**
+     * A compiler failure event.
+     */
+    public interface CompilerFailureEvent extends InstantEvent {
+        void setCompileId(int compileId);
+
+        void setMessage(String message);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java	Thu Apr 28 15:16:47 2016 +0200
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2015, 2016, 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 jdk.vm.ci.hotspot.services;
+
+import jdk.vm.ci.code.CompiledCode;
+import jdk.vm.ci.code.InstalledCode;
+import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
+import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
+import jdk.vm.ci.meta.JVMCIMetaAccessContext;
+import jdk.vm.ci.meta.ResolvedJavaType;
+
+/**
+ * Service-provider class for responding to VM events and for creating
+ * {@link JVMCIMetaAccessContext}s.
+ */
+public abstract class HotSpotVMEventListener {
+
+    private static Void checkPermission() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null)
+            sm.checkPermission(new RuntimePermission("jvmci"));
+        return null;
+    }
+
+    @SuppressWarnings("unused")
+    HotSpotVMEventListener(Void ignore) {
+    }
+
+    /**
+     * Initializes a new instance of this class.
+     *
+     * @throws SecurityException if a security manager has been installed and it denies
+     *             {@code RuntimePermission("jvmci")}
+     */
+    protected HotSpotVMEventListener() {
+        this(checkPermission());
+    }
+
+    /**
+     * Notifies this client that the VM is shutting down.
+     */
+    public void notifyShutdown() {
+    }
+
+    /**
+     * Notify on successful install into the code cache.
+     *
+     * @param hotSpotCodeCacheProvider
+     * @param installedCode
+     * @param compiledCode
+     */
+    public void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
+    }
+
+    /**
+     * Create a custom {@link JVMCIMetaAccessContext} to be used for managing the lifetime of loaded
+     * metadata. It a custom one isn't created then the default implementation will be a single
+     * context with globally shared instances of {@link ResolvedJavaType} that are never released.
+     *
+     * @param runtime the runtime instance that will use the returned context
+     * @return a custom context or null
+     */
+    public JVMCIMetaAccessContext createMetaAccessContext(HotSpotJVMCIRuntime runtime) {
+        return null;
+    }
+}
--- a/jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompilerFactory.java	Thu Apr 28 14:55:09 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 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
- * 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 jdk.vm.ci.runtime;
-
-/**
- * Service-provider class for creating JVMCI compilers.
- */
-public abstract class JVMCICompilerFactory {
-
-    private static Void checkPermission() {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null)
-            sm.checkPermission(new RuntimePermission("jvmci"));
-        return null;
-    }
-
-    @SuppressWarnings("unused")
-    private JVMCICompilerFactory(Void ignore) {
-    }
-
-    /**
-     * Initializes a new instance of this class.
-     *
-     * @throws SecurityException if a security manager has been installed and it denies
-     *             {@code RuntimePermission("jvmci")}
-     */
-    protected JVMCICompilerFactory() {
-        this(checkPermission());
-    }
-
-    /**
-     * Get the name of this compiler. The name is used by JVMCI to determine which factory to use.
-     */
-    public abstract String getCompilerName();
-
-    /**
-     * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime)
-     * create} a compiler and it should now perform any heavy weight initialization that it deferred
-     * during construction.
-     */
-    public void onSelection() {
-    }
-
-    /**
-     * Create a new instance of a {@link JVMCICompiler}.
-     */
-    public abstract JVMCICompiler createCompiler(JVMCIRuntime runtime);
-
-    /**
-     * In a tiered system it might be advantageous for startup to keep the JVMCI compiler from
-     * compiling itself so provide a hook to request that certain packages are compiled only by an
-     * optimizing first tier. The prefixes should class or package names using / as the separator,
-     * i.e. jdk/vm/ci for instance.
-     *
-     * @return 0 or more Strings identifying packages that should by compiled by the first tier
-     *         only.
-     */
-    public String[] getTrivialPrefixes() {
-        return null;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/services/JVMCICompilerFactory.java	Thu Apr 28 15:16:47 2016 +0200
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 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
+ * 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 jdk.vm.ci.runtime.services;
+
+import jdk.vm.ci.runtime.JVMCICompiler;
+import jdk.vm.ci.runtime.JVMCIRuntime;
+
+/**
+ * Service-provider class for creating JVMCI compilers.
+ */
+public abstract class JVMCICompilerFactory {
+
+    private static Void checkPermission() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null)
+            sm.checkPermission(new RuntimePermission("jvmci"));
+        return null;
+    }
+
+    @SuppressWarnings("unused")
+    private JVMCICompilerFactory(Void ignore) {
+    }
+
+    /**
+     * Initializes a new instance of this class.
+     *
+     * @throws SecurityException if a security manager has been installed and it denies
+     *             {@code RuntimePermission("jvmci")}
+     */
+    protected JVMCICompilerFactory() {
+        this(checkPermission());
+    }
+
+    /**
+     * Get the name of this compiler. The name is used by JVMCI to determine which factory to use.
+     */
+    public abstract String getCompilerName();
+
+    /**
+     * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime)
+     * create} a compiler and it should now perform any heavy weight initialization that it deferred
+     * during construction.
+     */
+    public void onSelection() {
+    }
+
+    /**
+     * Create a new instance of a {@link JVMCICompiler}.
+     */
+    public abstract JVMCICompiler createCompiler(JVMCIRuntime runtime);
+
+    /**
+     * In a tiered system it might be advantageous for startup to keep the JVMCI compiler from
+     * compiling itself so provide a hook to request that certain packages are compiled only by an
+     * optimizing first tier. The prefixes should class or package names using / as the separator,
+     * i.e. jdk/vm/ci for instance.
+     *
+     * @return 0 or more Strings identifying packages that should by compiled by the first tier
+     *         only.
+     */
+    public String[] getTrivialPrefixes() {
+        return null;
+    }
+}