diff --git a/compiler/mx.compiler/suite.py b/compiler/mx.compiler/suite.py index 5c78c8c8675d..bc46e962958b 100644 --- a/compiler/mx.compiler/suite.py +++ b/compiler/mx.compiler/suite.py @@ -487,6 +487,7 @@ "javaCompliance" : "21+", "dependencies" : [ "GRAAL", + "GRAAL_MANAGEMENT", "sdk:NATIVEIMAGE_LIBGRAAL", "sdk:JNIUTILS", "sdk:NATIVEBRIDGE" @@ -697,6 +698,7 @@ ], "distDependencies": [ "GRAAL", + "GRAAL_MANAGEMENT", "sdk:NATIVEIMAGE_LIBGRAAL", "sdk:JNIUTILS", "sdk:NATIVEIMAGE", diff --git a/compiler/src/jdk.graal.compiler.libgraal.loader/src/jdk/graal/compiler/libgraal/loader/HostedLibGraalClassLoader.java b/compiler/src/jdk.graal.compiler.libgraal.loader/src/jdk/graal/compiler/libgraal/loader/HostedLibGraalClassLoader.java index 2064a0fddede..23c0ad16e5c8 100644 --- a/compiler/src/jdk.graal.compiler.libgraal.loader/src/jdk/graal/compiler/libgraal/loader/HostedLibGraalClassLoader.java +++ b/compiler/src/jdk.graal.compiler.libgraal.loader/src/jdk/graal/compiler/libgraal/loader/HostedLibGraalClassLoader.java @@ -177,6 +177,7 @@ byte[] readBytes() throws ClassNotFoundException { private static final Set LIBGRAAL_MODULES = Set.of( "jdk.internal.vm.ci", "jdk.graal.compiler", + "jdk.graal.compiler.management", "jdk.graal.compiler.libgraal", "org.graalvm.truffle.compiler", "com.oracle.graal.graal_enterprise"); diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/LibGraalCompilationDriver.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/LibGraalCompilationDriver.java index e6b38c28dc8d..3d36bbb9deb5 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/LibGraalCompilationDriver.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/LibGraalCompilationDriver.java @@ -574,7 +574,11 @@ protected CompilationResult compileWithLibGraal(Compilation compilation, LibGraa failedCompilations.getAndAdd(1); return null; } - return new CompilationResult(installedCode, memTimeBuffer.readTimeElapsed(), memTimeBuffer.readBytesAllocated()); + long memoryUsed = memTimeBuffer.readBytesAllocated(); + long compileTime = memTimeBuffer.readTimeElapsed(); + GraalError.guarantee(compileTime != 0L, "Compilation time cannot be 0"); + GraalError.guarantee(memoryUsed != 0L, "Compilation memory used cannot be 0"); + return new CompilationResult(installedCode, compileTime, memoryUsed); } } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/GraalServices.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/GraalServices.java index e536e6b6c7e4..062b05779b94 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/GraalServices.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/GraalServices.java @@ -384,7 +384,6 @@ public static long milliTimeStamp() { * measurement. */ public static long getThreadAllocatedBytes(long id) { - JMXService jmx = JMXService.instance; if (jmx == null) { throw new UnsupportedOperationException(); } @@ -433,7 +432,6 @@ public static long getCurrentThreadId() { * the current thread */ public static long getCurrentThreadCpuTime() { - JMXService jmx = JMXService.instance; if (jmx == null) { throw new UnsupportedOperationException(); } @@ -445,7 +443,6 @@ public static long getCurrentThreadCpuTime() { * measurement. */ public static boolean isThreadAllocatedMemorySupported() { - JMXService jmx = JMXService.instance; if (jmx == null) { return false; } @@ -456,7 +453,6 @@ public static boolean isThreadAllocatedMemorySupported() { * Determines if the Java virtual machine supports CPU time measurement for the current thread. */ public static boolean isCurrentThreadCpuTimeSupported() { - JMXService jmx = JMXService.instance; if (jmx == null) { return false; } @@ -478,7 +474,6 @@ public static boolean isCurrentThreadCpuTimeSupported() { * @return the input arguments to the JVM or {@code null} if they are unavailable */ public static List getInputArguments() { - JMXService jmx = JMXService.instance; if (jmx == null) { return null; } @@ -511,4 +506,6 @@ public static double fma(double a, double b, double c) { public static int getJavaUpdateVersion() { return Runtime.version().update(); } + + private static final JMXService jmx = loadSingle(JMXService.class, libgraalServices != null); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/JMXService.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/JMXService.java index 1b3539399dfc..c158cec5b54a 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/JMXService.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/JMXService.java @@ -42,8 +42,4 @@ public abstract class JMXService { protected abstract boolean isCurrentThreadCpuTimeSupported(); protected abstract List getInputArguments(); - - // Placing this static field in JMXService (instead of GraalServices) - // allows for lazy initialization. - static final JMXService instance = GraalServices.loadSingle(JMXService.class, false); }