8174957: [JVMCI] jaotc is broken in Xcomp mode
authordnsimon
Wed, 15 Feb 2017 11:14:45 +0100
changeset 43962 8d1c5fdcdf76
parent 43961 441de9600d40
child 43963 6845bb645be5
8174957: [JVMCI] jaotc is broken in Xcomp mode Reviewed-by: iveresov
hotspot/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataBuilder.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/VMField.java
hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp
hotspot/test/compiler/jvmci/compilerToVM/ReadConfigurationTest.java
--- a/hotspot/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataBuilder.java	Wed Feb 15 17:40:44 2017 +0300
+++ b/hotspot/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataBuilder.java	Wed Feb 15 11:14:45 2017 +0100
@@ -70,8 +70,8 @@
      */
     private void fillVMAddresses(HotSpotVMConfigStore config) {
         for (VMField vmField : config.getFields().values()) {
-            if (vmField.value != null) {
-                final long address = vmField.value;
+            if (vmField.value != null && vmField.value instanceof Long) {
+                final long address = (Long) vmField.value;
                 String value = vmField.name;
                 /*
                  * Some fields don't contain addresses but integer values. At least don't add zero
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java	Wed Feb 15 17:40:44 2017 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java	Wed Feb 15 11:14:45 2017 +0100
@@ -76,7 +76,7 @@
             HotSpotVMConfigStore store = runtime.getConfigStore();
             for (Map.Entry<String, VMField> e : store.getFields().entrySet()) {
                 VMField field = e.getValue();
-                if (field.isStatic() && field.value != null && field.value == address) {
+                if (field.isStatic() && field.value != null && field.value instanceof Long && ((Long) field.value) == address) {
                     return e.getValue() + ":0x" + Long.toHexString(address);
                 }
             }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Wed Feb 15 17:40:44 2017 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Wed Feb 15 11:14:45 2017 +0100
@@ -497,7 +497,7 @@
             if (!field.isStatic()) {
                 printConfigLine(vm, "[vmconfig:instance field] %s %s {offset=%d[0x%x]}%n", field.type, field.name, field.offset, field.offset);
             } else {
-                String value = field.value == null ? "null" : String.format("%d[0x%x]", field.value, field.value);
+                String value = field.value == null ? "null" : field.value instanceof Boolean ? field.value.toString() : String.format("%d[0x%x]", field.value, field.value);
                 printConfigLine(vm, "[vmconfig:static field] %s %s = %s {address=0x%x}%n", field.type, field.name, value, field.address);
             }
         }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/VMField.java	Wed Feb 15 17:40:44 2017 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/VMField.java	Wed Feb 15 11:14:45 2017 +0100
@@ -38,22 +38,22 @@
     public final String type;
 
     /**
-     * If represented field is non-static, this is its offset within the containing structure.
+     * If the represented field is non-static, this is its offset within the containing structure.
      */
     public final long offset;
 
     /**
-     * If represented field is static, this is its address. Otherwise, this field is 0.
+     * If the represented field is static, this is its address. Otherwise, this is 0.
      */
     public final long address;
 
     /**
-     * Value of the field represented as a boxed long; only valid for non-oop static fields. This
-     * value is only captured once, during JVMCI initialization. If {@link #type} cannot be
-     * meaningfully (e.g., a struct) or safely (e.g., an oop) expressed as a boxed long, this is
-     * {@code null}.
+     * Value of the field represented as a boxed boolean if its C++ type is bool otherwise as a
+     * boxed long; only valid for non-oop static fields. This value is only captured once, during
+     * JVMCI initialization. If {@link #type} cannot be meaningfully (e.g., a struct) or safely
+     * (e.g., an oop) expressed as a boxed object, this is {@code null}.
      */
-    public final Long value;
+    public final Object value;
 
     /**
      * Determines if the represented field is static.
--- a/hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp	Wed Feb 15 17:40:44 2017 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp	Wed Feb 15 11:14:45 2017 +0100
@@ -117,7 +117,7 @@
     oop_field(VMField, type, "Ljava/lang/String;")                                                                                                             \
     long_field(VMField, offset)                                                                                                                                \
     long_field(VMField, address)                                                                                                                               \
-    oop_field(VMField, value, "Ljava/lang/Long;")                                                                                                              \
+    oop_field(VMField, value, "Ljava/lang/Object;")                                                                                                            \
   end_class                                                                                                                                                    \
   start_class(VMFlag)                                                                                                                                          \
     oop_field(VMFlag, name, "Ljava/lang/String;")                                                                                                              \
--- a/hotspot/test/compiler/jvmci/compilerToVM/ReadConfigurationTest.java	Wed Feb 15 17:40:44 2017 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ReadConfigurationTest.java	Wed Feb 15 11:14:45 2017 +0100
@@ -38,6 +38,7 @@
 package compiler.jvmci.compilerToVM;
 
 import jdk.test.lib.Asserts;
+import jdk.vm.ci.hotspot.VMField;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
 import jdk.vm.ci.hotspot.HotSpotVMConfigAccess;
 import jdk.vm.ci.hotspot.HotSpotVMConfigStore;
@@ -49,10 +50,19 @@
     }
 
     private void runTest() {
-        TestHotSpotVMConfig config = new TestHotSpotVMConfig(HotSpotJVMCIRuntime.runtime().getConfigStore());
+        HotSpotVMConfigStore store = HotSpotJVMCIRuntime.runtime().getConfigStore();
+        TestHotSpotVMConfig config = new TestHotSpotVMConfig(store);
         Asserts.assertNE(config.codeCacheHighBound, 0L, "Got null address");
         Asserts.assertNE(config.stubRoutineJintArrayCopy, 0L, "Got null address");
 
+        for (VMField field : store.getFields().values()) {
+                Object value = field.value;
+                if (value != null) {
+                    Asserts.assertTrue(value instanceof Long || value instanceof Boolean,
+                        "Got unexpected value type for VM field " + field.name + ": " + value.getClass());
+                }
+        }
+
         for (VMIntrinsicMethod m : config.getStore().getIntrinsics()) {
             Asserts.assertNotNull(m);
             Asserts.assertNotNull(m.declaringClass);