--- old/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java 2018-07-11 09:54:20.474099348 -0700
+++ new/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java 2018-07-11 09:54:20.230100203 -0700
@@ -23,9 +23,13 @@
package MyPackage;
+import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.List;
+import com.sun.management.HotSpotDiagnosticMXBean;
+import com.sun.management.VMOption;
+
/** API for handling the underlying heap sampling monitoring system. */
public class HeapMonitor {
private static int[][] arrays;
@@ -56,7 +60,7 @@
int sum = 0;
List frames = new ArrayList();
allocate(frames);
- frames.add(new Frame("allocate", "()Ljava/util/List;", "HeapMonitor.java", 58));
+ frames.add(new Frame("allocate", "()Ljava/util/List;", "HeapMonitor.java", 62));
return frames;
}
@@ -65,8 +69,8 @@
for (int j = 0; j < allocationIterations; j++) {
sum += actuallyAllocate();
}
- frames.add(new Frame("actuallyAllocate", "()I", "HeapMonitor.java", 93));
- frames.add(new Frame("allocate", "(Ljava/util/List;)V", "HeapMonitor.java", 66));
+ frames.add(new Frame("actuallyAllocate", "()I", "HeapMonitor.java", 97));
+ frames.add(new Frame("allocate", "(Ljava/util/List;)V", "HeapMonitor.java", 70));
}
public static List repeatAllocate(int max) {
@@ -74,7 +78,7 @@
for (int i = 0; i < max; i++) {
frames = allocate();
}
- frames.add(new Frame("repeatAllocate", "(I)Ljava/util/List;", "HeapMonitor.java", 75));
+ frames.add(new Frame("repeatAllocate", "(I)Ljava/util/List;", "HeapMonitor.java", 79));
return frames;
}
@@ -152,14 +156,42 @@
}
public native static int sampledEvents();
- public native static boolean obtainedEvents(Frame[] frames);
- public native static boolean garbageContains(Frame[] frames);
+ public native static boolean obtainedEvents(Frame[] frames, boolean checkLines);
+ public native static boolean garbageContains(Frame[] frames, boolean checkLines);
public native static boolean eventStorageIsEmpty();
public native static void resetEventStorage();
public native static int getEventStorageElementCount();
public native static void forceGarbageCollection();
public native static boolean enableVMEvents();
+ private static boolean getCheckLines() {
+ boolean checkLines = true;
+
+ // Do not check lines for Graal since it is not always "precise" with BCIs at uncommon traps.
+ try {
+ HotSpotDiagnosticMXBean bean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
+
+ VMOption enableJVMCI = bean.getVMOption("EnableJVMCI");
+ VMOption useJVMCICompiler = bean.getVMOption("UseJVMCICompiler");
+ String compiler = System.getProperty("jvmci.Compiler");
+
+ checkLines = !(enableJVMCI.getValue().equals("true")
+ && useJVMCICompiler.getValue().equals("true") && compiler.equals("graal"));
+ } catch (Exception e) {
+ // NOP.
+ }
+
+ return checkLines;
+ }
+
+ public static boolean obtainedEvents(Frame[] frames) {
+ return obtainedEvents(frames, getCheckLines());
+ }
+
+ public static boolean garbageContains(Frame[] frames) {
+ return garbageContains(frames, getCheckLines());
+ }
+
public static boolean statsHaveExpectedNumberSamples(int expected, int acceptedErrorPercentage) {
double actual = getEventStorageElementCount();
double diffPercentage = Math.abs(actual - expected) / expected;