< prev index next >

src/hotspot/share/utilities/globalDefinitions.cpp

Print this page




  77   assert( 2 == sizeof( jshort),    "wrong size for basic type");
  78   assert( 4 == sizeof( juint),     "wrong size for basic type");
  79   assert( 4 == sizeof( jint),      "wrong size for basic type");
  80   assert( 1 == sizeof( jboolean),  "wrong size for basic type");
  81   assert( 8 == sizeof( jlong),     "wrong size for basic type");
  82   assert( 4 == sizeof( jfloat),    "wrong size for basic type");
  83   assert( 8 == sizeof( jdouble),   "wrong size for basic type");
  84   assert( 1 == sizeof( u1),        "wrong size for basic type");
  85   assert( 2 == sizeof( u2),        "wrong size for basic type");
  86   assert( 4 == sizeof( u4),        "wrong size for basic type");
  87   assert(wordSize == BytesPerWord, "should be the same since they're used interchangeably");
  88   assert(wordSize == HeapWordSize, "should be the same since they're also used interchangeably");
  89 
  90   int num_type_chars = 0;
  91   for (int i = 0; i < 99; i++) {
  92     if (type2char((BasicType)i) != 0) {
  93       assert(char2type(type2char((BasicType)i)) == i, "proper inverses");
  94       num_type_chars++;
  95     }
  96   }
  97   assert(num_type_chars == 12, "must have tested the right number of mappings");
  98   assert(char2type(0) == T_ILLEGAL, "correct illegality");
  99 
 100   {
 101     for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
 102       BasicType vt = (BasicType)i;
 103       BasicType ft = type2field[vt];
 104       switch (vt) {
 105       // the following types might plausibly show up in memory layouts:
 106       case T_BOOLEAN:
 107       case T_BYTE:
 108       case T_CHAR:
 109       case T_SHORT:
 110       case T_INT:
 111       case T_FLOAT:
 112       case T_DOUBLE:
 113       case T_LONG:
 114       case T_OBJECT:
 115       case T_VALUETYPE:
 116       case T_ADDRESS:     // random raw pointer
 117       case T_METADATA:    // metadata pointer


 162     os::java_to_os_priority[10] = JavaPriority10_To_OSPriority;
 163 
 164   // Set the size of basic types here (after argument parsing but before
 165   // stub generation).
 166   if (UseCompressedOops) {
 167     // Size info for oops within java objects is fixed
 168     heapOopSize        = jintSize;
 169     LogBytesPerHeapOop = LogBytesPerInt;
 170     LogBitsPerHeapOop  = LogBitsPerInt;
 171     BytesPerHeapOop    = BytesPerInt;
 172     BitsPerHeapOop     = BitsPerInt;
 173   } else {
 174     heapOopSize        = oopSize;
 175     LogBytesPerHeapOop = LogBytesPerWord;
 176     LogBitsPerHeapOop  = LogBitsPerWord;
 177     BytesPerHeapOop    = BytesPerWord;
 178     BitsPerHeapOop     = BitsPerWord;
 179   }
 180   _type2aelembytes[T_OBJECT] = heapOopSize;
 181   _type2aelembytes[T_ARRAY]  = heapOopSize;
 182   _type2aelembytes[T_VALUETYPE] = heapOopSize;
 183 }
 184 
 185 
 186 // Map BasicType to signature character
 187 char type2char_tab[T_CONFLICT+1]={ 0, 0, 0, 0, 'Z', 'C', 'F', 'D', 'B', 'S', 'I', 'J', 'L', '[', 'Q', 'V', 0, 0, 0, 0, 0, 0};
 188 
 189 // Map BasicType to Java type name
 190 const char* type2name_tab[T_CONFLICT+1] = {
 191   NULL, NULL, NULL, NULL,
 192   "boolean",
 193   "char",
 194   "float",
 195   "double",
 196   "byte",
 197   "short",
 198   "int",
 199   "long",
 200   "object",
 201   "array",
 202   "valuetype",
 203   "void",
 204   "*address*",
 205   "*narrowoop*",
 206   "*metadata*",
 207   "*narrowklass*",
 208   "valuetypeptr",
 209   "*conflict*"
 210 };
 211 
 212 
 213 BasicType name2type(const char* name) {
 214   for (int i = T_BOOLEAN; i <= T_VOID; i++) {
 215     BasicType t = (BasicType)i;
 216     if (type2name_tab[t] != NULL && 0 == strcmp(type2name_tab[t], name))
 217       return t;
 218   }
 219   return T_ILLEGAL;
 220 }
 221 
 222 // Map BasicType to size in words
 223 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, -1};
 224 
 225 BasicType type2field[T_CONFLICT+1] = {
 226   (BasicType)0,            // 0,
 227   (BasicType)0,            // 1,
 228   (BasicType)0,            // 2,
 229   (BasicType)0,            // 3,
 230   T_BOOLEAN,               // T_BOOLEAN  =  4,
 231   T_CHAR,                  // T_CHAR     =  5,
 232   T_FLOAT,                 // T_FLOAT    =  6,
 233   T_DOUBLE,                // T_DOUBLE   =  7,
 234   T_BYTE,                  // T_BYTE     =  8,
 235   T_SHORT,                 // T_SHORT    =  9,
 236   T_INT,                   // T_INT      = 10,
 237   T_LONG,                  // T_LONG     = 11,
 238   T_OBJECT,                // T_OBJECT   = 12,
 239   T_OBJECT,                // T_ARRAY    = 13,
 240   T_VALUETYPE,             // T_VALUETYPE = 14
 241   T_VOID,                  // T_VOID     = 15,
 242   T_ADDRESS,               // T_ADDRESS  = 16,
 243   T_NARROWOOP,             // T_NARROWOOP= 17,
 244   T_METADATA,              // T_METADATA = 18,
 245   T_NARROWKLASS,           // T_NARROWKLASS = 19,
 246   T_VALUETYPEPTR,          // T_VALUETYPEPTR = 20,
 247   T_CONFLICT               // T_CONFLICT = 21,
 248 };
 249 
 250 
 251 BasicType type2wfield[T_CONFLICT+1] = {
 252   (BasicType)0,            // 0,
 253   (BasicType)0,            // 1,
 254   (BasicType)0,            // 2,
 255   (BasicType)0,            // 3,
 256   T_INT,     // T_BOOLEAN  =  4,
 257   T_INT,     // T_CHAR     =  5,
 258   T_FLOAT,   // T_FLOAT    =  6,
 259   T_DOUBLE,  // T_DOUBLE   =  7,
 260   T_INT,     // T_BYTE     =  8,
 261   T_INT,     // T_SHORT    =  9,
 262   T_INT,     // T_INT      = 10,
 263   T_LONG,    // T_LONG     = 11,
 264   T_OBJECT,  // T_OBJECT   = 12,
 265   T_OBJECT,  // T_ARRAY    = 13,
 266   T_VALUETYPE, // T_VALUETYPE = 14
 267   T_VOID,    // T_VOID     = 15,
 268   T_ADDRESS, // T_ADDRESS  = 16,
 269   T_NARROWOOP, // T_NARROWOOP  = 17,
 270   T_METADATA,  // T_METADATA   = 18,
 271   T_NARROWKLASS, // T_NARROWKLASS  = 19,
 272   T_VALUETYPEPTR,// T_VALUETYPEPTR = 20,
 273   T_CONFLICT // T_CONFLICT = 21,
 274 };
 275 
 276 
 277 int _type2aelembytes[T_CONFLICT+1] = {
 278   0,                         // 0
 279   0,                         // 1
 280   0,                         // 2
 281   0,                         // 3
 282   T_BOOLEAN_aelem_bytes,     // T_BOOLEAN  =  4,
 283   T_CHAR_aelem_bytes,        // T_CHAR     =  5,
 284   T_FLOAT_aelem_bytes,       // T_FLOAT    =  6,
 285   T_DOUBLE_aelem_bytes,      // T_DOUBLE   =  7,
 286   T_BYTE_aelem_bytes,        // T_BYTE     =  8,
 287   T_SHORT_aelem_bytes,       // T_SHORT    =  9,
 288   T_INT_aelem_bytes,         // T_INT      = 10,
 289   T_LONG_aelem_bytes,        // T_LONG     = 11,
 290   T_OBJECT_aelem_bytes,      // T_OBJECT   = 12,
 291   T_ARRAY_aelem_bytes,       // T_ARRAY    = 13,
 292   T_VALUETYPE_aelem_bytes,   // T_VALUETYPE = 14
 293   0,                         // T_VOID     = 15,
 294   T_OBJECT_aelem_bytes,      // T_ADDRESS  = 16,
 295   T_NARROWOOP_aelem_bytes,   // T_NARROWOOP= 17,
 296   T_OBJECT_aelem_bytes,      // T_METADATA = 18,
 297   T_NARROWKLASS_aelem_bytes, // T_NARROWKLASS= 19,
 298   T_VALUETYPEPTR_aelem_bytes,// T_VALUETYPEPTR = 20
 299   0                          // T_CONFLICT = 21,
 300 };
 301 
 302 #ifdef ASSERT
 303 int type2aelembytes(BasicType t, bool allow_address) {
 304   assert(allow_address || t != T_ADDRESS, " ");
 305   return _type2aelembytes[t];
 306 }
 307 #endif
 308 
 309 // Support for 64-bit integer arithmetic
 310 
 311 // The following code is mostly taken from JVM typedefs_md.h and system_md.c
 312 




  77   assert( 2 == sizeof( jshort),    "wrong size for basic type");
  78   assert( 4 == sizeof( juint),     "wrong size for basic type");
  79   assert( 4 == sizeof( jint),      "wrong size for basic type");
  80   assert( 1 == sizeof( jboolean),  "wrong size for basic type");
  81   assert( 8 == sizeof( jlong),     "wrong size for basic type");
  82   assert( 4 == sizeof( jfloat),    "wrong size for basic type");
  83   assert( 8 == sizeof( jdouble),   "wrong size for basic type");
  84   assert( 1 == sizeof( u1),        "wrong size for basic type");
  85   assert( 2 == sizeof( u2),        "wrong size for basic type");
  86   assert( 4 == sizeof( u4),        "wrong size for basic type");
  87   assert(wordSize == BytesPerWord, "should be the same since they're used interchangeably");
  88   assert(wordSize == HeapWordSize, "should be the same since they're also used interchangeably");
  89 
  90   int num_type_chars = 0;
  91   for (int i = 0; i < 99; i++) {
  92     if (type2char((BasicType)i) != 0) {
  93       assert(char2type(type2char((BasicType)i)) == i, "proper inverses");
  94       num_type_chars++;
  95     }
  96   }
  97   assert(num_type_chars == 11, "must have tested the right number of mappings");
  98   assert(char2type(0) == T_ILLEGAL, "correct illegality");
  99 
 100   {
 101     for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
 102       BasicType vt = (BasicType)i;
 103       BasicType ft = type2field[vt];
 104       switch (vt) {
 105       // the following types might plausibly show up in memory layouts:
 106       case T_BOOLEAN:
 107       case T_BYTE:
 108       case T_CHAR:
 109       case T_SHORT:
 110       case T_INT:
 111       case T_FLOAT:
 112       case T_DOUBLE:
 113       case T_LONG:
 114       case T_OBJECT:
 115       case T_VALUETYPE:
 116       case T_ADDRESS:     // random raw pointer
 117       case T_METADATA:    // metadata pointer


 162     os::java_to_os_priority[10] = JavaPriority10_To_OSPriority;
 163 
 164   // Set the size of basic types here (after argument parsing but before
 165   // stub generation).
 166   if (UseCompressedOops) {
 167     // Size info for oops within java objects is fixed
 168     heapOopSize        = jintSize;
 169     LogBytesPerHeapOop = LogBytesPerInt;
 170     LogBitsPerHeapOop  = LogBitsPerInt;
 171     BytesPerHeapOop    = BytesPerInt;
 172     BitsPerHeapOop     = BitsPerInt;
 173   } else {
 174     heapOopSize        = oopSize;
 175     LogBytesPerHeapOop = LogBytesPerWord;
 176     LogBitsPerHeapOop  = LogBitsPerWord;
 177     BytesPerHeapOop    = BytesPerWord;
 178     BitsPerHeapOop     = BitsPerWord;
 179   }
 180   _type2aelembytes[T_OBJECT] = heapOopSize;
 181   _type2aelembytes[T_ARRAY]  = heapOopSize;

 182 }
 183 
 184 
 185 // Map BasicType to signature character
 186 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, 0};
 187 
 188 // Map BasicType to Java type name
 189 const char* type2name_tab[T_CONFLICT+1] = {
 190   NULL, NULL, NULL, NULL,
 191   "boolean",
 192   "char",
 193   "float",
 194   "double",
 195   "byte",
 196   "short",
 197   "int",
 198   "long",
 199   "object",
 200   "array",

 201   "void",
 202   "*address*",
 203   "*narrowoop*",
 204   "*metadata*",
 205   "*narrowklass*",
 206   "valuetypeptr",
 207   "*conflict*"
 208 };
 209 
 210 
 211 BasicType name2type(const char* name) {
 212   for (int i = T_BOOLEAN; i <= T_VOID; i++) {
 213     BasicType t = (BasicType)i;
 214     if (type2name_tab[t] != NULL && 0 == strcmp(type2name_tab[t], name))
 215       return t;
 216   }
 217   return T_ILLEGAL;
 218 }
 219 
 220 // Map BasicType to size in words
 221 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};
 222 
 223 BasicType type2field[T_CONFLICT+1] = {
 224   (BasicType)0,            // 0,
 225   (BasicType)0,            // 1,
 226   (BasicType)0,            // 2,
 227   (BasicType)0,            // 3,
 228   T_BOOLEAN,               // T_BOOLEAN  =  4,
 229   T_CHAR,                  // T_CHAR     =  5,
 230   T_FLOAT,                 // T_FLOAT    =  6,
 231   T_DOUBLE,                // T_DOUBLE   =  7,
 232   T_BYTE,                  // T_BYTE     =  8,
 233   T_SHORT,                 // T_SHORT    =  9,
 234   T_INT,                   // T_INT      = 10,
 235   T_LONG,                  // T_LONG     = 11,
 236   T_OBJECT,                // T_OBJECT   = 12,
 237   T_OBJECT,                // T_ARRAY    = 13,

 238   T_VOID,                  // T_VOID     = 15,
 239   T_ADDRESS,               // T_ADDRESS  = 16,
 240   T_NARROWOOP,             // T_NARROWOOP= 17,
 241   T_METADATA,              // T_METADATA = 18,
 242   T_NARROWKLASS,           // T_NARROWKLASS = 19,
 243   T_VALUETYPEPTR,          // T_VALUETYPEPTR = 20,
 244   T_CONFLICT               // T_CONFLICT = 21,
 245 };
 246 
 247 
 248 BasicType type2wfield[T_CONFLICT+1] = {
 249   (BasicType)0,            // 0,
 250   (BasicType)0,            // 1,
 251   (BasicType)0,            // 2,
 252   (BasicType)0,            // 3,
 253   T_INT,     // T_BOOLEAN  =  4,
 254   T_INT,     // T_CHAR     =  5,
 255   T_FLOAT,   // T_FLOAT    =  6,
 256   T_DOUBLE,  // T_DOUBLE   =  7,
 257   T_INT,     // T_BYTE     =  8,
 258   T_INT,     // 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_VOID,    // T_VOID     = 15,
 264   T_ADDRESS, // T_ADDRESS  = 16,
 265   T_NARROWOOP, // T_NARROWOOP  = 17,
 266   T_METADATA,  // T_METADATA   = 18,
 267   T_NARROWKLASS, // T_NARROWKLASS  = 19,
 268   T_VALUETYPEPTR,// T_VALUETYPEPTR = 20,
 269   T_CONFLICT // T_CONFLICT = 21,
 270 };
 271 
 272 
 273 int _type2aelembytes[T_CONFLICT+1] = {
 274   0,                         // 0
 275   0,                         // 1
 276   0,                         // 2
 277   0,                         // 3
 278   T_BOOLEAN_aelem_bytes,     // T_BOOLEAN  =  4,
 279   T_CHAR_aelem_bytes,        // T_CHAR     =  5,
 280   T_FLOAT_aelem_bytes,       // T_FLOAT    =  6,
 281   T_DOUBLE_aelem_bytes,      // T_DOUBLE   =  7,
 282   T_BYTE_aelem_bytes,        // T_BYTE     =  8,
 283   T_SHORT_aelem_bytes,       // T_SHORT    =  9,
 284   T_INT_aelem_bytes,         // T_INT      = 10,
 285   T_LONG_aelem_bytes,        // T_LONG     = 11,
 286   T_OBJECT_aelem_bytes,      // T_OBJECT   = 12,
 287   T_ARRAY_aelem_bytes,       // T_ARRAY    = 13,

 288   0,                         // T_VOID     = 15,
 289   T_OBJECT_aelem_bytes,      // T_ADDRESS  = 16,
 290   T_NARROWOOP_aelem_bytes,   // T_NARROWOOP= 17,
 291   T_OBJECT_aelem_bytes,      // T_METADATA = 18,
 292   T_NARROWKLASS_aelem_bytes, // T_NARROWKLASS= 19,
 293   T_VALUETYPEPTR_aelem_bytes,// T_VALUETYPEPTR = 20
 294   0                          // T_CONFLICT = 21,
 295 };
 296 
 297 #ifdef ASSERT
 298 int type2aelembytes(BasicType t, bool allow_address) {
 299   assert(allow_address || t != T_ADDRESS, " ");
 300   return _type2aelembytes[t];
 301 }
 302 #endif
 303 
 304 // Support for 64-bit integer arithmetic
 305 
 306 // The following code is mostly taken from JVM typedefs_md.h and system_md.c
 307 


< prev index next >