< prev index next >

test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java

Print this page

        

@@ -24,22 +24,21 @@
 /*
  * @test
  * @bug 8136421
  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  * @library / /testlibrary /test/lib
- * @ignore 8139703
  * @compile ../common/CompilerToVMHelper.java
  * @build sun.hotspot.WhiteBox MaterializeVirtualObjectTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  *                              jdk.vm.ci.hotspot.CompilerToVMHelper
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * @run main/othervm -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *     -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  *     -XX:CompileCommand=exclude,*::check -XX:+DoEscapeAnalysis -Xbatch
  *     -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
  *     compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * @run main/othervm -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *     -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  *     -XX:CompileCommand=exclude,*::check -XX:+DoEscapeAnalysis -Xbatch
  *     -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true
  *     compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
  */

@@ -52,28 +51,31 @@
 import jdk.vm.ci.hotspot.CompilerToVMHelper;
 import jdk.test.lib.Asserts;
 
 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) {
         int levels[] = CompilerUtils.getAvailableCompilationLevels();
         // we need compilation level 4 to use EscapeAnalysis

@@ -91,30 +93,30 @@
 
     private void test() {
         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 */
+        for (int i = 0; i < CompilerWhiteBoxTest.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[]{
                                 RESOLVED_METHOD}, /* don't skip any */ 0);
             Asserts.assertNotNull(hsFrame, getName() + " : got null frame");
< prev index next >