Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/deoptimization/test05/test05.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/test05.
28
* VM Testbase keywords: [jit, quick]
29
*
30
* @library /vmTestbase
31
* /test/lib
32
* @run main/othervm jit.deoptimization.test05.test05
33
*/
34
35
package jit.deoptimization.test05;
36
37
import nsk.share.TestFailure;
38
39
/*
40
*
41
*/
42
43
public class test05 {
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 synchronized 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.test05.B").newInstance()).foo(index);
68
}
69
catch(Exception e) {
70
}
71
}
72
return rv;
73
}
74
75
public synchronized 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 synchronized 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.test05.C").newInstance()).foo(index);
94
else
95
rv = ((B)Class.forName("jit.deoptimization.test05.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 synchronized int foo(int index) {
113
int j = count;
114
for (int i=0; i<5000; i++) {
115
j += used_alot();
116
117
if (i==4999) {
118
try {
119
j = ((D2)Class.forName("jit.deoptimization.test05.D2").newInstance()).foo(index);
120
}
121
catch (Exception e) {}
122
}
123
}
124
return j;
125
}
126
127
public synchronized int used_alot() {
128
int i=1;
129
int j=4;
130
int k=i+j;
131
byte ba[] = new byte[1000];
132
int ia[] = new int[1000];
133
return this.count + (ba.length + i + j - k - ia.length);
134
}
135
136
protected int count = 1;
137
}
138
139
class D extends C {
140
public D () {
141
super();
142
143
this.count+=2;
144
}
145
146
public int foo(int index) {
147
return super.foo(index);
148
}
149
150
public synchronized int used_alot() {
151
count += (--count);
152
return 0;
153
}
154
}
155
156
class D2 extends C {
157
public int foo(int index) {
158
return 0;
159
}
160
}
161
162