29 * @ignore 8139703
30 * @compile ../common/CompilerToVMHelper.java
31 * @build sun.hotspot.WhiteBox MaterializeVirtualObjectTest
32 * @run main ClassFileInstaller sun.hotspot.WhiteBox
33 * sun.hotspot.WhiteBox$WhiteBoxPermission
34 * jdk.vm.ci.hotspot.CompilerToVMHelper
35 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
36 * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
37 * -XX:CompileCommand=exclude,*::check -XX:+DoEscapeAnalysis -Xbatch
38 * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
39 * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
40 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
41 * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
42 * -XX:CompileCommand=exclude,*::check -XX:+DoEscapeAnalysis -Xbatch
43 * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true
44 * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
45 */
46
47 package compiler.jvmci.compilerToVM;
48
49 import compiler.jvmci.common.CTVMUtilities;
50 import compiler.testlibrary.CompilerUtils;
51 import jdk.vm.ci.hotspot.CompilerToVMHelper;
52 import jdk.test.lib.Asserts;
53 import sun.hotspot.WhiteBox;
54 import java.lang.reflect.Method;
55 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl;
56 import jdk.vm.ci.hotspot.HotSpotStackFrameReference;
57
58 public class MaterializeVirtualObjectTest {
59 private static final WhiteBox WB = WhiteBox.getWhiteBox();
60 private static final Method METHOD;
61 private static final HotSpotResolvedJavaMethodImpl RESOLVED_METHOD;
62 private static final boolean INVALIDATE = Boolean.getBoolean(
63 "compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate");
64
65 static {
66 try {
67 METHOD = MaterializeVirtualObjectTest.class.getDeclaredMethod(
68 "testFrame", String.class, boolean.class);
69 } catch (NoSuchMethodException e) {
70 throw new Error("Can't get executable for test method", e);
71 }
72 RESOLVED_METHOD = CTVMUtilities.getResolvedMethod(METHOD);
73 }
74
75 public static void main(String[] args) {
76 int levels[] = CompilerUtils.getAvailableCompilationLevels();
77 // we need compilation level 4 to use EscapeAnalysis
78 if (levels.length < 1 || levels[levels.length - 1] != 4) {
79 System.out.println("INFO: Test needs compilation level 4 to"
80 + " be available. Skipping.");
81 } else {
96 testFrame("someString", /* materialize= */ false);
97 WB.enqueueMethodForCompilation(METHOD, 4);
98 Asserts.assertTrue(WB.isMethodCompiled(METHOD), getName()
99 + "Method unexpectedly not compiled");
100 // calling with materialize=true to materialize compiled testFrame
101 testFrame("someString", /* materialize= */ true);
102 }
103
104 private void testFrame(String str, boolean materialize) {
105 Helper helper = new Helper(str);
106 check(materialize);
107 Asserts.assertTrue((helper.string != null) && (this != null)
108 && (helper != null), getName() + " : some locals are null");
109 }
110
111 private void check(boolean materialize) {
112 // Materialize virtual objects on last invocation
113 if (materialize) {
114 HotSpotStackFrameReference hsFrame = CompilerToVMHelper
115 .getNextStackFrame(/* topmost frame */ null,
116 new HotSpotResolvedJavaMethodImpl[]{
117 RESOLVED_METHOD}, /* don't skip any */ 0);
118 Asserts.assertNotNull(hsFrame, getName() + " : got null frame");
119 Asserts.assertTrue(WB.isMethodCompiled(METHOD), getName()
120 + "Test method should be compiled");
121 Asserts.assertTrue(hsFrame.hasVirtualObjects(), getName()
122 + ": has no virtual object before materialization");
123 CompilerToVMHelper.materializeVirtualObjects(hsFrame, INVALIDATE);
124 Asserts.assertFalse(hsFrame.hasVirtualObjects(), getName()
125 + " : has virtual object after materialization");
126 Asserts.assertEQ(WB.isMethodCompiled(METHOD), !INVALIDATE, getName()
127 + " : unexpected compiled status");
128 }
129 }
130
131 private class Helper {
132 public String string;
133
134 public Helper(String s) {
135 this.string = s;
136 }
|
29 * @ignore 8139703
30 * @compile ../common/CompilerToVMHelper.java
31 * @build sun.hotspot.WhiteBox MaterializeVirtualObjectTest
32 * @run main ClassFileInstaller sun.hotspot.WhiteBox
33 * sun.hotspot.WhiteBox$WhiteBoxPermission
34 * jdk.vm.ci.hotspot.CompilerToVMHelper
35 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
36 * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
37 * -XX:CompileCommand=exclude,*::check -XX:+DoEscapeAnalysis -Xbatch
38 * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
39 * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
40 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
41 * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
42 * -XX:CompileCommand=exclude,*::check -XX:+DoEscapeAnalysis -Xbatch
43 * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true
44 * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
45 */
46
47 package compiler.jvmci.compilerToVM;
48
49 import java.lang.reflect.Method;
50 import jdk.vm.ci.hotspot.HotSpotStackFrameReference;
51 import jdk.vm.ci.meta.ResolvedJavaMethod;
52 import jdk.vm.ci.hotspot.CompilerToVMHelper;
53 import jdk.test.lib.Asserts;
54
55 import compiler.jvmci.common.CTVMUtilities;
56 import compiler.testlibrary.CompilerUtils;
57
58 import sun.hotspot.WhiteBox;
59
60 public class MaterializeVirtualObjectTest {
61 private static final WhiteBox WB = WhiteBox.getWhiteBox();
62 private static final Method METHOD;
63 private static final ResolvedJavaMethod RESOLVED_METHOD;
64 private static final boolean INVALIDATE = Boolean.getBoolean(
65 "compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate");
66
67 static {
68 try {
69 METHOD = MaterializeVirtualObjectTest.class.getDeclaredMethod(
70 "testFrame", String.class, boolean.class);
71 } catch (NoSuchMethodException e) {
72 throw new Error("Can't get executable for test method", e);
73 }
74 RESOLVED_METHOD = CTVMUtilities.getResolvedMethod(METHOD);
75 }
76
77 public static void main(String[] args) {
78 int levels[] = CompilerUtils.getAvailableCompilationLevels();
79 // we need compilation level 4 to use EscapeAnalysis
80 if (levels.length < 1 || levels[levels.length - 1] != 4) {
81 System.out.println("INFO: Test needs compilation level 4 to"
82 + " be available. Skipping.");
83 } else {
98 testFrame("someString", /* materialize= */ false);
99 WB.enqueueMethodForCompilation(METHOD, 4);
100 Asserts.assertTrue(WB.isMethodCompiled(METHOD), getName()
101 + "Method unexpectedly not compiled");
102 // calling with materialize=true to materialize compiled testFrame
103 testFrame("someString", /* materialize= */ true);
104 }
105
106 private void testFrame(String str, boolean materialize) {
107 Helper helper = new Helper(str);
108 check(materialize);
109 Asserts.assertTrue((helper.string != null) && (this != null)
110 && (helper != null), getName() + " : some locals are null");
111 }
112
113 private void check(boolean materialize) {
114 // Materialize virtual objects on last invocation
115 if (materialize) {
116 HotSpotStackFrameReference hsFrame = CompilerToVMHelper
117 .getNextStackFrame(/* topmost frame */ null,
118 new ResolvedJavaMethod[]{
119 RESOLVED_METHOD}, /* don't skip any */ 0);
120 Asserts.assertNotNull(hsFrame, getName() + " : got null frame");
121 Asserts.assertTrue(WB.isMethodCompiled(METHOD), getName()
122 + "Test method should be compiled");
123 Asserts.assertTrue(hsFrame.hasVirtualObjects(), getName()
124 + ": has no virtual object before materialization");
125 CompilerToVMHelper.materializeVirtualObjects(hsFrame, INVALIDATE);
126 Asserts.assertFalse(hsFrame.hasVirtualObjects(), getName()
127 + " : has virtual object after materialization");
128 Asserts.assertEQ(WB.isMethodCompiled(METHOD), !INVALIDATE, getName()
129 + " : unexpected compiled status");
130 }
131 }
132
133 private class Helper {
134 public String string;
135
136 public Helper(String s) {
137 this.string = s;
138 }
|