author | stefank |
Thu, 25 Feb 2016 13:08:19 +0100 | |
changeset 37056 | 109f610020fa |
parent 35898 | ddc274f0052f |
child 37462 | 58bb9394a98b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
35898
ddc274f0052f
8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents:
35529
diff
changeset
|
2 |
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "runtime/os.hpp" |
|
27 |
#include "utilities/globalDefinitions.hpp" |
|
28 |
#include "utilities/top.hpp" |
|
29 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
30 |
// Basic error support |
1 | 31 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
32 |
// Info for oops within a java object. Defaults are zero so |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
33 |
// things will break badly if incorrectly initialized. |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
34 |
int heapOopSize = 0; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
35 |
int LogBytesPerHeapOop = 0; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
36 |
int LogBitsPerHeapOop = 0; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
37 |
int BytesPerHeapOop = 0; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
38 |
int BitsPerHeapOop = 0; |
1 | 39 |
|
5694
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
40 |
// Object alignment, in units of HeapWords. |
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
41 |
// Defaults are -1 so things will break badly if incorrectly initialized. |
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
42 |
int MinObjAlignment = -1; |
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
43 |
int MinObjAlignmentInBytes = -1; |
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
44 |
int MinObjAlignmentInBytesMask = 0; |
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
45 |
|
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
46 |
int LogMinObjAlignment = -1; |
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
47 |
int LogMinObjAlignmentInBytes = -1; |
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
48 |
|
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
49 |
// Oop encoding heap max |
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
50 |
uint64_t OopEncodingHeapMax = 0; |
1e0532a6abff
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
670
diff
changeset
|
51 |
|
1 | 52 |
void basic_fatal(const char* msg) { |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
22234
diff
changeset
|
53 |
fatal("%s", msg); |
1 | 54 |
} |
55 |
||
56 |
// Something to help porters sleep at night |
|
57 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
58 |
void basic_types_init() { |
1 | 59 |
#ifdef ASSERT |
60 |
#ifdef _LP64 |
|
61 |
assert(min_intx == (intx)CONST64(0x8000000000000000), "correct constant"); |
|
62 |
assert(max_intx == CONST64(0x7FFFFFFFFFFFFFFF), "correct constant"); |
|
63 |
assert(max_uintx == CONST64(0xFFFFFFFFFFFFFFFF), "correct constant"); |
|
64 |
assert( 8 == sizeof( intx), "wrong size for basic type"); |
|
65 |
assert( 8 == sizeof( jobject), "wrong size for basic type"); |
|
66 |
#else |
|
67 |
assert(min_intx == (intx)0x80000000, "correct constant"); |
|
68 |
assert(max_intx == 0x7FFFFFFF, "correct constant"); |
|
69 |
assert(max_uintx == 0xFFFFFFFF, "correct constant"); |
|
70 |
assert( 4 == sizeof( intx), "wrong size for basic type"); |
|
71 |
assert( 4 == sizeof( jobject), "wrong size for basic type"); |
|
72 |
#endif |
|
73 |
assert( (~max_juint) == 0, "max_juint has all its bits"); |
|
74 |
assert( (~max_uintx) == 0, "max_uintx has all its bits"); |
|
75 |
assert( (~max_julong) == 0, "max_julong has all its bits"); |
|
76 |
assert( 1 == sizeof( jbyte), "wrong size for basic type"); |
|
77 |
assert( 2 == sizeof( jchar), "wrong size for basic type"); |
|
78 |
assert( 2 == sizeof( jshort), "wrong size for basic type"); |
|
79 |
assert( 4 == sizeof( juint), "wrong size for basic type"); |
|
80 |
assert( 4 == sizeof( jint), "wrong size for basic type"); |
|
81 |
assert( 1 == sizeof( jboolean), "wrong size for basic type"); |
|
82 |
assert( 8 == sizeof( jlong), "wrong size for basic type"); |
|
83 |
assert( 4 == sizeof( jfloat), "wrong size for basic type"); |
|
84 |
assert( 8 == sizeof( jdouble), "wrong size for basic type"); |
|
85 |
assert( 1 == sizeof( u1), "wrong size for basic type"); |
|
86 |
assert( 2 == sizeof( u2), "wrong size for basic type"); |
|
87 |
assert( 4 == sizeof( u4), "wrong size for basic type"); |
|
35898
ddc274f0052f
8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents:
35529
diff
changeset
|
88 |
assert(wordSize == BytesPerWord, "should be the same since they're used interchangeably"); |
ddc274f0052f
8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents:
35529
diff
changeset
|
89 |
assert(wordSize == HeapWordSize, "should be the same since they're also used interchangeably"); |
1 | 90 |
|
91 |
int num_type_chars = 0; |
|
92 |
for (int i = 0; i < 99; i++) { |
|
93 |
if (type2char((BasicType)i) != 0) { |
|
94 |
assert(char2type(type2char((BasicType)i)) == i, "proper inverses"); |
|
95 |
num_type_chars++; |
|
96 |
} |
|
97 |
} |
|
98 |
assert(num_type_chars == 11, "must have tested the right number of mappings"); |
|
99 |
assert(char2type(0) == T_ILLEGAL, "correct illegality"); |
|
100 |
||
101 |
{ |
|
102 |
for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) { |
|
103 |
BasicType vt = (BasicType)i; |
|
104 |
BasicType ft = type2field[vt]; |
|
105 |
switch (vt) { |
|
106 |
// the following types might plausibly show up in memory layouts: |
|
107 |
case T_BOOLEAN: |
|
108 |
case T_BYTE: |
|
109 |
case T_CHAR: |
|
110 |
case T_SHORT: |
|
111 |
case T_INT: |
|
112 |
case T_FLOAT: |
|
113 |
case T_DOUBLE: |
|
114 |
case T_LONG: |
|
115 |
case T_OBJECT: |
|
13969
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
116 |
case T_ADDRESS: // random raw pointer |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
117 |
case T_METADATA: // metadata pointer |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
118 |
case T_NARROWOOP: // compressed pointer |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
119 |
case T_NARROWKLASS: // compressed klass pointer |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
120 |
case T_CONFLICT: // might as well support a bottom type |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
121 |
case T_VOID: // padding or other unaddressed word |
1 | 122 |
// layout type must map to itself |
123 |
assert(vt == ft, ""); |
|
124 |
break; |
|
125 |
default: |
|
126 |
// non-layout type must map to a (different) layout type |
|
127 |
assert(vt != ft, ""); |
|
128 |
assert(ft == type2field[ft], ""); |
|
129 |
} |
|
130 |
// every type must map to same-sized layout type: |
|
131 |
assert(type2size[vt] == type2size[ft], ""); |
|
132 |
} |
|
133 |
} |
|
134 |
// These are assumed, e.g., when filling HeapWords with juints. |
|
135 |
assert(is_power_of_2(sizeof(juint)), "juint must be power of 2"); |
|
136 |
assert(is_power_of_2(HeapWordSize), "HeapWordSize must be power of 2"); |
|
137 |
assert((size_t)HeapWordSize >= sizeof(juint), |
|
138 |
"HeapWord should be at least as large as juint"); |
|
139 |
assert(sizeof(NULL) == sizeof(char*), "NULL must be same size as pointer"); |
|
140 |
#endif |
|
141 |
||
142 |
if( JavaPriority1_To_OSPriority != -1 ) |
|
143 |
os::java_to_os_priority[1] = JavaPriority1_To_OSPriority; |
|
144 |
if( JavaPriority2_To_OSPriority != -1 ) |
|
145 |
os::java_to_os_priority[2] = JavaPriority2_To_OSPriority; |
|
146 |
if( JavaPriority3_To_OSPriority != -1 ) |
|
147 |
os::java_to_os_priority[3] = JavaPriority3_To_OSPriority; |
|
148 |
if( JavaPriority4_To_OSPriority != -1 ) |
|
149 |
os::java_to_os_priority[4] = JavaPriority4_To_OSPriority; |
|
150 |
if( JavaPriority5_To_OSPriority != -1 ) |
|
151 |
os::java_to_os_priority[5] = JavaPriority5_To_OSPriority; |
|
152 |
if( JavaPriority6_To_OSPriority != -1 ) |
|
153 |
os::java_to_os_priority[6] = JavaPriority6_To_OSPriority; |
|
154 |
if( JavaPriority7_To_OSPriority != -1 ) |
|
155 |
os::java_to_os_priority[7] = JavaPriority7_To_OSPriority; |
|
156 |
if( JavaPriority8_To_OSPriority != -1 ) |
|
157 |
os::java_to_os_priority[8] = JavaPriority8_To_OSPriority; |
|
158 |
if( JavaPriority9_To_OSPriority != -1 ) |
|
159 |
os::java_to_os_priority[9] = JavaPriority9_To_OSPriority; |
|
160 |
if(JavaPriority10_To_OSPriority != -1 ) |
|
161 |
os::java_to_os_priority[10] = JavaPriority10_To_OSPriority; |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
162 |
|
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
163 |
// Set the size of basic types here (after argument parsing but before |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
164 |
// stub generation). |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
165 |
if (UseCompressedOops) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
166 |
// Size info for oops within java objects is fixed |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
167 |
heapOopSize = jintSize; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
168 |
LogBytesPerHeapOop = LogBytesPerInt; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
169 |
LogBitsPerHeapOop = LogBitsPerInt; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
170 |
BytesPerHeapOop = BytesPerInt; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
171 |
BitsPerHeapOop = BitsPerInt; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
172 |
} else { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
173 |
heapOopSize = oopSize; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
174 |
LogBytesPerHeapOop = LogBytesPerWord; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
175 |
LogBitsPerHeapOop = LogBitsPerWord; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
176 |
BytesPerHeapOop = BytesPerWord; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
177 |
BitsPerHeapOop = BitsPerWord; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
178 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
179 |
_type2aelembytes[T_OBJECT] = heapOopSize; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
180 |
_type2aelembytes[T_ARRAY] = heapOopSize; |
1 | 181 |
} |
182 |
||
183 |
||
184 |
// Map BasicType to signature character |
|
13969
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
185 |
char type2char_tab[T_CONFLICT+1]={ 0, 0, 0, 0, 'Z', 'C', 'F', 'D', 'B', 'S', 'I', 'J', 'L', '[', 'V', 0, 0, 0, 0, 0}; |
1 | 186 |
|
187 |
// Map BasicType to Java type name |
|
188 |
const char* type2name_tab[T_CONFLICT+1] = { |
|
189 |
NULL, NULL, NULL, NULL, |
|
190 |
"boolean", |
|
191 |
"char", |
|
192 |
"float", |
|
193 |
"double", |
|
194 |
"byte", |
|
195 |
"short", |
|
196 |
"int", |
|
197 |
"long", |
|
198 |
"object", |
|
199 |
"array", |
|
200 |
"void", |
|
201 |
"*address*", |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
202 |
"*narrowoop*", |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
203 |
"*metadata*", |
13969
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
204 |
"*narrowklass*", |
1 | 205 |
"*conflict*" |
206 |
}; |
|
207 |
||
208 |
||
209 |
BasicType name2type(const char* name) { |
|
210 |
for (int i = T_BOOLEAN; i <= T_VOID; i++) { |
|
211 |
BasicType t = (BasicType)i; |
|
212 |
if (type2name_tab[t] != NULL && 0 == strcmp(type2name_tab[t], name)) |
|
213 |
return t; |
|
214 |
} |
|
215 |
return T_ILLEGAL; |
|
216 |
} |
|
217 |
||
218 |
||
219 |
// Map BasicType to size in words |
|
13969
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
220 |
int type2size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 1, -1}; |
1 | 221 |
|
222 |
BasicType type2field[T_CONFLICT+1] = { |
|
223 |
(BasicType)0, // 0, |
|
224 |
(BasicType)0, // 1, |
|
225 |
(BasicType)0, // 2, |
|
226 |
(BasicType)0, // 3, |
|
227 |
T_BOOLEAN, // T_BOOLEAN = 4, |
|
228 |
T_CHAR, // T_CHAR = 5, |
|
229 |
T_FLOAT, // T_FLOAT = 6, |
|
230 |
T_DOUBLE, // T_DOUBLE = 7, |
|
231 |
T_BYTE, // T_BYTE = 8, |
|
232 |
T_SHORT, // T_SHORT = 9, |
|
233 |
T_INT, // T_INT = 10, |
|
234 |
T_LONG, // T_LONG = 11, |
|
235 |
T_OBJECT, // T_OBJECT = 12, |
|
236 |
T_OBJECT, // T_ARRAY = 13, |
|
237 |
T_VOID, // T_VOID = 14, |
|
238 |
T_ADDRESS, // T_ADDRESS = 15, |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
239 |
T_NARROWOOP, // T_NARROWOOP= 16, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
240 |
T_METADATA, // T_METADATA = 17, |
13969
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
241 |
T_NARROWKLASS, // T_NARROWKLASS = 18, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
242 |
T_CONFLICT // T_CONFLICT = 19, |
1 | 243 |
}; |
244 |
||
245 |
||
246 |
BasicType type2wfield[T_CONFLICT+1] = { |
|
247 |
(BasicType)0, // 0, |
|
248 |
(BasicType)0, // 1, |
|
249 |
(BasicType)0, // 2, |
|
250 |
(BasicType)0, // 3, |
|
251 |
T_INT, // T_BOOLEAN = 4, |
|
252 |
T_INT, // T_CHAR = 5, |
|
253 |
T_FLOAT, // T_FLOAT = 6, |
|
254 |
T_DOUBLE, // T_DOUBLE = 7, |
|
255 |
T_INT, // T_BYTE = 8, |
|
256 |
T_INT, // T_SHORT = 9, |
|
257 |
T_INT, // T_INT = 10, |
|
258 |
T_LONG, // T_LONG = 11, |
|
259 |
T_OBJECT, // T_OBJECT = 12, |
|
260 |
T_OBJECT, // T_ARRAY = 13, |
|
261 |
T_VOID, // T_VOID = 14, |
|
262 |
T_ADDRESS, // T_ADDRESS = 15, |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
263 |
T_NARROWOOP, // T_NARROWOOP = 16, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
264 |
T_METADATA, // T_METADATA = 17, |
13969
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
265 |
T_NARROWKLASS, // T_NARROWKLASS = 18, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
266 |
T_CONFLICT // T_CONFLICT = 19, |
1 | 267 |
}; |
268 |
||
269 |
||
202
dc13bf0e5d5d
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
1
diff
changeset
|
270 |
int _type2aelembytes[T_CONFLICT+1] = { |
13969
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
271 |
0, // 0 |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
272 |
0, // 1 |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
273 |
0, // 2 |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
274 |
0, // 3 |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
275 |
T_BOOLEAN_aelem_bytes, // T_BOOLEAN = 4, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
276 |
T_CHAR_aelem_bytes, // T_CHAR = 5, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
277 |
T_FLOAT_aelem_bytes, // T_FLOAT = 6, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
278 |
T_DOUBLE_aelem_bytes, // T_DOUBLE = 7, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
279 |
T_BYTE_aelem_bytes, // T_BYTE = 8, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
280 |
T_SHORT_aelem_bytes, // T_SHORT = 9, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
281 |
T_INT_aelem_bytes, // T_INT = 10, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
282 |
T_LONG_aelem_bytes, // T_LONG = 11, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
283 |
T_OBJECT_aelem_bytes, // T_OBJECT = 12, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
284 |
T_ARRAY_aelem_bytes, // T_ARRAY = 13, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
285 |
0, // T_VOID = 14, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
286 |
T_OBJECT_aelem_bytes, // T_ADDRESS = 15, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
287 |
T_NARROWOOP_aelem_bytes, // T_NARROWOOP= 16, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
288 |
T_OBJECT_aelem_bytes, // T_METADATA = 17, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
289 |
T_NARROWKLASS_aelem_bytes, // T_NARROWKLASS= 18, |
d2a189b83b87
7054512: Compress class pointers after perm gen removal
roland
parents:
13742
diff
changeset
|
290 |
0 // T_CONFLICT = 19, |
1 | 291 |
}; |
292 |
||
202
dc13bf0e5d5d
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
1
diff
changeset
|
293 |
#ifdef ASSERT |
dc13bf0e5d5d
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
1
diff
changeset
|
294 |
int type2aelembytes(BasicType t, bool allow_address) { |
dc13bf0e5d5d
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
1
diff
changeset
|
295 |
assert(allow_address || t != T_ADDRESS, " "); |
dc13bf0e5d5d
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
1
diff
changeset
|
296 |
return _type2aelembytes[t]; |
dc13bf0e5d5d
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
1
diff
changeset
|
297 |
} |
dc13bf0e5d5d
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
1
diff
changeset
|
298 |
#endif |
1 | 299 |
|
300 |
// Support for 64-bit integer arithmetic |
|
301 |
||
302 |
// The following code is mostly taken from JVM typedefs_md.h and system_md.c |
|
303 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
202
diff
changeset
|
304 |
static const jlong high_bit = (jlong)1 << (jlong)63; |
1 | 305 |
static const jlong other_bits = ~high_bit; |
306 |
||
307 |
jlong float2long(jfloat f) { |
|
308 |
jlong tmp = (jlong) f; |
|
309 |
if (tmp != high_bit) { |
|
310 |
return tmp; |
|
311 |
} else { |
|
312 |
if (g_isnan((jdouble)f)) { |
|
313 |
return 0; |
|
314 |
} |
|
315 |
if (f < 0) { |
|
316 |
return high_bit; |
|
317 |
} else { |
|
318 |
return other_bits; |
|
319 |
} |
|
320 |
} |
|
321 |
} |
|
322 |
||
323 |
||
324 |
jlong double2long(jdouble f) { |
|
325 |
jlong tmp = (jlong) f; |
|
326 |
if (tmp != high_bit) { |
|
327 |
return tmp; |
|
328 |
} else { |
|
329 |
if (g_isnan(f)) { |
|
330 |
return 0; |
|
331 |
} |
|
332 |
if (f < 0) { |
|
333 |
return high_bit; |
|
334 |
} else { |
|
335 |
return other_bits; |
|
336 |
} |
|
337 |
} |
|
338 |
} |
|
339 |
||
340 |
// least common multiple |
|
341 |
size_t lcm(size_t a, size_t b) { |
|
342 |
size_t cur, div, next; |
|
343 |
||
344 |
cur = MAX2(a, b); |
|
345 |
div = MIN2(a, b); |
|
346 |
||
347 |
assert(div != 0, "lcm requires positive arguments"); |
|
348 |
||
349 |
||
350 |
while ((next = cur % div) != 0) { |
|
351 |
cur = div; div = next; |
|
352 |
} |
|
353 |
||
354 |
||
355 |
julong result = julong(a) * b / div; |
|
356 |
assert(result <= (size_t)max_uintx, "Integer overflow in lcm"); |
|
357 |
||
358 |
return size_t(result); |
|
359 |
} |
|
16670
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
360 |
|
37056 | 361 |
|
362 |
// Test that nth_bit macro and friends behave as |
|
363 |
// expected, even with low-precedence operators. |
|
364 |
||
365 |
STATIC_ASSERT(nth_bit(3) == 0x8); |
|
366 |
STATIC_ASSERT(nth_bit(1|2) == 0x8); |
|
367 |
||
368 |
STATIC_ASSERT(right_n_bits(3) == 0x7); |
|
369 |
STATIC_ASSERT(right_n_bits(1|2) == 0x7); |
|
370 |
||
371 |
STATIC_ASSERT(left_n_bits(3) == (intptr_t) LP64_ONLY(0xE000000000000000) NOT_LP64(0xE0000000)); |
|
372 |
STATIC_ASSERT(left_n_bits(1|2) == (intptr_t) LP64_ONLY(0xE000000000000000) NOT_LP64(0xE0000000)); |
|
373 |
||
374 |
||
16670
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
375 |
#ifndef PRODUCT |
35529 | 376 |
// For unit testing only |
377 |
class GlobalDefinitions { |
|
378 |
public: |
|
379 |
static void test_globals(); |
|
380 |
}; |
|
16670
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
381 |
|
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
382 |
void GlobalDefinitions::test_globals() { |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
383 |
intptr_t page_sizes[] = { os::vm_page_size(), 4096, 8192, 65536, 2*1024*1024 }; |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
384 |
const int num_page_sizes = sizeof(page_sizes) / sizeof(page_sizes[0]); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
385 |
|
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
386 |
for (int i = 0; i < num_page_sizes; i++) { |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
387 |
intptr_t page_size = page_sizes[i]; |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
388 |
|
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
389 |
address a_page = (address)(10*page_size); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
390 |
|
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
391 |
// Check that address within page is returned as is |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
392 |
assert(clamp_address_in_page(a_page, a_page, page_size) == a_page, "incorrect"); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
393 |
assert(clamp_address_in_page(a_page + 128, a_page, page_size) == a_page + 128, "incorrect"); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
394 |
assert(clamp_address_in_page(a_page + page_size - 1, a_page, page_size) == a_page + page_size - 1, "incorrect"); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
395 |
|
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
396 |
// Check that address above page returns start of next page |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
397 |
assert(clamp_address_in_page(a_page + page_size, a_page, page_size) == a_page + page_size, "incorrect"); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
398 |
assert(clamp_address_in_page(a_page + page_size + 1, a_page, page_size) == a_page + page_size, "incorrect"); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
399 |
assert(clamp_address_in_page(a_page + page_size*5 + 1, a_page, page_size) == a_page + page_size, "incorrect"); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
400 |
|
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
401 |
// Check that address below page returns start of page |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
402 |
assert(clamp_address_in_page(a_page - 1, a_page, page_size) == a_page, "incorrect"); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
403 |
assert(clamp_address_in_page(a_page - 2*page_size - 1, a_page, page_size) == a_page, "incorrect"); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
404 |
assert(clamp_address_in_page(a_page - 5*page_size - 1, a_page, page_size) == a_page, "incorrect"); |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
405 |
} |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
406 |
} |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
407 |
|
35529 | 408 |
void GlobalDefinitions_test() { |
409 |
GlobalDefinitions::test_globals(); |
|
410 |
} |
|
411 |
||
16670
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
13969
diff
changeset
|
412 |
#endif // PRODUCT |