8193577: nsk/jvmti/IterateThroughHeap/filter-tagged fails with Graal in Xcomp mode
authoriveresov
Thu, 29 Nov 2018 11:47:08 -0800
changeset 52770 5e9d836c5ad8
parent 52769 7c8d9a89e298
child 52771 fffe38c905a0
8193577: nsk/jvmti/IterateThroughHeap/filter-tagged fails with Graal in Xcomp mode Summary: Make field values opaque to compiler Reviewed-by: dlong, sspitsyn
test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter-tagged/HeapFilter.cpp
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter-tagged/HeapFilter.cpp	Thu Nov 29 11:14:36 2018 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter-tagged/HeapFilter.cpp	Thu Nov 29 11:47:08 2018 -0800
@@ -61,10 +61,11 @@
 //expected values
 #define INT_ARRAY_LENGTH 2
 
-static jint TAGGED_STATIC_INT_VALUE = 0xC0DE01;
-static jint TAGGED_INT_VALUE = 0xC0DE02;
-static jint UNTAGGED_STATIC_INT_VALUE = 0xC0DE03;
-static jint UNTAGGED_INT_VALUE = 0xC0DE04;
+static jint POISON = 0x1234;
+static jint TAGGED_STATIC_INT_VALUE = 0xC0DE01 + POISON;
+static jint TAGGED_INT_VALUE = 0xC0DE02 + POISON;
+static jint UNTAGGED_STATIC_INT_VALUE = 0xC0DE03 + POISON;
+static jint UNTAGGED_INT_VALUE = 0xC0DE04 + POISON;
 static jint TAGGED_INT_ARRAY_VALUE[] = {0xC0DE01,
                                                  0xC0DE01+1};
 static jint UNTAGGED_INT_ARRAY_VALUE[] = {0xC0DE03,
@@ -352,6 +353,14 @@
       if (is_primitive_type(objects_info[object].fields[field].signature)) {
         objects_info[object].fields[field].primitive = 1;
         is_primitive = 1;
+        // Add POISON to all int fields to make the values opaque to the JIT compiler.
+        if (is_static) {
+          jint value = jni->GetStaticIntField(targetClass, targetFields[field]);
+          jni->SetStaticIntField(targetClass, targetFields[field], value + POISON);
+        } else {
+          jint value = jni->GetIntField(target, targetFields[field]);
+          jni->SetIntField(target, targetFields[field], value + POISON);
+        }
       } else {
         jobject value;
         if (!NSK_JVMTI_VERIFY(jvmti->GetFieldModifiers(