< prev index next >

src/hotspot/share/utilities/globalDefinitions.cpp

Print this page

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

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

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

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

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

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

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

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

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

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