src/share/vm/utilities/globalDefinitions.cpp

Print this page




  97   assert(char2type(0) == T_ILLEGAL, "correct illegality");
  98 
  99   {
 100     for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
 101       BasicType vt = (BasicType)i;
 102       BasicType ft = type2field[vt];
 103       switch (vt) {
 104       // the following types might plausibly show up in memory layouts:
 105       case T_BOOLEAN:
 106       case T_BYTE:
 107       case T_CHAR:
 108       case T_SHORT:
 109       case T_INT:
 110       case T_FLOAT:
 111       case T_DOUBLE:
 112       case T_LONG:
 113       case T_OBJECT:
 114       case T_ADDRESS:   // random raw pointer
 115       case T_METADATA:  // metadata pointer
 116       case T_NARROWOOP: // compressed pointer

 117       case T_CONFLICT:  // might as well support a bottom type
 118       case T_VOID:      // padding or other unaddressed word
 119         // layout type must map to itself
 120         assert(vt == ft, "");
 121         break;
 122       default:
 123         // non-layout type must map to a (different) layout type
 124         assert(vt != ft, "");
 125         assert(ft == type2field[ft], "");
 126       }
 127       // every type must map to same-sized layout type:
 128       assert(type2size[vt] == type2size[ft], "");
 129     }
 130   }
 131   // These are assumed, e.g., when filling HeapWords with juints.
 132   assert(is_power_of_2(sizeof(juint)), "juint must be power of 2");
 133   assert(is_power_of_2(HeapWordSize), "HeapWordSize must be power of 2");
 134   assert((size_t)HeapWordSize >= sizeof(juint),
 135          "HeapWord should be at least as large as juint");
 136   assert(sizeof(NULL) == sizeof(char*), "NULL must be same size as pointer");


 162   if (UseCompressedOops) {
 163     // Size info for oops within java objects is fixed
 164     heapOopSize        = jintSize;
 165     LogBytesPerHeapOop = LogBytesPerInt;
 166     LogBitsPerHeapOop  = LogBitsPerInt;
 167     BytesPerHeapOop    = BytesPerInt;
 168     BitsPerHeapOop     = BitsPerInt;
 169   } else {
 170     heapOopSize        = oopSize;
 171     LogBytesPerHeapOop = LogBytesPerWord;
 172     LogBitsPerHeapOop  = LogBitsPerWord;
 173     BytesPerHeapOop    = BytesPerWord;
 174     BitsPerHeapOop     = BitsPerWord;
 175   }
 176   _type2aelembytes[T_OBJECT] = heapOopSize;
 177   _type2aelembytes[T_ARRAY]  = heapOopSize;
 178 }
 179 
 180 
 181 // Map BasicType to signature character
 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};
 183 
 184 // Map BasicType to Java type name
 185 const char* type2name_tab[T_CONFLICT+1] = {
 186   NULL, NULL, NULL, NULL,
 187   "boolean",
 188   "char",
 189   "float",
 190   "double",
 191   "byte",
 192   "short",
 193   "int",
 194   "long",
 195   "object",
 196   "array",
 197   "void",
 198   "*address*",
 199   "*narrowoop*",
 200   "*metadata*",

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

 238 };
 239 
 240 
 241 BasicType type2wfield[T_CONFLICT+1] = {
 242   (BasicType)0,            // 0,
 243   (BasicType)0,            // 1,
 244   (BasicType)0,            // 2,
 245   (BasicType)0,            // 3,
 246   T_INT,     // T_BOOLEAN  =  4,
 247   T_INT,     // T_CHAR     =  5,
 248   T_FLOAT,   // T_FLOAT    =  6,
 249   T_DOUBLE,  // T_DOUBLE   =  7,
 250   T_INT,     // T_BYTE     =  8,
 251   T_INT,     // T_SHORT    =  9,
 252   T_INT,     // T_INT      = 10,
 253   T_LONG,    // T_LONG     = 11,
 254   T_OBJECT,  // T_OBJECT   = 12,
 255   T_OBJECT,  // T_ARRAY    = 13,
 256   T_VOID,    // T_VOID     = 14,
 257   T_ADDRESS, // T_ADDRESS  = 15,
 258   T_NARROWOOP, // T_NARROWOOP  = 16,
 259   T_METADATA,  // T_METADATA   = 17,
 260   T_CONFLICT // T_CONFLICT = 18,

 261 };
 262 
 263 
 264 int _type2aelembytes[T_CONFLICT+1] = {
 265   0,                      // 0
 266   0,                      // 1
 267   0,                      // 2
 268   0,                      // 3
 269   T_BOOLEAN_aelem_bytes,  // T_BOOLEAN  =  4,
 270   T_CHAR_aelem_bytes,     // T_CHAR     =  5,
 271   T_FLOAT_aelem_bytes,    // T_FLOAT    =  6,
 272   T_DOUBLE_aelem_bytes,   // T_DOUBLE   =  7,
 273   T_BYTE_aelem_bytes,     // T_BYTE     =  8,
 274   T_SHORT_aelem_bytes,    // T_SHORT    =  9,
 275   T_INT_aelem_bytes,      // T_INT      = 10,
 276   T_LONG_aelem_bytes,     // T_LONG     = 11,
 277   T_OBJECT_aelem_bytes,   // T_OBJECT   = 12,
 278   T_ARRAY_aelem_bytes,    // T_ARRAY    = 13,
 279   0,                      // T_VOID     = 14,
 280   T_OBJECT_aelem_bytes,   // T_ADDRESS  = 15,
 281   T_NARROWOOP_aelem_bytes,// T_NARROWOOP= 16,
 282   T_OBJECT_aelem_bytes,   // T_METADATA = 17,
 283   0                       // T_CONFLICT = 18,

 284 };
 285 
 286 #ifdef ASSERT
 287 int type2aelembytes(BasicType t, bool allow_address) {
 288   assert(allow_address || t != T_ADDRESS, " ");
 289   return _type2aelembytes[t];
 290 }
 291 #endif
 292 
 293 // Support for 64-bit integer arithmetic
 294 
 295 // The following code is mostly taken from JVM typedefs_md.h and system_md.c
 296 
 297 static const jlong high_bit   = (jlong)1 << (jlong)63;
 298 static const jlong other_bits = ~high_bit;
 299 
 300 jlong float2long(jfloat f) {
 301   jlong tmp = (jlong) f;
 302   if (tmp != high_bit) {
 303     return tmp;




  97   assert(char2type(0) == T_ILLEGAL, "correct illegality");
  98 
  99   {
 100     for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
 101       BasicType vt = (BasicType)i;
 102       BasicType ft = type2field[vt];
 103       switch (vt) {
 104       // the following types might plausibly show up in memory layouts:
 105       case T_BOOLEAN:
 106       case T_BYTE:
 107       case T_CHAR:
 108       case T_SHORT:
 109       case T_INT:
 110       case T_FLOAT:
 111       case T_DOUBLE:
 112       case T_LONG:
 113       case T_OBJECT:
 114       case T_ADDRESS:     // random raw pointer
 115       case T_METADATA:    // metadata pointer
 116       case T_NARROWOOP:   // compressed pointer
 117       case T_NARROWKLASS: // compressed klass pointer
 118       case T_CONFLICT:    // might as well support a bottom type
 119       case T_VOID:        // padding or other unaddressed word
 120         // layout type must map to itself
 121         assert(vt == ft, "");
 122         break;
 123       default:
 124         // non-layout type must map to a (different) layout type
 125         assert(vt != ft, "");
 126         assert(ft == type2field[ft], "");
 127       }
 128       // every type must map to same-sized layout type:
 129       assert(type2size[vt] == type2size[ft], "");
 130     }
 131   }
 132   // These are assumed, e.g., when filling HeapWords with juints.
 133   assert(is_power_of_2(sizeof(juint)), "juint must be power of 2");
 134   assert(is_power_of_2(HeapWordSize), "HeapWordSize must be power of 2");
 135   assert((size_t)HeapWordSize >= sizeof(juint),
 136          "HeapWord should be at least as large as juint");
 137   assert(sizeof(NULL) == sizeof(char*), "NULL must be same size as pointer");


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