< prev index next >

src/hotspot/share/utilities/globalDefinitions.cpp

Print this page

 93   assert( 1 == sizeof( jboolean),  "wrong size for basic type");
 94   assert( 8 == sizeof( jlong),     "wrong size for basic type");
 95   assert( 4 == sizeof( jfloat),    "wrong size for basic type");
 96   assert( 8 == sizeof( jdouble),   "wrong size for basic type");
 97   assert( 1 == sizeof( u1),        "wrong size for basic type");
 98   assert( 2 == sizeof( u2),        "wrong size for basic type");
 99   assert( 4 == sizeof( u4),        "wrong size for basic type");
100   assert(wordSize == BytesPerWord, "should be the same since they're used interchangeably");
101   assert(wordSize == HeapWordSize, "should be the same since they're also used interchangeably");
102 
103   assert(signature_constants_sane(), "");
104 
105   int num_type_chars = 0;
106   for (int i = 0; i < 99; i++) {
107     if (type2char((BasicType)i) != 0) {
108       assert(char2type(type2char((BasicType)i)) == i, "proper inverses");
109       assert(Signature::basic_type(type2char((BasicType)i)) == i, "proper inverses");
110       num_type_chars++;
111     }
112   }
113   assert(num_type_chars == 11, "must have tested the right number of mappings");
114   assert(char2type(0) == T_ILLEGAL, "correct illegality");
115 
116   {
117     for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
118       BasicType vt = (BasicType)i;
119       BasicType ft = type2field[vt];
120       switch (vt) {
121       // the following types might plausibly show up in memory layouts:
122       case T_BOOLEAN:
123       case T_BYTE:
124       case T_CHAR:
125       case T_SHORT:
126       case T_INT:
127       case T_FLOAT:
128       case T_DOUBLE:
129       case T_LONG:
130       case T_OBJECT:

131       case T_ADDRESS:     // random raw pointer
132       case T_METADATA:    // metadata pointer
133       case T_NARROWOOP:   // compressed pointer
134       case T_NARROWKLASS: // compressed klass pointer
135       case T_CONFLICT:    // might as well support a bottom type
136       case T_VOID:        // padding or other unaddressed word
137         // layout type must map to itself
138         assert(vt == ft, "");
139         break;
140       default:
141         // non-layout type must map to a (different) layout type
142         assert(vt != ft, "");
143         assert(ft == type2field[ft], "");
144       }
145       // every type must map to same-sized layout type:
146       assert(type2size[vt] == type2size[ft], "");
147     }
148   }
149   // These are assumed, e.g., when filling HeapWords with juints.
150   assert(is_power_of_2(sizeof(juint)), "juint must be power of 2");

176     os::java_to_os_priority[10] = JavaPriority10_To_OSPriority;
177 
178   // Set the size of basic types here (after argument parsing but before
179   // stub generation).
180   if (UseCompressedOops) {
181     // Size info for oops within java objects is fixed
182     heapOopSize        = jintSize;
183     LogBytesPerHeapOop = LogBytesPerInt;
184     LogBitsPerHeapOop  = LogBitsPerInt;
185     BytesPerHeapOop    = BytesPerInt;
186     BitsPerHeapOop     = BitsPerInt;
187   } else {
188     heapOopSize        = oopSize;
189     LogBytesPerHeapOop = LogBytesPerWord;
190     LogBitsPerHeapOop  = LogBitsPerWord;
191     BytesPerHeapOop    = BytesPerWord;
192     BitsPerHeapOop     = BitsPerWord;
193   }
194   _type2aelembytes[T_OBJECT] = heapOopSize;
195   _type2aelembytes[T_ARRAY]  = heapOopSize;

196 }
197 
198 
199 // Map BasicType to signature character
200 char type2char_tab[T_CONFLICT+1] = {
201   0, 0, 0, 0,
202   JVM_SIGNATURE_BOOLEAN, JVM_SIGNATURE_CHAR,
203   JVM_SIGNATURE_FLOAT,   JVM_SIGNATURE_DOUBLE,
204   JVM_SIGNATURE_BYTE,    JVM_SIGNATURE_SHORT,
205   JVM_SIGNATURE_INT,     JVM_SIGNATURE_LONG,
206   JVM_SIGNATURE_CLASS,   JVM_SIGNATURE_ARRAY,
207   JVM_SIGNATURE_VOID,    0,
208   0, 0, 0, 0
209 };
210 
211 // Map BasicType to Java type name
212 const char* type2name_tab[T_CONFLICT+1] = {
213   NULL, NULL, NULL, NULL,
214   "boolean",
215   "char",
216   "float",
217   "double",
218   "byte",
219   "short",
220   "int",
221   "long",
222   "object",
223   "array",

224   "void",
225   "*address*",
226   "*narrowoop*",
227   "*metadata*",
228   "*narrowklass*",
229   "*conflict*"
230 };
231 
232 
233 BasicType name2type(const char* name) {
234   for (int i = T_BOOLEAN; i <= T_VOID; i++) {
235     BasicType t = (BasicType)i;
236     if (type2name_tab[t] != NULL && 0 == strcmp(type2name_tab[t], name))
237       return t;
238   }
239   return T_ILLEGAL;
240 }
241 
242 // Map BasicType to size in words
243 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};
244 
245 BasicType type2field[T_CONFLICT+1] = {
246   (BasicType)0,            // 0,
247   (BasicType)0,            // 1,
248   (BasicType)0,            // 2,
249   (BasicType)0,            // 3,
250   T_BOOLEAN,               // T_BOOLEAN  =  4,
251   T_CHAR,                  // T_CHAR     =  5,
252   T_FLOAT,                 // T_FLOAT    =  6,
253   T_DOUBLE,                // T_DOUBLE   =  7,
254   T_BYTE,                  // T_BYTE     =  8,
255   T_SHORT,                 // T_SHORT    =  9,
256   T_INT,                   // T_INT      = 10,
257   T_LONG,                  // T_LONG     = 11,
258   T_OBJECT,                // T_OBJECT   = 12,
259   T_OBJECT,                // T_ARRAY    = 13,
260   T_VOID,                  // T_VOID     = 14,
261   T_ADDRESS,               // T_ADDRESS  = 15,
262   T_NARROWOOP,             // T_NARROWOOP= 16,
263   T_METADATA,              // T_METADATA = 17,
264   T_NARROWKLASS,           // T_NARROWKLASS = 18,
265   T_CONFLICT               // T_CONFLICT = 19,

266 };
267 
268 
269 BasicType type2wfield[T_CONFLICT+1] = {
270   (BasicType)0,            // 0,
271   (BasicType)0,            // 1,
272   (BasicType)0,            // 2,
273   (BasicType)0,            // 3,
274   T_INT,     // T_BOOLEAN  =  4,
275   T_INT,     // T_CHAR     =  5,
276   T_FLOAT,   // T_FLOAT    =  6,
277   T_DOUBLE,  // T_DOUBLE   =  7,
278   T_INT,     // T_BYTE     =  8,
279   T_INT,     // T_SHORT    =  9,
280   T_INT,     // T_INT      = 10,
281   T_LONG,    // T_LONG     = 11,
282   T_OBJECT,  // T_OBJECT   = 12,
283   T_OBJECT,  // T_ARRAY    = 13,
284   T_VOID,    // T_VOID     = 14,
285   T_ADDRESS, // T_ADDRESS  = 15,
286   T_NARROWOOP, // T_NARROWOOP  = 16,
287   T_METADATA,  // T_METADATA   = 17,
288   T_NARROWKLASS, // T_NARROWKLASS  = 18,
289   T_CONFLICT // T_CONFLICT = 19,

290 };
291 
292 
293 int _type2aelembytes[T_CONFLICT+1] = {
294   0,                         // 0
295   0,                         // 1
296   0,                         // 2
297   0,                         // 3
298   T_BOOLEAN_aelem_bytes,     // T_BOOLEAN  =  4,
299   T_CHAR_aelem_bytes,        // T_CHAR     =  5,
300   T_FLOAT_aelem_bytes,       // T_FLOAT    =  6,
301   T_DOUBLE_aelem_bytes,      // T_DOUBLE   =  7,
302   T_BYTE_aelem_bytes,        // T_BYTE     =  8,
303   T_SHORT_aelem_bytes,       // T_SHORT    =  9,
304   T_INT_aelem_bytes,         // T_INT      = 10,
305   T_LONG_aelem_bytes,        // T_LONG     = 11,
306   T_OBJECT_aelem_bytes,      // T_OBJECT   = 12,
307   T_ARRAY_aelem_bytes,       // T_ARRAY    = 13,
308   0,                         // T_VOID     = 14,
309   T_OBJECT_aelem_bytes,      // T_ADDRESS  = 15,
310   T_NARROWOOP_aelem_bytes,   // T_NARROWOOP= 16,
311   T_OBJECT_aelem_bytes,      // T_METADATA = 17,
312   T_NARROWKLASS_aelem_bytes, // T_NARROWKLASS= 18,
313   0                          // T_CONFLICT = 19,

314 };
315 
316 #ifdef ASSERT
317 int type2aelembytes(BasicType t, bool allow_address) {
318   assert(allow_address || t != T_ADDRESS, " ");
319   return _type2aelembytes[t];
320 }
321 #endif
322 
323 // Support for 64-bit integer arithmetic
324 
325 // The following code is mostly taken from JVM typedefs_md.h and system_md.c
326 
327 static const jlong high_bit   = (jlong)1 << (jlong)63;
328 static const jlong other_bits = ~high_bit;
329 
330 jlong float2long(jfloat f) {
331   jlong tmp = (jlong) f;
332   if (tmp != high_bit) {
333     return tmp;

 93   assert( 1 == sizeof( jboolean),  "wrong size for basic type");
 94   assert( 8 == sizeof( jlong),     "wrong size for basic type");
 95   assert( 4 == sizeof( jfloat),    "wrong size for basic type");
 96   assert( 8 == sizeof( jdouble),   "wrong size for basic type");
 97   assert( 1 == sizeof( u1),        "wrong size for basic type");
 98   assert( 2 == sizeof( u2),        "wrong size for basic type");
 99   assert( 4 == sizeof( u4),        "wrong size for basic type");
100   assert(wordSize == BytesPerWord, "should be the same since they're used interchangeably");
101   assert(wordSize == HeapWordSize, "should be the same since they're also used interchangeably");
102 
103   assert(signature_constants_sane(), "");
104 
105   int num_type_chars = 0;
106   for (int i = 0; i < 99; i++) {
107     if (type2char((BasicType)i) != 0) {
108       assert(char2type(type2char((BasicType)i)) == i, "proper inverses");
109       assert(Signature::basic_type(type2char((BasicType)i)) == i, "proper inverses");
110       num_type_chars++;
111     }
112   }
113   assert(num_type_chars == 12, "must have tested the right number of mappings");
114   assert(char2type(0) == T_ILLEGAL, "correct illegality");
115 
116   {
117     for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
118       BasicType vt = (BasicType)i;
119       BasicType ft = type2field[vt];
120       switch (vt) {
121       // the following types might plausibly show up in memory layouts:
122       case T_BOOLEAN:
123       case T_BYTE:
124       case T_CHAR:
125       case T_SHORT:
126       case T_INT:
127       case T_FLOAT:
128       case T_DOUBLE:
129       case T_LONG:
130       case T_OBJECT:
131       case T_INLINE_TYPE:
132       case T_ADDRESS:     // random raw pointer
133       case T_METADATA:    // metadata pointer
134       case T_NARROWOOP:   // compressed pointer
135       case T_NARROWKLASS: // compressed klass pointer
136       case T_CONFLICT:    // might as well support a bottom type
137       case T_VOID:        // padding or other unaddressed word
138         // layout type must map to itself
139         assert(vt == ft, "");
140         break;
141       default:
142         // non-layout type must map to a (different) layout type
143         assert(vt != ft, "");
144         assert(ft == type2field[ft], "");
145       }
146       // every type must map to same-sized layout type:
147       assert(type2size[vt] == type2size[ft], "");
148     }
149   }
150   // These are assumed, e.g., when filling HeapWords with juints.
151   assert(is_power_of_2(sizeof(juint)), "juint must be power of 2");

177     os::java_to_os_priority[10] = JavaPriority10_To_OSPriority;
178 
179   // Set the size of basic types here (after argument parsing but before
180   // stub generation).
181   if (UseCompressedOops) {
182     // Size info for oops within java objects is fixed
183     heapOopSize        = jintSize;
184     LogBytesPerHeapOop = LogBytesPerInt;
185     LogBitsPerHeapOop  = LogBitsPerInt;
186     BytesPerHeapOop    = BytesPerInt;
187     BitsPerHeapOop     = BitsPerInt;
188   } else {
189     heapOopSize        = oopSize;
190     LogBytesPerHeapOop = LogBytesPerWord;
191     LogBitsPerHeapOop  = LogBitsPerWord;
192     BytesPerHeapOop    = BytesPerWord;
193     BitsPerHeapOop     = BitsPerWord;
194   }
195   _type2aelembytes[T_OBJECT] = heapOopSize;
196   _type2aelembytes[T_ARRAY]  = heapOopSize;
197   _type2aelembytes[T_INLINE_TYPE]  = heapOopSize;
198 }
199 
200 
201 // Map BasicType to signature character
202 char type2char_tab[T_CONFLICT+1] = {
203   0, 0, 0, 0,
204   JVM_SIGNATURE_BOOLEAN, JVM_SIGNATURE_CHAR,
205   JVM_SIGNATURE_FLOAT,   JVM_SIGNATURE_DOUBLE,
206   JVM_SIGNATURE_BYTE,    JVM_SIGNATURE_SHORT,
207   JVM_SIGNATURE_INT,     JVM_SIGNATURE_LONG,
208   JVM_SIGNATURE_CLASS,   JVM_SIGNATURE_ARRAY,
209   JVM_SIGNATURE_INLINE_TYPE, JVM_SIGNATURE_VOID,
210   0, 0, 0, 0, 0
211 };
212 
213 // Map BasicType to Java type name
214 const char* type2name_tab[T_CONFLICT+1] = {
215   NULL, NULL, NULL, NULL,
216   "boolean",
217   "char",
218   "float",
219   "double",
220   "byte",
221   "short",
222   "int",
223   "long",
224   "object",
225   "array",
226   "inline_type",
227   "void",
228   "*address*",
229   "*narrowoop*",
230   "*metadata*",
231   "*narrowklass*",
232   "*conflict*"
233 };
234 
235 
236 BasicType name2type(const char* name) {
237   for (int i = T_BOOLEAN; i <= T_VOID; i++) {
238     BasicType t = (BasicType)i;
239     if (type2name_tab[t] != NULL && 0 == strcmp(type2name_tab[t], name))
240       return t;
241   }
242   return T_ILLEGAL;
243 }
244 
245 // Map BasicType to size in words
246 int type2size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 0, 1, 1, 1, 1, -1};
247 
248 BasicType type2field[T_CONFLICT+1] = {
249   (BasicType)0,            // 0,
250   (BasicType)0,            // 1,
251   (BasicType)0,            // 2,
252   (BasicType)0,            // 3,
253   T_BOOLEAN,               // T_BOOLEAN  =  4,
254   T_CHAR,                  // T_CHAR     =  5,
255   T_FLOAT,                 // T_FLOAT    =  6,
256   T_DOUBLE,                // T_DOUBLE   =  7,
257   T_BYTE,                  // T_BYTE     =  8,
258   T_SHORT,                 // T_SHORT    =  9,
259   T_INT,                   // T_INT      = 10,
260   T_LONG,                  // T_LONG     = 11,
261   T_OBJECT,                // T_OBJECT   = 12,
262   T_OBJECT,                // T_ARRAY    = 13,
263   T_INLINE_TYPE,           // T_INLINE_TYPE = 14,
264   T_VOID,                  // T_VOID     = 15,
265   T_ADDRESS,               // T_ADDRESS  = 16,
266   T_NARROWOOP,             // T_NARROWOOP= 17,
267   T_METADATA,              // T_METADATA = 18,
268   T_NARROWKLASS,           // T_NARROWKLASS = 19,
269   T_CONFLICT               // T_CONFLICT = 20
270 };
271 
272 
273 BasicType type2wfield[T_CONFLICT+1] = {
274   (BasicType)0,            // 0,
275   (BasicType)0,            // 1,
276   (BasicType)0,            // 2,
277   (BasicType)0,            // 3,
278   T_INT,     // T_BOOLEAN  =  4,
279   T_INT,     // T_CHAR     =  5,
280   T_FLOAT,   // T_FLOAT    =  6,
281   T_DOUBLE,  // T_DOUBLE   =  7,
282   T_INT,     // T_BYTE     =  8,
283   T_INT,     // T_SHORT    =  9,
284   T_INT,     // T_INT      = 10,
285   T_LONG,    // T_LONG     = 11,
286   T_OBJECT,  // T_OBJECT   = 12,
287   T_OBJECT,  // T_ARRAY    = 13,
288   T_OBJECT,  // T_INLINE_TYPE = 14,
289   T_VOID,    // T_VOID     = 15,
290   T_ADDRESS, // T_ADDRESS  = 16,
291   T_NARROWOOP, // T_NARROWOOP  = 17,
292   T_METADATA,  // T_METADATA   = 18,
293   T_NARROWKLASS, // T_NARROWKLASS  = 19,
294   T_CONFLICT // T_CONFLICT = 20
295 };
296 
297 
298 int _type2aelembytes[T_CONFLICT+1] = {
299   0,                         // 0
300   0,                         // 1
301   0,                         // 2
302   0,                         // 3
303   T_BOOLEAN_aelem_bytes,     // T_BOOLEAN  =  4,
304   T_CHAR_aelem_bytes,        // T_CHAR     =  5,
305   T_FLOAT_aelem_bytes,       // T_FLOAT    =  6,
306   T_DOUBLE_aelem_bytes,      // T_DOUBLE   =  7,
307   T_BYTE_aelem_bytes,        // T_BYTE     =  8,
308   T_SHORT_aelem_bytes,       // T_SHORT    =  9,
309   T_INT_aelem_bytes,         // T_INT      = 10,
310   T_LONG_aelem_bytes,        // T_LONG     = 11,
311   T_OBJECT_aelem_bytes,      // T_OBJECT   = 12,
312   T_ARRAY_aelem_bytes,       // T_ARRAY    = 13,
313   T_INLINE_TYPE_aelem_bytes,   // T_INLINE_TYPE = 14,
314   0,                         // T_VOID     = 15,
315   T_OBJECT_aelem_bytes,      // T_ADDRESS  = 16,
316   T_NARROWOOP_aelem_bytes,   // T_NARROWOOP= 17,
317   T_OBJECT_aelem_bytes,      // T_METADATA = 18,
318   T_NARROWKLASS_aelem_bytes, // T_NARROWKLASS= 19,
319   0                          // T_CONFLICT = 20
320 };
321 
322 #ifdef ASSERT
323 int type2aelembytes(BasicType t, bool allow_address) {
324   assert(allow_address || t != T_ADDRESS, " ");
325   return _type2aelembytes[t];
326 }
327 #endif
328 
329 // Support for 64-bit integer arithmetic
330 
331 // The following code is mostly taken from JVM typedefs_md.h and system_md.c
332 
333 static const jlong high_bit   = (jlong)1 << (jlong)63;
334 static const jlong other_bits = ~high_bit;
335 
336 jlong float2long(jfloat f) {
337   jlong tmp = (jlong) f;
338   if (tmp != high_bit) {
339     return tmp;
< prev index next >