Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/c1/TestValueNumberingNullObject.java
41152 views
1
/*
2
* Copyright (c) 2020, 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 8237894
27
* @summary CTW: C1 compilation fails with assert(x->type()->tag() == f->type()->tag()) failed: should have same type
28
*
29
* @run main/othervm
30
* -Xcomp -Xbatch -XX:CompileCommand=compileonly,compiler.c1.T*::*
31
* -XX:CompileCommand=exclude,compiler.c1.TestValueNumberingNullObject::main
32
* -XX:CompileCommand=inline,*.*
33
* -XX:TieredStopAtLevel=3
34
* compiler.c1.TestValueNumberingNullObject
35
*/
36
37
package compiler.c1;
38
39
class T1 {
40
41
public T2 f1;
42
43
public int za() {
44
return 0;
45
}
46
47
public int zb() {
48
return 0;
49
}
50
51
public int zc() {
52
return 0;
53
}
54
55
public int zd() {
56
return 0;
57
}
58
59
public int ze() {
60
return 0;
61
}
62
63
public int zf() {
64
return 0;
65
}
66
67
public int zg() {
68
return 0;
69
}
70
71
public int zh() {
72
return 0;
73
}
74
}
75
76
class T2 {
77
78
public T1 f1;
79
80
public int zh() {
81
return 0;
82
}
83
}
84
85
public class TestValueNumberingNullObject {
86
87
public static void main(String args[]) {
88
new T1(); // Load
89
new T2(); // Load
90
try {
91
// case 1
92
// Null based field access.
93
// Value Numbering null based field access causes instructions to be eliminated across type/subtypes.
94
// declared type of these instructions are field type, so it being receiver causes problems to Type System.
95
// to mitigate this issue, we hash declared type in addition to existing hashing.
96
testFieldAccess();
97
} catch (Exception e) {
98
}
99
try {
100
// case 2
101
// Null based indexed access.
102
// Value Numbering null based indexed access causes instructions to be eliminated across type/subtypes.
103
// element basic type in encoded in the access instruction, this causes problems to Type system.
104
// declared type of these instructions are null, so it being receiver doesn't cause any problem to Type System.
105
// to mitigate this issue, we hash basic type in addition to existing hashing
106
basicTypeAccess();
107
} catch (Exception e) {
108
}
109
}
110
111
static long testFieldAccess() {
112
T1 t1 = null;
113
T2 t2 = null;
114
T1[] t3 = null;
115
T2[] t4 = null;
116
117
long value = t1.f1.zh() + t2.f1.zh();
118
// null array object based field access.
119
value += t3[2].f1.zh() + t4[2].f1.zh();
120
return value;
121
}
122
123
static long basicTypeAccess() {
124
long[] f1 = null;
125
int[] f2 = null;
126
T2[] t2 = null;
127
T1[] t1 = null;
128
return f1[5] + f2[5] + t2[5].zh() + t1[5].zh();
129
}
130
}
131
132
133