8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
authordpochepk
Mon, 16 May 2016 16:54:09 +0300
changeset 38688 ad115177801f
parent 38687 ebf49a952c51
child 38689 3fc0148a997b
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp Reviewed-by: kvn
hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java
--- a/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java	Fri May 13 21:26:06 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java	Mon May 16 16:54:09 2016 +0300
@@ -33,13 +33,12 @@
  *          jdk.vm.ci/jdk.vm.ci.hotspot
  *          jdk.vm.ci/jdk.vm.ci.code
  *          jdk.vm.ci/jdk.vm.ci.meta
- * @ignore 8139703
  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  * @build compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:.
+ * @run main/othervm -Xmixed -Xbootclasspath/a:.
  *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  *                   -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  *                   -XX:CompileCommand=exclude,*::check
@@ -47,7 +46,7 @@
  *                   -Xbatch
  *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
  *                   compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
- * @run main/othervm -Xbootclasspath/a:.
+ * @run main/othervm -Xmixed -Xbootclasspath/a:.
  *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  *                   -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  *                   -XX:CompileCommand=exclude,*::check
@@ -67,24 +66,27 @@
 
 import compiler.jvmci.common.CTVMUtilities;
 import compiler.testlibrary.CompilerUtils;
+import compiler.whitebox.CompilerWhiteBoxTest;
 
 import sun.hotspot.WhiteBox;
 
 public class MaterializeVirtualObjectTest {
-    private static final WhiteBox WB = WhiteBox.getWhiteBox();
+    private static final WhiteBox WB;
     private static final Method METHOD;
     private static final ResolvedJavaMethod RESOLVED_METHOD;
-    private static final boolean INVALIDATE = Boolean.getBoolean(
-            "compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate");
+    private static final boolean INVALIDATE;
 
     static {
+        WB = WhiteBox.getWhiteBox();
         try {
             METHOD = MaterializeVirtualObjectTest.class.getDeclaredMethod(
-                    "testFrame", String.class, boolean.class);
+                    "testFrame", String.class, int.class);
         } catch (NoSuchMethodException e) {
             throw new Error("Can't get executable for test method", e);
         }
         RESOLVED_METHOD = CTVMUtilities.getResolvedMethod(METHOD);
+        INVALIDATE = Boolean.getBoolean(
+            "compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate");
     }
 
     public static void main(String[] args) {
@@ -106,26 +108,29 @@
         System.out.println(getName());
         Asserts.assertFalse(WB.isMethodCompiled(METHOD), getName()
                 + " : method unexpectedly compiled");
-        /* need to call testFrame at least once to be able to compile it, so
-           calling with materialize=false, because testFrame is not compiled */
-        testFrame("someString", /* materialize= */ false);
-        WB.enqueueMethodForCompilation(METHOD, 4);
+        /* need to trigger compilation by multiple method invocations
+           in order to have method profile data to be gathered */
+        boolean isTiered = WB.getBooleanVMFlag("TieredCompilation");
+        int COMPILE_THRESHOLD = isTiered ? CompilerWhiteBoxTest.THRESHOLD
+                : CompilerWhiteBoxTest.THRESHOLD * 2;
+        for (int i = 0; i < COMPILE_THRESHOLD; i++) {
+            testFrame("someString", i);
+        }
         Asserts.assertTrue(WB.isMethodCompiled(METHOD), getName()
                 + "Method unexpectedly not compiled");
-        // calling with materialize=true to materialize compiled testFrame
-        testFrame("someString", /* materialize= */ true);
+        testFrame("someString", CompilerWhiteBoxTest.THRESHOLD);
     }
 
-    private void testFrame(String str, boolean materialize) {
+    private void testFrame(String str, int iteration) {
         Helper helper = new Helper(str);
-        check(materialize);
+        check(iteration);
         Asserts.assertTrue((helper.string != null) && (this != null)
                 && (helper != null), getName() + " : some locals are null");
     }
 
-    private void check(boolean materialize) {
+    private void check(int iteration) {
         // Materialize virtual objects on last invocation
-        if (materialize) {
+        if (iteration == CompilerWhiteBoxTest.THRESHOLD) {
             HotSpotStackFrameReference hsFrame = CompilerToVMHelper
                     .getNextStackFrame(/* topmost frame */ null,
                             new ResolvedJavaMethod[]{