author | twisti |
Wed, 04 Nov 2015 07:23:23 -1000 | |
changeset 33632 | 038347770a9e |
parent 33191 | e155b02f22fc |
child 33813 | 4f376e851453 |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 8136421 |
|
27 |
* @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" |
|
28 |
* @library / /testlibrary /../../test/lib |
|
33191
e155b02f22fc
8139707: [TESTBUG] Quarantine unstable compiler/jvmci tests
iignatyev
parents:
33184
diff
changeset
|
29 |
* @ignore 8139703 |
33160 | 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 |
|
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
37 |
* -XX:CompileCommand=exclude,*::check -XX:+DoEscapeAnalysis -Xbatch |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
38 |
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
39 |
* compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
40 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
41 |
* -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
42 |
* -XX:CompileCommand=exclude,*::check -XX:+DoEscapeAnalysis -Xbatch |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
43 |
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true |
33160 | 44 |
* compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest |
45 |
*/ |
|
46 |
||
47 |
package compiler.jvmci.compilerToVM; |
|
48 |
||
33632 | 49 |
import java.lang.reflect.Method; |
50 |
import jdk.vm.ci.hotspot.HotSpotStackFrameReference; |
|
51 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
|
33160 | 52 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
53 |
import jdk.test.lib.Asserts; |
|
33632 | 54 |
|
55 |
import compiler.jvmci.common.CTVMUtilities; |
|
56 |
import compiler.testlibrary.CompilerUtils; |
|
57 |
||
33160 | 58 |
import sun.hotspot.WhiteBox; |
59 |
||
60 |
public class MaterializeVirtualObjectTest { |
|
61 |
private static final WhiteBox WB = WhiteBox.getWhiteBox(); |
|
62 |
private static final Method METHOD; |
|
33632 | 63 |
private static final ResolvedJavaMethod RESOLVED_METHOD; |
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
64 |
private static final boolean INVALIDATE = Boolean.getBoolean( |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
65 |
"compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate"); |
33160 | 66 |
|
67 |
static { |
|
68 |
try { |
|
69 |
METHOD = MaterializeVirtualObjectTest.class.getDeclaredMethod( |
|
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
70 |
"testFrame", String.class, boolean.class); |
33160 | 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 |
||
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
77 |
public static void main(String[] args) { |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
78 |
int levels[] = CompilerUtils.getAvailableCompilationLevels(); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
79 |
// we need compilation level 4 to use EscapeAnalysis |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
80 |
if (levels.length < 1 || levels[levels.length - 1] != 4) { |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
81 |
System.out.println("INFO: Test needs compilation level 4 to" |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
82 |
+ " be available. Skipping."); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
83 |
} else { |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
84 |
new MaterializeVirtualObjectTest().test(); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
85 |
} |
33160 | 86 |
} |
87 |
||
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
88 |
private static String getName() { |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
89 |
return "CASE: invalidate=" + INVALIDATE; |
33160 | 90 |
} |
91 |
||
92 |
private void test() { |
|
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
93 |
System.out.println(getName()); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
94 |
Asserts.assertFalse(WB.isMethodCompiled(METHOD), getName() |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
95 |
+ " : method unexpectedly compiled"); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
96 |
/* need to call testFrame at least once to be able to compile it, so |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
97 |
calling with materialize=false, because testFrame is not compiled */ |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
98 |
testFrame("someString", /* materialize= */ false); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
99 |
WB.enqueueMethodForCompilation(METHOD, 4); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
100 |
Asserts.assertTrue(WB.isMethodCompiled(METHOD), getName() |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
101 |
+ "Method unexpectedly not compiled"); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
102 |
// calling with materialize=true to materialize compiled testFrame |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
103 |
testFrame("someString", /* materialize= */ true); |
33160 | 104 |
} |
105 |
||
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
106 |
private void testFrame(String str, boolean materialize) { |
33160 | 107 |
Helper helper = new Helper(str); |
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
108 |
check(materialize); |
33160 | 109 |
Asserts.assertTrue((helper.string != null) && (this != null) |
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
110 |
&& (helper != null), getName() + " : some locals are null"); |
33160 | 111 |
} |
112 |
||
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
113 |
private void check(boolean materialize) { |
33160 | 114 |
// Materialize virtual objects on last invocation |
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
115 |
if (materialize) { |
33160 | 116 |
HotSpotStackFrameReference hsFrame = CompilerToVMHelper |
117 |
.getNextStackFrame(/* topmost frame */ null, |
|
33632 | 118 |
new ResolvedJavaMethod[]{ |
33160 | 119 |
RESOLVED_METHOD}, /* don't skip any */ 0); |
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
120 |
Asserts.assertNotNull(hsFrame, getName() + " : got null frame"); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
121 |
Asserts.assertTrue(WB.isMethodCompiled(METHOD), getName() |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
122 |
+ "Test method should be compiled"); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
123 |
Asserts.assertTrue(hsFrame.hasVirtualObjects(), getName() |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
124 |
+ ": has no virtual object before materialization"); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
125 |
CompilerToVMHelper.materializeVirtualObjects(hsFrame, INVALIDATE); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
126 |
Asserts.assertFalse(hsFrame.hasVirtualObjects(), getName() |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
127 |
+ " : has virtual object after materialization"); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
128 |
Asserts.assertEQ(WB.isMethodCompiled(METHOD), !INVALIDATE, getName() |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
129 |
+ " : unexpected compiled status"); |
33160 | 130 |
} |
131 |
} |
|
132 |
||
133 |
private class Helper { |
|
134 |
public String string; |
|
135 |
||
136 |
public Helper(String s) { |
|
137 |
this.string = s; |
|
138 |
} |
|
139 |
} |
|
140 |
} |