< prev index next >

src/hotspot/share/utilities/globalDefinitions.cpp

Print this page




  98       BasicType vt = (BasicType)i;
  99       BasicType ft = type2field[vt];
 100       switch (vt) {
 101       // the following types might plausibly show up in memory layouts:
 102       case T_BOOLEAN:
 103       case T_BYTE:
 104       case T_CHAR:
 105       case T_SHORT:
 106       case T_INT:
 107       case T_FLOAT:
 108       case T_DOUBLE:
 109       case T_LONG:
 110       case T_OBJECT:
 111       case T_VALUETYPE:
 112       case T_ADDRESS:     // random raw pointer
 113       case T_METADATA:    // metadata pointer
 114       case T_NARROWOOP:   // compressed pointer
 115       case T_NARROWKLASS: // compressed klass pointer
 116       case T_CONFLICT:    // might as well support a bottom type
 117       case T_VOID:        // padding or other unaddressed word
 118       case T_VALUETYPEPTR:
 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");
 137 #endif
 138 


 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   _type2aelembytes[T_VALUETYPE]  = 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', '[', 'Q', 'V', 0, 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   "valuetype",
 199   "void",
 200   "*address*",
 201   "*narrowoop*",
 202   "*metadata*",
 203   "*narrowklass*",
 204   "valuetypeptr",
 205   "*conflict*"
 206 };
 207 
 208 
 209 BasicType name2type(const char* name) {
 210   for (int i = T_BOOLEAN; i <= T_VOID; i++) {
 211     BasicType t = (BasicType)i;
 212     if (type2name_tab[t] != NULL && 0 == strcmp(type2name_tab[t], name))
 213       return t;
 214   }
 215   return T_ILLEGAL;
 216 }
 217 
 218 // Map BasicType to size in words
 219 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};
 220 
 221 BasicType type2field[T_CONFLICT+1] = {
 222   (BasicType)0,            // 0,
 223   (BasicType)0,            // 1,
 224   (BasicType)0,            // 2,
 225   (BasicType)0,            // 3,
 226   T_BOOLEAN,               // T_BOOLEAN  =  4,
 227   T_CHAR,                  // T_CHAR     =  5,
 228   T_FLOAT,                 // T_FLOAT    =  6,
 229   T_DOUBLE,                // T_DOUBLE   =  7,
 230   T_BYTE,                  // T_BYTE     =  8,
 231   T_SHORT,                 // T_SHORT    =  9,
 232   T_INT,                   // T_INT      = 10,
 233   T_LONG,                  // T_LONG     = 11,
 234   T_OBJECT,                // T_OBJECT   = 12,
 235   T_OBJECT,                // T_ARRAY    = 13,
 236   T_VALUETYPE,             // T_VALUETYPE = 14,
 237   T_VOID,                  // T_VOID     = 15,
 238   T_ADDRESS,               // T_ADDRESS  = 16,
 239   T_NARROWOOP,             // T_NARROWOOP= 17,
 240   T_METADATA,              // T_METADATA = 18,
 241   T_NARROWKLASS,           // T_NARROWKLASS = 19,
 242   T_VALUETYPEPTR,          // T_VALUETYPEPTR = 20,
 243   T_CONFLICT               // T_CONFLICT = 21,
 244 };
 245 
 246 
 247 BasicType type2wfield[T_CONFLICT+1] = {
 248   (BasicType)0,            // 0,
 249   (BasicType)0,            // 1,
 250   (BasicType)0,            // 2,
 251   (BasicType)0,            // 3,
 252   T_INT,     // T_BOOLEAN  =  4,
 253   T_INT,     // T_CHAR     =  5,
 254   T_FLOAT,   // T_FLOAT    =  6,
 255   T_DOUBLE,  // T_DOUBLE   =  7,
 256   T_INT,     // T_BYTE     =  8,
 257   T_INT,     // T_SHORT    =  9,
 258   T_INT,     // T_INT      = 10,
 259   T_LONG,    // T_LONG     = 11,
 260   T_OBJECT,  // T_OBJECT   = 12,
 261   T_OBJECT,  // T_ARRAY    = 13,
 262   T_VALUETYPE, // T_VALUETYPE = 14,
 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   T_VALUETYPE_aelem_bytes,   // T_VALUETYPE = 14,
 289   0,                         // T_VOID     = 15,
 290   T_OBJECT_aelem_bytes,      // T_ADDRESS  = 16,
 291   T_NARROWOOP_aelem_bytes,   // T_NARROWOOP= 17,
 292   T_OBJECT_aelem_bytes,      // T_METADATA = 18,
 293   T_NARROWKLASS_aelem_bytes, // T_NARROWKLASS= 19,
 294   T_VALUETYPEPTR_aelem_bytes,// T_VALUETYPEPTR = 20,
 295   0                          // T_CONFLICT = 21,
 296 };
 297 
 298 #ifdef ASSERT
 299 int type2aelembytes(BasicType t, bool allow_address) {
 300   assert(allow_address || t != T_ADDRESS, " ");
 301   return _type2aelembytes[t];
 302 }
 303 #endif
 304 
 305 // Support for 64-bit integer arithmetic
 306 
 307 // The following code is mostly taken from JVM typedefs_md.h and system_md.c
 308 
 309 static const jlong high_bit   = (jlong)1 << (jlong)63;
 310 static const jlong other_bits = ~high_bit;
 311 
 312 jlong float2long(jfloat f) {
 313   jlong tmp = (jlong) f;
 314   if (tmp != high_bit) {
 315     return tmp;




  98       BasicType vt = (BasicType)i;
  99       BasicType ft = type2field[vt];
 100       switch (vt) {
 101       // the following types might plausibly show up in memory layouts:
 102       case T_BOOLEAN:
 103       case T_BYTE:
 104       case T_CHAR:
 105       case T_SHORT:
 106       case T_INT:
 107       case T_FLOAT:
 108       case T_DOUBLE:
 109       case T_LONG:
 110       case T_OBJECT:
 111       case T_VALUETYPE:
 112       case T_ADDRESS:     // random raw pointer
 113       case T_METADATA:    // metadata pointer
 114       case T_NARROWOOP:   // compressed pointer
 115       case T_NARROWKLASS: // compressed klass pointer
 116       case T_CONFLICT:    // might as well support a bottom type
 117       case T_VOID:        // padding or other unaddressed word

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


 162     // Size info for oops within java objects is fixed
 163     heapOopSize        = jintSize;
 164     LogBytesPerHeapOop = LogBytesPerInt;
 165     LogBitsPerHeapOop  = LogBitsPerInt;
 166     BytesPerHeapOop    = BytesPerInt;
 167     BitsPerHeapOop     = BitsPerInt;
 168   } else {
 169     heapOopSize        = oopSize;
 170     LogBytesPerHeapOop = LogBytesPerWord;
 171     LogBitsPerHeapOop  = LogBitsPerWord;
 172     BytesPerHeapOop    = BytesPerWord;
 173     BitsPerHeapOop     = BitsPerWord;
 174   }
 175   _type2aelembytes[T_OBJECT] = heapOopSize;
 176   _type2aelembytes[T_ARRAY]  = heapOopSize;
 177   _type2aelembytes[T_VALUETYPE]  = 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', '[', 'Q', 'V', 0, 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   "valuetype",
 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 // Map BasicType to size in words
 217 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};
 218 
 219 BasicType type2field[T_CONFLICT+1] = {
 220   (BasicType)0,            // 0,
 221   (BasicType)0,            // 1,
 222   (BasicType)0,            // 2,
 223   (BasicType)0,            // 3,
 224   T_BOOLEAN,               // T_BOOLEAN  =  4,
 225   T_CHAR,                  // T_CHAR     =  5,
 226   T_FLOAT,                 // T_FLOAT    =  6,
 227   T_DOUBLE,                // T_DOUBLE   =  7,
 228   T_BYTE,                  // T_BYTE     =  8,
 229   T_SHORT,                 // T_SHORT    =  9,
 230   T_INT,                   // T_INT      = 10,
 231   T_LONG,                  // T_LONG     = 11,
 232   T_OBJECT,                // T_OBJECT   = 12,
 233   T_OBJECT,                // T_ARRAY    = 13,
 234   T_VALUETYPE,             // T_VALUETYPE = 14,
 235   T_VOID,                  // T_VOID     = 15,
 236   T_ADDRESS,               // T_ADDRESS  = 16,
 237   T_NARROWOOP,             // T_NARROWOOP= 17,
 238   T_METADATA,              // T_METADATA = 18,
 239   T_NARROWKLASS,           // T_NARROWKLASS = 19,
 240   T_CONFLICT               // T_CONFLICT = 20

 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_VALUETYPE, // T_VALUETYPE = 14,
 260   T_VOID,    // T_VOID     = 15,
 261   T_ADDRESS, // T_ADDRESS  = 16,
 262   T_NARROWOOP, // T_NARROWOOP  = 17,
 263   T_METADATA,  // T_METADATA   = 18,
 264   T_NARROWKLASS, // T_NARROWKLASS  = 19,
 265   T_CONFLICT // T_CONFLICT = 20

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

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


< prev index next >