Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/Arrays/ArrayTests/ArrayTests.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
// srm 961012
24
// Test if array stores and reads are correct for
25
// integral types and floating points
26
27
28
/*
29
* @test
30
*
31
* @summary converted from VM Testbase jit/Arrays/ArrayTests.
32
* VM Testbase keywords: [jit, quick]
33
*
34
* @library /vmTestbase
35
* /test/lib
36
* @run main/othervm jit.Arrays.ArrayTests.ArrayTests
37
*/
38
39
package jit.Arrays.ArrayTests;
40
41
import nsk.share.TestFailure;
42
43
public class ArrayTests {
44
int base_array[];
45
static int the_int_res = 200;
46
static int the_char_res = 13041864;
47
static int the_byte_res = -312;
48
static int n = 400;
49
50
ArrayTests() {
51
base_array = new int [n];
52
int start_value = n/2;
53
for (int i=0; i<n; i++) {
54
base_array[i]= start_value;
55
start_value--;
56
}
57
};
58
59
void print() {
60
for (int i=0; i<base_array.length; i++)
61
System.out.print(" "+base_array[i]);
62
// System.out.println("Result is " + the_res);
63
}
64
65
boolean with_chars () {
66
char char_array[] = new char[n];
67
int res = 0;
68
for (int i=0; i<n; i++) {
69
char_array[i] = (char)base_array[i];
70
// System.out.print (" " + (int) char_array[i]);
71
}
72
for (int i=0; i<n; i++) {
73
res += (int) char_array[i];
74
}
75
System.out.println("chars " + res + " == " + the_char_res);
76
return (res==the_char_res);
77
}
78
79
boolean with_bytes () {
80
byte byte_array[] = new byte[n];
81
int res = 0;
82
for (int i=0; i<n; i++) {
83
byte_array[i] = (byte)base_array[i];
84
}
85
for (int i=0; i<n; i++) {
86
res += (int) byte_array[i];
87
}
88
System.out.println("bytes " + res + " == " + the_byte_res);
89
return res==the_byte_res;
90
}
91
92
boolean with_shorts () {
93
short short_array[] = new short[n];
94
int res = 0;
95
for (int i=0; i<n; i++) {
96
short_array[i] = (short)base_array[i];
97
}
98
for (int i=0; i<n; i++) {
99
res += (int) short_array[i];
100
}
101
System.out.println("shorts " + res + " == " + the_int_res);
102
return res==the_int_res;
103
}
104
105
boolean with_ints () {
106
int res = 0;
107
for (int i=0; i<n; i++) {
108
res += base_array[i];
109
}
110
// base_array is integer
111
return (res==the_int_res);
112
}
113
114
boolean with_longs() {
115
long long_array[] = new long[n];
116
int res = 0;
117
for (int i=0; i<n; i++) {
118
long_array[i] = (long)base_array[i];
119
}
120
for (int i=0; i<n; i++) {
121
res += (int) long_array[i];
122
}
123
System.out.println("longs " + res + " == " + the_int_res);
124
return res==the_int_res;
125
}
126
127
boolean with_floats () {
128
float float_array[] = new float[n];
129
int res = 0;
130
for (int i=0; i<n; i++) {
131
float_array[i] = (float)base_array[i];
132
}
133
for (int i=0; i<n; i++) {
134
res += (int) float_array[i];
135
}
136
System.out.println("floats " + res + " == " + the_int_res);
137
return res==the_int_res;
138
}
139
140
boolean with_doubles () {
141
double double_array[] = new double[n];
142
int res = 0;
143
for (int i=0; i<n; i++) {
144
double_array[i] = (double)base_array[i];
145
}
146
for (int i=0; i<n; i++) {
147
res += (int) double_array[i];
148
}
149
System.out.println("doubles " + res + " == " + the_int_res);
150
return res==the_int_res;
151
}
152
153
void check(String msg, boolean flag) {
154
if (!flag) {
155
System.out.println("ERROR in " + msg);
156
}
157
}
158
159
boolean execute() {
160
// print();
161
boolean res = true;
162
res = res & with_chars(); check("chars",res);
163
res = res & with_shorts(); check("shorts",res);
164
res = res & with_bytes(); check("bytes",res);
165
res = res & with_ints(); check("ints",res);
166
res = res & with_longs(); check("longs",res);
167
res = res & with_floats(); check("floats",res);
168
res = res & with_doubles(); check("doubles",res);
169
170
return res;
171
}
172
173
174
public static void main (String s[]) {
175
boolean res = true;
176
ArrayTests at = new ArrayTests();
177
res = res & at.execute();
178
179
if (res) System.out.println("Array read/write testsOK (srm 10/22/96)");
180
else throw new TestFailure("Error in read/write array tests!");
181
}
182
183
}
184
185