Determining if JVMCI is enabled and whether it is being used by the JVM
Doug Simon
doug.simon at oracle.com
Wed Jun 29 08:20:59 UTC 2016
Here’s some useful information on how to be able to query this kind of information from Java.
> Begin forwarded message:
>
> From: Roland Schatz <roland.schatz at oracle.com>
> Subject: Re: Problems building Graal-0.12 on Debian 8
> Date: 28 June 2016 at 13:23:19 GMT+2
>
> It depends on what exactly you want to know:
>
> - Am I running a JDK that supports JVMCI?
> Look at the "java.vm.version" system property.
> On JDK 8, it will contain "jvmci-<version>" for jvmci-enabled builds.
> JDK 9 always has JVMCI built in.
>
> - Is JVMCI enabled and/or used?
> For that, you can query the VM options (EnableJVMCI and UseJVMCICompiler) using the management API.
>
> - What compiler is selected?
> That's in the "jvmci.Compiler" system property.
>
>> import java.lang.management.ManagementFactory;
>> import com.sun.management.HotSpotDiagnosticMXBean;
>> import com.sun.management.VMOption;
>>
>> class JVMCIQuery {
>> public static void main(String[] args) {
>> // Am I running on a JDK that supports JVMCI?
>> String vm_version = System.getProperty("java.vm.version");
>> System.out.printf("java.vm.version = %s%n", vm_version);
>>
>> HotSpotDiagnosticMXBean bean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
>>
>> // Is JVMCI enabled?
>> VMOption enableJVMCI = bean.getVMOption("EnableJVMCI");
>> System.out.println(enableJVMCI);
>>
>> // Is the system using the JVMCI compiler for normal compilations?
>> VMOption useJVMCICompiler = bean.getVMOption("UseJVMCICompiler");
>> System.out.println(useJVMCICompiler);
>>
>> // What compiler is selected?
>> String compiler = System.getProperty("jvmci.Compiler");
>> System.out.printf("jvmci.Compiler = %s%n", compiler);
>> }
>> }
>
> On a normal JDK 8 (without JVMCI), you'll get:
>
> [roland at oracle-rs graal-core]$ java -cp graal_fun JVMCIQuery
> java.vm.version = 25.92-b14
> Exception in thread "main" java.lang.IllegalArgumentException: VM option "EnableJVMCI" does not exist
> at sun.management.HotSpotDiagnostic.getVMOption(HotSpotDiagnostic.java:73)
> at JVMCIQuery.main(JVMCIQuery.java:12)
>
>
> On a JDK 8 with JVMCI (i.e. JVMCI enabled, but not used by default):
>
> [roland at oracle-rs graal-core]$ mx vm -cp graal_fun JVMCIQuery
> java.vm.version = 25.71-b01-internal-jvmci-0.17-dev
> VM option: EnableJVMCI value: true origin: VM_CREATION (read-only)
> VM option: UseJVMCICompiler value: false origin: DEFAULT (read-only)
> jvmci.Compiler = graal
>
>
> On a JDK 8 with JVMCI, using Graal as the system compiler:
>
> [roland at oracle-rs graal-core]$ mx vm -cp graal_fun -XX:+UseJVMCICompiler JVMCIQuery
> java.vm.version = 25.71-b01-internal-jvmci-0.17-dev
> VM option: EnableJVMCI value: true origin: VM_CREATION (read-only)
> VM option: UseJVMCICompiler value: true origin: VM_CREATION (read-only)
> jvmci.Compiler = graal
>
>
> - Roland
More information about the graal-dev
mailing list