--- old/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerFactory.java 2017-07-11 14:48:48.000000000 -0700
+++ new/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerFactory.java 2017-07-11 14:48:48.000000000 -0700
@@ -91,4 +91,28 @@
public CompilationLevel adjustCompilationLevel(Class> declaringClass, String name, String signature, boolean isOsr, CompilationLevel level) {
throw new InternalError("Should not reach here");
}
+
+ /** Name of the {@link MBeanInfo MBean} representing the internals
+ * of the current JVMCI compiler. By default returns null
+ * signaling no such bean is present. Overwrite together with {@link #mbean()}
+ * if there is a bean associated with the compiler.
+ *
+ * @return name of the bean or null if no such bean
+ * is provided by the runtime
+ */
+ public String mbeanName() {
+ return null;
+ }
+
+ /** Instance of the {@link MBeanInfo MBean} representing the internals
+ * of the current JVMCI compiler. By default returns null
+ * signaling no such bean is present. Overwrite together with {@link #mbeanName()}
+ * if there is a bean associated with the compiler.
+ *
+ * @return name of the bean or null if no such bean
+ * is provided by the runtime
+ */
+ public Object mbean() {
+ return null;
+ }
}
--- old/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java 2017-07-11 14:48:49.000000000 -0700
+++ new/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java 2017-07-11 14:48:49.000000000 -0700
@@ -35,6 +35,7 @@
import java.util.ServiceLoader;
import java.util.TreeMap;
+import javax.management.MBeanInfo;
import jdk.internal.misc.VM;
import jdk.vm.ci.code.Architecture;
import jdk.vm.ci.code.CompilationRequestResult;
@@ -548,6 +549,26 @@
};
}
+ /** Name of the {@link MBeanInfo MBean} representing the internals
+ * of the current JVMCI runtime.
+ *
+ * @return name of the bean or null if no such bean
+ * is provided by the runtime
+ */
+ public String mbeanName() {
+ return hsCompilerFactory == null ? null : hsCompilerFactory.mbeanName();
+ }
+
+ /** Instance of the {@link MBeanInfo MBean} representing the internals
+ * of the current JVMCI runtime.
+ *
+ * @return instance of the bean or null if no such bean
+ * is provided by the runtime
+ */
+ public Object mbean() {
+ return hsCompilerFactory == null ? null : hsCompilerFactory.mbean();
+ }
+
/**
* Collects the current values of all JVMCI benchmark counters, summed up over all threads.
*/
--- old/src/jdk.internal.vm.ci/share/classes/module-info.java 2017-07-11 14:48:50.000000000 -0700
+++ new/src/jdk.internal.vm.ci/share/classes/module-info.java 2017-07-11 14:48:49.000000000 -0700
@@ -26,6 +26,8 @@
module jdk.internal.vm.ci {
exports jdk.vm.ci.services to jdk.internal.vm.compiler;
+ requires java.management;
+
uses jdk.vm.ci.services.JVMCIServiceLocator;
uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;
@@ -33,4 +35,6 @@
jdk.vm.ci.hotspot.aarch64.AArch64HotSpotJVMCIBackendFactory,
jdk.vm.ci.hotspot.amd64.AMD64HotSpotJVMCIBackendFactory,
jdk.vm.ci.hotspot.sparc.SPARCHotSpotJVMCIBackendFactory;
+ provides sun.management.spi.PlatformMBeanProvider
+ with jdk.vm.ci.services.internal.JVMCIMXBeans;
}
--- /dev/null 2017-07-11 14:48:50.000000000 -0700
+++ new/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/src/jdk/vm/ci/services/internal/JVMCIMXBeans.java 2017-07-11 14:48:50.000000000 -0700
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2014, 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.services.internal;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
+import sun.management.spi.PlatformMBeanProvider;
+
+public final class JVMCIMXBeans extends PlatformMBeanProvider {
+ @Override
+ public List> getPlatformComponentList() {
+ // somehow obtain the bean from JVMCI compiler
+ HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime();
+ if (runtime.mbeanName() != null) {
+ return Collections.singletonList(new HotSpotRuntimeMBeanComponent(runtime));
+ }
+ return Collections.emptyList();
+ }
+
+ private static final class HotSpotRuntimeMBeanComponent implements PlatformComponent