annotate src/share/vm/utilities/globalDefinitions.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents f95d63e2154a
children 8a02ca5e5576
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
26 #include "runtime/os.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
27 #include "utilities/globalDefinitions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
28 #include "utilities/top.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
29
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
30 // Basic error support
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
32 // Info for oops within a java object. Defaults are zero so
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
33 // things will break badly if incorrectly initialized.
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
34 int heapOopSize = 0;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
35 int LogBytesPerHeapOop = 0;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
36 int LogBitsPerHeapOop = 0;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
37 int BytesPerHeapOop = 0;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
38 int BitsPerHeapOop = 0;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39
1571
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
40 // Object alignment, in units of HeapWords.
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
41 // Defaults are -1 so things will break badly if incorrectly initialized.
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
42 int MinObjAlignment = -1;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
43 int MinObjAlignmentInBytes = -1;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
44 int MinObjAlignmentInBytesMask = 0;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
45
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
46 int LogMinObjAlignment = -1;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
47 int LogMinObjAlignmentInBytes = -1;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
48
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
49 // Oop encoding heap max
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
50 uint64_t OopEncodingHeapMax = 0;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
51
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 void basic_fatal(const char* msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 fatal(msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // Something to help porters sleep at night
a61af66fc99e Initial load
duke
parents:
diff changeset
57
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
58 void basic_types_init() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
59 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
60 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
61 assert(min_intx == (intx)CONST64(0x8000000000000000), "correct constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
62 assert(max_intx == CONST64(0x7FFFFFFFFFFFFFFF), "correct constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
63 assert(max_uintx == CONST64(0xFFFFFFFFFFFFFFFF), "correct constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
64 assert( 8 == sizeof( intx), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
65 assert( 8 == sizeof( jobject), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
66 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
67 assert(min_intx == (intx)0x80000000, "correct constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
68 assert(max_intx == 0x7FFFFFFF, "correct constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
69 assert(max_uintx == 0xFFFFFFFF, "correct constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
70 assert( 4 == sizeof( intx), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert( 4 == sizeof( jobject), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
73 assert( (~max_juint) == 0, "max_juint has all its bits");
a61af66fc99e Initial load
duke
parents:
diff changeset
74 assert( (~max_uintx) == 0, "max_uintx has all its bits");
a61af66fc99e Initial load
duke
parents:
diff changeset
75 assert( (~max_julong) == 0, "max_julong has all its bits");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 assert( 1 == sizeof( jbyte), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
77 assert( 2 == sizeof( jchar), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
78 assert( 2 == sizeof( jshort), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
79 assert( 4 == sizeof( juint), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
80 assert( 4 == sizeof( jint), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
81 assert( 1 == sizeof( jboolean), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
82 assert( 8 == sizeof( jlong), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
83 assert( 4 == sizeof( jfloat), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
84 assert( 8 == sizeof( jdouble), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
85 assert( 1 == sizeof( u1), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 assert( 2 == sizeof( u2), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 assert( 4 == sizeof( u4), "wrong size for basic type");
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int num_type_chars = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 for (int i = 0; i < 99; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 if (type2char((BasicType)i) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 assert(char2type(type2char((BasicType)i)) == i, "proper inverses");
a61af66fc99e Initial load
duke
parents:
diff changeset
93 num_type_chars++;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 assert(num_type_chars == 11, "must have tested the right number of mappings");
a61af66fc99e Initial load
duke
parents:
diff changeset
97 assert(char2type(0) == T_ILLEGAL, "correct illegality");
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 BasicType vt = (BasicType)i;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 BasicType ft = type2field[vt];
a61af66fc99e Initial load
duke
parents:
diff changeset
103 switch (vt) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // the following types might plausibly show up in memory layouts:
a61af66fc99e Initial load
duke
parents:
diff changeset
105 case T_BOOLEAN:
a61af66fc99e Initial load
duke
parents:
diff changeset
106 case T_BYTE:
a61af66fc99e Initial load
duke
parents:
diff changeset
107 case T_CHAR:
a61af66fc99e Initial load
duke
parents:
diff changeset
108 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
109 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
110 case T_FLOAT:
a61af66fc99e Initial load
duke
parents:
diff changeset
111 case T_DOUBLE:
a61af66fc99e Initial load
duke
parents:
diff changeset
112 case T_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
113 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
114 case T_ADDRESS: // random raw pointer
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
115 case T_METADATA: // metadata pointer
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
116 case T_NARROWOOP: // compressed pointer
0
a61af66fc99e Initial load
duke
parents:
diff changeset
117 case T_CONFLICT: // might as well support a bottom type
a61af66fc99e Initial load
duke
parents:
diff changeset
118 case T_VOID: // padding or other unaddressed word
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // layout type must map to itself
a61af66fc99e Initial load
duke
parents:
diff changeset
120 assert(vt == ft, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
121 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // non-layout type must map to a (different) layout type
a61af66fc99e Initial load
duke
parents:
diff changeset
124 assert(vt != ft, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
125 assert(ft == type2field[ft], "");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // every type must map to same-sized layout type:
a61af66fc99e Initial load
duke
parents:
diff changeset
128 assert(type2size[vt] == type2size[ft], "");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // These are assumed, e.g., when filling HeapWords with juints.
a61af66fc99e Initial load
duke
parents:
diff changeset
132 assert(is_power_of_2(sizeof(juint)), "juint must be power of 2");
a61af66fc99e Initial load
duke
parents:
diff changeset
133 assert(is_power_of_2(HeapWordSize), "HeapWordSize must be power of 2");
a61af66fc99e Initial load
duke
parents:
diff changeset
134 assert((size_t)HeapWordSize >= sizeof(juint),
a61af66fc99e Initial load
duke
parents:
diff changeset
135 "HeapWord should be at least as large as juint");
a61af66fc99e Initial load
duke
parents:
diff changeset
136 assert(sizeof(NULL) == sizeof(char*), "NULL must be same size as pointer");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 if( JavaPriority1_To_OSPriority != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
140 os::java_to_os_priority[1] = JavaPriority1_To_OSPriority;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 if( JavaPriority2_To_OSPriority != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
142 os::java_to_os_priority[2] = JavaPriority2_To_OSPriority;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if( JavaPriority3_To_OSPriority != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
144 os::java_to_os_priority[3] = JavaPriority3_To_OSPriority;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 if( JavaPriority4_To_OSPriority != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
146 os::java_to_os_priority[4] = JavaPriority4_To_OSPriority;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if( JavaPriority5_To_OSPriority != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
148 os::java_to_os_priority[5] = JavaPriority5_To_OSPriority;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 if( JavaPriority6_To_OSPriority != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
150 os::java_to_os_priority[6] = JavaPriority6_To_OSPriority;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 if( JavaPriority7_To_OSPriority != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
152 os::java_to_os_priority[7] = JavaPriority7_To_OSPriority;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 if( JavaPriority8_To_OSPriority != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
154 os::java_to_os_priority[8] = JavaPriority8_To_OSPriority;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 if( JavaPriority9_To_OSPriority != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
156 os::java_to_os_priority[9] = JavaPriority9_To_OSPriority;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if(JavaPriority10_To_OSPriority != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
158 os::java_to_os_priority[10] = JavaPriority10_To_OSPriority;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
159
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
160 // Set the size of basic types here (after argument parsing but before
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
161 // stub generation).
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
162 if (UseCompressedOops) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
163 // Size info for oops within java objects is fixed
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
164 heapOopSize = jintSize;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
165 LogBytesPerHeapOop = LogBytesPerInt;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
166 LogBitsPerHeapOop = LogBitsPerInt;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
167 BytesPerHeapOop = BytesPerInt;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
168 BitsPerHeapOop = BitsPerInt;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
169 } else {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
170 heapOopSize = oopSize;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
171 LogBytesPerHeapOop = LogBytesPerWord;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
172 LogBitsPerHeapOop = LogBitsPerWord;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
173 BytesPerHeapOop = BytesPerWord;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
174 BitsPerHeapOop = BitsPerWord;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
175 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
176 _type2aelembytes[T_OBJECT] = heapOopSize;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
177 _type2aelembytes[T_ARRAY] = heapOopSize;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // Map BasicType to signature character
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
182 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
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // Map BasicType to Java type name
a61af66fc99e Initial load
duke
parents:
diff changeset
185 const char* type2name_tab[T_CONFLICT+1] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 NULL, NULL, NULL, NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
187 "boolean",
a61af66fc99e Initial load
duke
parents:
diff changeset
188 "char",
a61af66fc99e Initial load
duke
parents:
diff changeset
189 "float",
a61af66fc99e Initial load
duke
parents:
diff changeset
190 "double",
a61af66fc99e Initial load
duke
parents:
diff changeset
191 "byte",
a61af66fc99e Initial load
duke
parents:
diff changeset
192 "short",
a61af66fc99e Initial load
duke
parents:
diff changeset
193 "int",
a61af66fc99e Initial load
duke
parents:
diff changeset
194 "long",
a61af66fc99e Initial load
duke
parents:
diff changeset
195 "object",
a61af66fc99e Initial load
duke
parents:
diff changeset
196 "array",
a61af66fc99e Initial load
duke
parents:
diff changeset
197 "void",
a61af66fc99e Initial load
duke
parents:
diff changeset
198 "*address*",
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
199 "*narrowoop*",
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
200 "*metadata*",
0
a61af66fc99e Initial load
duke
parents:
diff changeset
201 "*conflict*"
a61af66fc99e Initial load
duke
parents:
diff changeset
202 };
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 BasicType name2type(const char* name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 for (int i = T_BOOLEAN; i <= T_VOID; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 BasicType t = (BasicType)i;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if (type2name_tab[t] != NULL && 0 == strcmp(type2name_tab[t], name))
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return T_ILLEGAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // Map BasicType to size in words
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
216 int type2size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 0, 1, 1, -1};
0
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 BasicType type2field[T_CONFLICT+1] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 (BasicType)0, // 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
220 (BasicType)0, // 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
221 (BasicType)0, // 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
222 (BasicType)0, // 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
223 T_BOOLEAN, // T_BOOLEAN = 4,
a61af66fc99e Initial load
duke
parents:
diff changeset
224 T_CHAR, // T_CHAR = 5,
a61af66fc99e Initial load
duke
parents:
diff changeset
225 T_FLOAT, // T_FLOAT = 6,
a61af66fc99e Initial load
duke
parents:
diff changeset
226 T_DOUBLE, // T_DOUBLE = 7,
a61af66fc99e Initial load
duke
parents:
diff changeset
227 T_BYTE, // T_BYTE = 8,
a61af66fc99e Initial load
duke
parents:
diff changeset
228 T_SHORT, // T_SHORT = 9,
a61af66fc99e Initial load
duke
parents:
diff changeset
229 T_INT, // T_INT = 10,
a61af66fc99e Initial load
duke
parents:
diff changeset
230 T_LONG, // T_LONG = 11,
a61af66fc99e Initial load
duke
parents:
diff changeset
231 T_OBJECT, // T_OBJECT = 12,
a61af66fc99e Initial load
duke
parents:
diff changeset
232 T_OBJECT, // T_ARRAY = 13,
a61af66fc99e Initial load
duke
parents:
diff changeset
233 T_VOID, // T_VOID = 14,
a61af66fc99e Initial load
duke
parents:
diff changeset
234 T_ADDRESS, // T_ADDRESS = 15,
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
235 T_NARROWOOP, // T_NARROWOOP= 16,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
236 T_METADATA, // T_METADATA = 17,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
237 T_CONFLICT // T_CONFLICT = 18,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
238 };
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 BasicType type2wfield[T_CONFLICT+1] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 (BasicType)0, // 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
243 (BasicType)0, // 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
244 (BasicType)0, // 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
245 (BasicType)0, // 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
246 T_INT, // T_BOOLEAN = 4,
a61af66fc99e Initial load
duke
parents:
diff changeset
247 T_INT, // T_CHAR = 5,
a61af66fc99e Initial load
duke
parents:
diff changeset
248 T_FLOAT, // T_FLOAT = 6,
a61af66fc99e Initial load
duke
parents:
diff changeset
249 T_DOUBLE, // T_DOUBLE = 7,
a61af66fc99e Initial load
duke
parents:
diff changeset
250 T_INT, // T_BYTE = 8,
a61af66fc99e Initial load
duke
parents:
diff changeset
251 T_INT, // T_SHORT = 9,
a61af66fc99e Initial load
duke
parents:
diff changeset
252 T_INT, // T_INT = 10,
a61af66fc99e Initial load
duke
parents:
diff changeset
253 T_LONG, // T_LONG = 11,
a61af66fc99e Initial load
duke
parents:
diff changeset
254 T_OBJECT, // T_OBJECT = 12,
a61af66fc99e Initial load
duke
parents:
diff changeset
255 T_OBJECT, // T_ARRAY = 13,
a61af66fc99e Initial load
duke
parents:
diff changeset
256 T_VOID, // T_VOID = 14,
a61af66fc99e Initial load
duke
parents:
diff changeset
257 T_ADDRESS, // T_ADDRESS = 15,
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
258 T_NARROWOOP, // T_NARROWOOP = 16,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
259 T_METADATA, // T_METADATA = 17,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
260 T_CONFLICT // T_CONFLICT = 18,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
261 };
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263
29
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
264 int _type2aelembytes[T_CONFLICT+1] = {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
265 0, // 0
a61af66fc99e Initial load
duke
parents:
diff changeset
266 0, // 1
a61af66fc99e Initial load
duke
parents:
diff changeset
267 0, // 2
a61af66fc99e Initial load
duke
parents:
diff changeset
268 0, // 3
a61af66fc99e Initial load
duke
parents:
diff changeset
269 T_BOOLEAN_aelem_bytes, // T_BOOLEAN = 4,
a61af66fc99e Initial load
duke
parents:
diff changeset
270 T_CHAR_aelem_bytes, // T_CHAR = 5,
a61af66fc99e Initial load
duke
parents:
diff changeset
271 T_FLOAT_aelem_bytes, // T_FLOAT = 6,
a61af66fc99e Initial load
duke
parents:
diff changeset
272 T_DOUBLE_aelem_bytes, // T_DOUBLE = 7,
a61af66fc99e Initial load
duke
parents:
diff changeset
273 T_BYTE_aelem_bytes, // T_BYTE = 8,
a61af66fc99e Initial load
duke
parents:
diff changeset
274 T_SHORT_aelem_bytes, // T_SHORT = 9,
a61af66fc99e Initial load
duke
parents:
diff changeset
275 T_INT_aelem_bytes, // T_INT = 10,
a61af66fc99e Initial load
duke
parents:
diff changeset
276 T_LONG_aelem_bytes, // T_LONG = 11,
a61af66fc99e Initial load
duke
parents:
diff changeset
277 T_OBJECT_aelem_bytes, // T_OBJECT = 12,
a61af66fc99e Initial load
duke
parents:
diff changeset
278 T_ARRAY_aelem_bytes, // T_ARRAY = 13,
a61af66fc99e Initial load
duke
parents:
diff changeset
279 0, // T_VOID = 14,
29
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
280 T_OBJECT_aelem_bytes, // T_ADDRESS = 15,
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
281 T_NARROWOOP_aelem_bytes,// T_NARROWOOP= 16,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
282 T_OBJECT_aelem_bytes, // T_METADATA = 17,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
283 0 // T_CONFLICT = 18,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
284 };
a61af66fc99e Initial load
duke
parents:
diff changeset
285
29
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
286 #ifdef ASSERT
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
287 int type2aelembytes(BasicType t, bool allow_address) {
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
288 assert(allow_address || t != T_ADDRESS, " ");
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
289 return _type2aelembytes[t];
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
290 }
d5fc211aea19 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 0
diff changeset
291 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // Support for 64-bit integer arithmetic
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // The following code is mostly taken from JVM typedefs_md.h and system_md.c
a61af66fc99e Initial load
duke
parents:
diff changeset
296
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 29
diff changeset
297 static const jlong high_bit = (jlong)1 << (jlong)63;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
298 static const jlong other_bits = ~high_bit;
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 jlong float2long(jfloat f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 jlong tmp = (jlong) f;
a61af66fc99e Initial load
duke
parents:
diff changeset
302 if (tmp != high_bit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 return tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 if (g_isnan((jdouble)f)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308 if (f < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 return high_bit;
a61af66fc99e Initial load
duke
parents:
diff changeset
310 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
311 return other_bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 jlong double2long(jdouble f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 jlong tmp = (jlong) f;
a61af66fc99e Initial load
duke
parents:
diff changeset
319 if (tmp != high_bit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
320 return tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
321 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
322 if (g_isnan(f)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
325 if (f < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 return high_bit;
a61af66fc99e Initial load
duke
parents:
diff changeset
327 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
328 return other_bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
329 }
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // least common multiple
a61af66fc99e Initial load
duke
parents:
diff changeset
334 size_t lcm(size_t a, size_t b) {
a61af66fc99e Initial load
duke
parents:
diff changeset
335 size_t cur, div, next;
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337 cur = MAX2(a, b);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 div = MIN2(a, b);
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 assert(div != 0, "lcm requires positive arguments");
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 while ((next = cur % div) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 cur = div; div = next;
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348 julong result = julong(a) * b / div;
a61af66fc99e Initial load
duke
parents:
diff changeset
349 assert(result <= (size_t)max_uintx, "Integer overflow in lcm");
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 return size_t(result);
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }