Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/eliminateAutobox/TestIdentityWithEliminateBoxInDebugInfo.java
41149 views
1
/*
2
* Copyright (c) 2021, Huawei Technologies Co., Ltd. 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 8261137
27
* @requires vm.flavor == "server"
28
* @summary Verify that box object identity matches after deoptimization When it is eliminated.
29
* @library /test/lib
30
*
31
* @run main/othervm -Xbatch compiler.c2.TestIdentityWithEliminateBoxInDebugInfo
32
*/
33
package compiler.c2;
34
35
import jdk.test.lib.Asserts;
36
37
public class TestIdentityWithEliminateBoxInDebugInfo {
38
interface TestF {
39
void apply(boolean condition);
40
}
41
42
public static void helper(TestF f) {
43
// warmup
44
for(int i = 0; i < 100000; i++) {
45
f.apply(true);
46
}
47
// deoptimize
48
f.apply(false);
49
}
50
51
public static void runTest() throws Exception {
52
helper((c) -> {
53
Integer a = Integer.valueOf(42);
54
Integer b = Integer.valueOf(-42);
55
if (!c) {
56
Asserts.assertTrue(a == Integer.valueOf(42));
57
Asserts.assertTrue(b == Integer.valueOf(-42));
58
}
59
});
60
61
helper((c) -> {
62
long highBitsOnly = 2L << 40;
63
Long a = Long.valueOf(42L);
64
Long b = Long.valueOf(-42L);
65
Long h = Long.valueOf(highBitsOnly);
66
if (!c) {
67
Asserts.assertTrue(a == Long.valueOf(42L));
68
Asserts.assertTrue(b == Long.valueOf(-42L));
69
Asserts.assertFalse(h == Long.valueOf(highBitsOnly));
70
}
71
});
72
73
helper((c) -> {
74
Character a = Character.valueOf('a');
75
Character b = Character.valueOf('Z');
76
if (!c) {
77
Asserts.assertTrue(a == Character.valueOf('a'));
78
Asserts.assertTrue(b == Character.valueOf('Z'));
79
}
80
});
81
82
helper((c) -> {
83
Short a = Short.valueOf((short)42);
84
Short b = Short.valueOf((short)-42);
85
if (!c) {
86
Asserts.assertTrue(a == Short.valueOf((short)42));
87
Asserts.assertTrue(b == Short.valueOf((short)-42));
88
}
89
});
90
91
helper((c) -> {
92
Byte a = Byte.valueOf((byte)42);
93
Byte b = Byte.valueOf((byte)-42);
94
if (!c) {
95
Asserts.assertTrue(a == Byte.valueOf((byte)42));
96
Asserts.assertTrue(b == Byte.valueOf((byte)-42));
97
}
98
});
99
100
helper((c) -> {
101
Boolean a = Boolean.valueOf(true);
102
Boolean b = Boolean.valueOf(false);
103
if (!c) {
104
Asserts.assertTrue(a == Boolean.valueOf(true));
105
Asserts.assertTrue(b == Boolean.valueOf(false));
106
}
107
});
108
}
109
110
public static void main(String[] args) throws Exception {
111
runTest();
112
}
113
}
114
115