changeset 34219:eb43fec35c99

8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature Summary: A test was redesigned to track xcomp and tiered states Reviewed-by: twisti
author dpochepk
date Tue, 24 Nov 2015 22:59:50 +0300
parents 4b22b04519e6
children 57d99d1614e0
files hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java
diffstat 1 files changed, 20 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java	Tue Nov 24 21:03:39 2015 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java	Tue Nov 24 22:59:50 2015 +0300
@@ -35,9 +35,11 @@
  *     -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  *     compiler.jvmci.compilerToVM.IsMatureTest
  */
+
 package compiler.jvmci.compilerToVM;
 
 import compiler.jvmci.common.testcases.SimpleClass;
+import compiler.whitebox.CompilerWhiteBoxTest;
 import jdk.vm.ci.hotspot.CompilerToVMHelper;
 import jdk.test.lib.Asserts;
 import sun.hotspot.WhiteBox;
@@ -46,6 +48,10 @@
 
 public class IsMatureTest {
     private static final WhiteBox WB = WhiteBox.getWhiteBox();
+    private static final boolean IS_XCOMP
+            = System.getProperty("java.vm.info").contains("compiled mode");
+    private static final boolean TIERED
+            = WB.getBooleanVMFlag("TieredCompilation");
 
     public static void main(String[] args) throws Exception {
         new IsMatureTest().test();
@@ -54,23 +60,21 @@
     public void test() throws Exception {
         SimpleClass sclass = new SimpleClass();
         Executable method = SimpleClass.class.getDeclaredMethod("testMethod");
-        long metaspaceMethodData = WB.getMethodData(method);
-        Asserts.assertEQ(metaspaceMethodData, 0L, "MDO should be null for "
-                 + "never invoked method");
-        boolean isMature = CompilerToVMHelper.isMature(metaspaceMethodData);
-        Asserts.assertFalse(isMature, "null MDO can't be mature");
-        for (int i = 0; i < 1000; i++) {
+        long methodData = WB.getMethodData(method);
+        boolean isMature = CompilerToVMHelper.isMature(methodData);
+        Asserts.assertEQ(methodData, 0L,
+                "Never invoked method can't have method data");
+        Asserts.assertFalse(isMature, "Never invoked method can't be mature");
+        for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
             sclass.testMethod();
         }
-        // warmed up, mdo should be ready for now
-        metaspaceMethodData = WB.getMethodData(method);
-        Asserts.assertNE(metaspaceMethodData, 0L,
-                "MDO should be available after 1000 calls");
-        for (int i = 0; i < 100_000; i++) {
-            sclass.testMethod();
-        }
-        isMature = CompilerToVMHelper.isMature(metaspaceMethodData);
-        Asserts.assertTrue(isMature,
-                "a 100_000 times invoked method should be mature");
+        methodData = WB.getMethodData(method);
+        isMature = CompilerToVMHelper.isMature(methodData);
+        Asserts.assertNE(methodData, 0L,
+                "Multiple times invoked method should have method data");
+        /* a method is not mature for -Xcomp and -Tiered,
+           see NonTieredCompPolicy::is_mature */
+        Asserts.assertEQ(isMature, !(IS_XCOMP && !TIERED),
+                "Unexpected isMature state for multiple times invoked method");
     }
 }