Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/deoptimization/test04/test04.java
40948 views
1
/*
2
* Copyright (c) 2008, 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
*
27
* @summary converted from VM Testbase jit/deoptimization/test04.
28
* VM Testbase keywords: [jit, quick]
29
*
30
* @library /vmTestbase
31
* /test/lib
32
* @run main/othervm jit.deoptimization.test04.test04
33
*/
34
35
package jit.deoptimization.test04;
36
37
import nsk.share.TestFailure;
38
39
/*
40
*
41
*/
42
43
public class test04 {
44
public static void main (String[] args) {
45
A obj = new A();
46
47
int result = -1;
48
for (int index = 0; index < 1; index++) {
49
result += obj.used_alot();
50
}
51
52
if (result != 1) {
53
throw new TestFailure("result : " + result + " must equal 1");
54
}
55
}
56
}
57
58
59
class A {
60
protected int count;
61
public int foo(int index) {
62
int rv = ++count;
63
if (index < A.sIndex / 2)
64
rv = index;
65
else {
66
try {
67
rv = ((A)Class.forName("jit.deoptimization.test04.B").newInstance()).foo(index);
68
}
69
catch(Exception e) {
70
}
71
}
72
return rv;
73
}
74
75
public int used_alot() {
76
int result = 1;
77
for (int i = 0; i < A.sIndex; i++) {
78
result = foo(i);
79
}
80
return result;
81
}
82
83
protected static final int sIndex = 25000;
84
}
85
86
class B extends A {
87
public int foo(int index) {
88
int rv = 0;
89
int qrtr = A.sIndex / 4;
90
if (index > 3 * qrtr) {
91
try {
92
if (index < A.sIndex - qrtr)
93
rv = ((B)Class.forName("jit.deoptimization.test04.C").newInstance()).foo(index);
94
else
95
rv = ((B)Class.forName("jit.deoptimization.test04.D").newInstance()).foo(index);
96
}
97
catch(Exception e) {
98
}
99
}
100
else {
101
rv = 1;
102
}
103
return rv;
104
}
105
}
106
107
class C extends B {
108
public C () {
109
--this.count;
110
}
111
112
public int foo(int index) {
113
int j = count;
114
for (int i=0; i<500; i++)
115
j += used_alot();
116
return j;
117
}
118
119
public int used_alot() {
120
int i=1;
121
int j=4;
122
int k=i+j;
123
byte ba[] = new byte[1000];
124
int ia[] = new int[1000];
125
return this.count + (ba.length + i + j - k - ia.length);
126
}
127
128
protected int count = 1;
129
}
130
131
class D extends C {
132
public D () {
133
super();
134
135
this.count+=2;
136
}
137
138
public int foo(int index) {
139
return super.foo(index);
140
}
141
142
public synchronized int used_alot() {
143
count += (--count);
144
return 0;
145
}
146
}
147
148