author | dpochepk |
Wed, 20 Jul 2016 19:29:10 +0300 | |
changeset 40076 | 1e283716fd17 |
parent 40059 | c2304140ed64 |
child 40631 | ed82623d7831 |
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 |
|
39291
a4efe145313d
8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents:
38700
diff
changeset
|
27 |
* @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") |
40076
1e283716fd17
8161508: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before materialization
dpochepk
parents:
40059
diff
changeset
|
28 |
* & (vm.compMode != "Xcomp" | vm.opt.TieredCompilation == null | vm.opt.TieredCompilation == true) |
1e283716fd17
8161508: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before materialization
dpochepk
parents:
40059
diff
changeset
|
29 |
* @summary no "-Xcomp -XX:-TieredCompilation" combination allowed until JDK-8140018 is resolved |
33730
30e064828045
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents:
33191
diff
changeset
|
30 |
* @library / /testlibrary /test/lib |
36508 | 31 |
* @library ../common/patches |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
36508
diff
changeset
|
32 |
* @modules java.base/jdk.internal.misc |
36508 | 33 |
* @modules java.base/jdk.internal.org.objectweb.asm |
34 |
* java.base/jdk.internal.org.objectweb.asm.tree |
|
35 |
* jdk.vm.ci/jdk.vm.ci.hotspot |
|
36 |
* jdk.vm.ci/jdk.vm.ci.code |
|
37 |
* jdk.vm.ci/jdk.vm.ci.meta |
|
40053
b3617982544e
8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents:
39291
diff
changeset
|
38 |
* |
36508 | 39 |
* @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper |
40 |
* @build compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest |
|
41 |
* @build sun.hotspot.WhiteBox |
|
40053
b3617982544e
8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents:
39291
diff
changeset
|
42 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
b3617982544e
8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents:
39291
diff
changeset
|
43 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
44 |
* @run main/othervm -Xmixed -Xbootclasspath/a:. |
36508 | 45 |
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
46 |
* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
|
47 |
* -XX:CompileCommand=exclude,*::check |
|
40076
1e283716fd17
8161508: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before materialization
dpochepk
parents:
40059
diff
changeset
|
48 |
* -XX:+DoEscapeAnalysis -XX:-UseCounterDecay |
36508 | 49 |
* -Xbatch |
50 |
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false |
|
51 |
* compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest |
|
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
52 |
* @run main/othervm -Xmixed -Xbootclasspath/a:. |
36508 | 53 |
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
54 |
* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
|
55 |
* -XX:CompileCommand=exclude,*::check |
|
40076
1e283716fd17
8161508: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before materialization
dpochepk
parents:
40059
diff
changeset
|
56 |
* -XX:+DoEscapeAnalysis -XX:-UseCounterDecay |
36508 | 57 |
* -Xbatch |
58 |
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true |
|
59 |
* compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest |
|
33160 | 60 |
*/ |
61 |
||
62 |
package compiler.jvmci.compilerToVM; |
|
63 |
||
33632 | 64 |
import compiler.jvmci.common.CTVMUtilities; |
65 |
import compiler.testlibrary.CompilerUtils; |
|
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
66 |
import compiler.whitebox.CompilerWhiteBoxTest; |
40059 | 67 |
import jdk.test.lib.Asserts; |
68 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
|
69 |
import jdk.vm.ci.hotspot.HotSpotStackFrameReference; |
|
70 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
|
71 |
import sun.hotspot.WhiteBox; |
|
33632 | 72 |
|
40059 | 73 |
import java.lang.reflect.Method; |
33160 | 74 |
|
75 |
public class MaterializeVirtualObjectTest { |
|
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
76 |
private static final WhiteBox WB; |
33160 | 77 |
private static final Method METHOD; |
33632 | 78 |
private static final ResolvedJavaMethod RESOLVED_METHOD; |
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
79 |
private static final boolean INVALIDATE; |
38700
6aa6444c1b48
8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents:
38688
diff
changeset
|
80 |
private static final int COMPILE_THRESHOLD; |
33160 | 81 |
|
82 |
static { |
|
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
83 |
WB = WhiteBox.getWhiteBox(); |
33160 | 84 |
try { |
85 |
METHOD = MaterializeVirtualObjectTest.class.getDeclaredMethod( |
|
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
86 |
"testFrame", String.class, int.class); |
33160 | 87 |
} catch (NoSuchMethodException e) { |
88 |
throw new Error("Can't get executable for test method", e); |
|
89 |
} |
|
90 |
RESOLVED_METHOD = CTVMUtilities.getResolvedMethod(METHOD); |
|
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
91 |
INVALIDATE = Boolean.getBoolean( |
38700
6aa6444c1b48
8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents:
38688
diff
changeset
|
92 |
"compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate"); |
6aa6444c1b48
8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents:
38688
diff
changeset
|
93 |
COMPILE_THRESHOLD = WB.getBooleanVMFlag("TieredCompilation") |
6aa6444c1b48
8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents:
38688
diff
changeset
|
94 |
? CompilerWhiteBoxTest.THRESHOLD |
6aa6444c1b48
8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents:
38688
diff
changeset
|
95 |
: CompilerWhiteBoxTest.THRESHOLD * 2; |
33160 | 96 |
} |
97 |
||
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
98 |
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
|
99 |
int levels[] = CompilerUtils.getAvailableCompilationLevels(); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
100 |
// 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
|
101 |
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
|
102 |
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
|
103 |
+ " be available. Skipping."); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
104 |
} else { |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
105 |
new MaterializeVirtualObjectTest().test(); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
106 |
} |
33160 | 107 |
} |
108 |
||
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
109 |
private static String getName() { |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
110 |
return "CASE: invalidate=" + INVALIDATE; |
33160 | 111 |
} |
112 |
||
113 |
private void test() { |
|
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
114 |
System.out.println(getName()); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
115 |
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
|
116 |
+ " : method unexpectedly compiled"); |
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
117 |
/* need to trigger compilation by multiple method invocations |
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
118 |
in order to have method profile data to be gathered */ |
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
119 |
for (int i = 0; i < COMPILE_THRESHOLD; i++) { |
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
120 |
testFrame("someString", i); |
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
121 |
} |
33184
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
122 |
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
|
123 |
+ "Method unexpectedly not compiled"); |
38700
6aa6444c1b48
8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents:
38688
diff
changeset
|
124 |
testFrame("someString", COMPILE_THRESHOLD); |
33160 | 125 |
} |
126 |
||
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
127 |
private void testFrame(String str, int iteration) { |
33160 | 128 |
Helper helper = new Helper(str); |
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
129 |
check(iteration); |
33160 | 130 |
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
|
131 |
&& (helper != null), getName() + " : some locals are null"); |
33160 | 132 |
} |
133 |
||
38688
ad115177801f
8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents:
38152
diff
changeset
|
134 |
private void check(int iteration) { |
33160 | 135 |
// Materialize virtual objects on last invocation |
38700
6aa6444c1b48
8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents:
38688
diff
changeset
|
136 |
if (iteration == COMPILE_THRESHOLD) { |
33160 | 137 |
HotSpotStackFrameReference hsFrame = CompilerToVMHelper |
138 |
.getNextStackFrame(/* topmost frame */ null, |
|
33632 | 139 |
new ResolvedJavaMethod[]{ |
33160 | 140 |
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
|
141 |
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
|
142 |
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
|
143 |
+ "Test method should be compiled"); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
144 |
Asserts.assertTrue(hsFrame.hasVirtualObjects(), getName() |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
145 |
+ ": 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
|
146 |
CompilerToVMHelper.materializeVirtualObjects(hsFrame, INVALIDATE); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
147 |
Asserts.assertFalse(hsFrame.hasVirtualObjects(), getName() |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
148 |
+ " : has virtual object after materialization"); |
db796ab93ba7
8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents:
33160
diff
changeset
|
149 |
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
|
150 |
+ " : unexpected compiled status"); |
33160 | 151 |
} |
152 |
} |
|
153 |
||
154 |
private class Helper { |
|
155 |
public String string; |
|
156 |
||
157 |
public Helper(String s) { |
|
158 |
this.string = s; |
|
159 |
} |
|
160 |
} |
|
161 |
} |