< prev index next >

src/hotspot/share/utilities/globalDefinitions.hpp

Print this page




 216 // Analogous opaque struct for metadata allocated from metaspaces.
 217 class MetaWordImpl;             // Opaque, never defined.
 218 typedef MetaWordImpl* MetaWord;
 219 
 220 // HeapWordSize must be 2^LogHeapWordSize.
 221 const int HeapWordSize        = sizeof(HeapWord);
 222 #ifdef _LP64
 223 const int LogHeapWordSize     = 3;
 224 #else
 225 const int LogHeapWordSize     = 2;
 226 #endif
 227 const int HeapWordsPerLong    = BytesPerLong / HeapWordSize;
 228 const int LogHeapWordsPerLong = LogBytesPerLong - LogHeapWordSize;
 229 
 230 // The minimum number of native machine words necessary to contain "byte_size"
 231 // bytes.
 232 inline size_t heap_word_size(size_t byte_size) {
 233   return (byte_size + (HeapWordSize-1)) >> LogHeapWordSize;
 234 }
 235 



 236 //-------------------------------------------
 237 // Constant for jlong (standardized by C++11)
 238 
 239 // Build a 64bit integer constant
 240 #define CONST64(x)  (x ## LL)
 241 #define UCONST64(x) (x ## ULL)
 242 
 243 const jlong min_jlong = CONST64(0x8000000000000000);
 244 const jlong max_jlong = CONST64(0x7fffffffffffffff);
 245 







 246 const size_t K                  = 1024;
 247 const size_t M                  = K*K;
 248 const size_t G                  = M*K;
 249 const size_t HWperKB            = K / sizeof(HeapWord);
 250 
 251 // Constants for converting from a base unit to milli-base units.  For
 252 // example from seconds to milliseconds and microseconds
 253 
 254 const int MILLIUNITS    = 1000;         // milli units per base unit
 255 const int MICROUNITS    = 1000000;      // micro units per base unit
 256 const int NANOUNITS     = 1000000000;   // nano units per base unit
 257 const int NANOUNITS_PER_MILLIUNIT = NANOUNITS / MILLIUNITS;
 258 
 259 const jlong NANOSECS_PER_SEC      = CONST64(1000000000);
 260 const jint  NANOSECS_PER_MILLISEC = 1000000;
 261 
 262 
 263 // Unit conversion functions
 264 // The caller is responsible for considering overlow.
 265 


 443 typedef julong  u8;
 444 
 445 const jubyte  max_jubyte  = (jubyte)-1;  // 0xFF       largest jubyte
 446 const jushort max_jushort = (jushort)-1; // 0xFFFF     largest jushort
 447 const juint   max_juint   = (juint)-1;   // 0xFFFFFFFF largest juint
 448 const julong  max_julong  = (julong)-1;  // 0xFF....FF largest julong
 449 
 450 typedef jbyte  s1;
 451 typedef jshort s2;
 452 typedef jint   s4;
 453 typedef jlong  s8;
 454 
 455 const jbyte min_jbyte = -(1 << 7);       // smallest jbyte
 456 const jbyte max_jbyte = (1 << 7) - 1;    // largest jbyte
 457 const jshort min_jshort = -(1 << 15);    // smallest jshort
 458 const jshort max_jshort = (1 << 15) - 1; // largest jshort
 459 
 460 const jint min_jint = (jint)1 << (sizeof(jint)*BitsPerByte-1); // 0x80000000 == smallest jint
 461 const jint max_jint = (juint)min_jint - 1;                     // 0x7FFFFFFF == largest jint
 462 





 463 //----------------------------------------------------------------------------------------------------
 464 // JVM spec restrictions
 465 
 466 const int max_method_code_size = 64*K - 1;  // JVM spec, 2nd ed. section 4.8.1 (p.134)
 467 
 468 //----------------------------------------------------------------------------------------------------
 469 // Object alignment, in units of HeapWords.
 470 //
 471 // Minimum is max(BytesPerLong, BytesPerDouble, BytesPerOop) / HeapWordSize, so jlong, jdouble and
 472 // reference fields can be naturally aligned.
 473 
 474 extern int MinObjAlignment;
 475 extern int MinObjAlignmentInBytes;
 476 extern int MinObjAlignmentInBytesMask;
 477 
 478 extern int LogMinObjAlignment;
 479 extern int LogMinObjAlignmentInBytes;
 480 
 481 const int LogKlassAlignmentInBytes = 3;
 482 const int LogKlassAlignment        = LogKlassAlignmentInBytes - LogHeapWordSize;


 647   return T_BOOLEAN <= t && t <= T_LONG;
 648 }
 649 
 650 inline bool is_subword_type(BasicType t) {
 651   // these guys are processed exactly like T_INT in calling sequences:
 652   return (t == T_BOOLEAN || t == T_CHAR || t == T_BYTE || t == T_SHORT);
 653 }
 654 
 655 inline bool is_signed_subword_type(BasicType t) {
 656   return (t == T_BYTE || t == T_SHORT);
 657 }
 658 
 659 inline bool is_double_word_type(BasicType t) {
 660   return (t == T_DOUBLE || t == T_LONG);
 661 }
 662 
 663 inline bool is_reference_type(BasicType t) {
 664   return (t == T_OBJECT || t == T_ARRAY);
 665 }
 666 




 667 extern char type2char_tab[T_CONFLICT+1];     // Map a BasicType to a jchar
 668 inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; }
 669 extern int type2size[T_CONFLICT+1];         // Map BasicType to result stack elements
 670 extern const char* type2name_tab[T_CONFLICT+1];     // Map a BasicType to a jchar
 671 inline const char* type2name(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2name_tab[t] : NULL; }
 672 extern BasicType name2type(const char* name);
 673 
 674 // Auxiliary math routines
 675 // least common multiple
 676 extern size_t lcm(size_t a, size_t b);
 677 
 678 
 679 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
 680 enum BasicTypeSize {
 681   T_BOOLEAN_size     = 1,
 682   T_CHAR_size        = 1,
 683   T_FLOAT_size       = 1,
 684   T_DOUBLE_size      = 2,
 685   T_BYTE_size        = 1,
 686   T_SHORT_size       = 1,




 216 // Analogous opaque struct for metadata allocated from metaspaces.
 217 class MetaWordImpl;             // Opaque, never defined.
 218 typedef MetaWordImpl* MetaWord;
 219 
 220 // HeapWordSize must be 2^LogHeapWordSize.
 221 const int HeapWordSize        = sizeof(HeapWord);
 222 #ifdef _LP64
 223 const int LogHeapWordSize     = 3;
 224 #else
 225 const int LogHeapWordSize     = 2;
 226 #endif
 227 const int HeapWordsPerLong    = BytesPerLong / HeapWordSize;
 228 const int LogHeapWordsPerLong = LogBytesPerLong - LogHeapWordSize;
 229 
 230 // The minimum number of native machine words necessary to contain "byte_size"
 231 // bytes.
 232 inline size_t heap_word_size(size_t byte_size) {
 233   return (byte_size + (HeapWordSize-1)) >> LogHeapWordSize;
 234 }
 235 
 236 inline jfloat  jfloat_cast(jint    x);
 237 inline jdouble  jdouble_cast(jlong    x);
 238 
 239 //-------------------------------------------
 240 // Constant for jlong (standardized by C++11)
 241 
 242 // Build a 64bit integer constant
 243 #define CONST64(x)  (x ## LL)
 244 #define UCONST64(x) (x ## ULL)
 245 
 246 const jlong min_jlong = CONST64(0x8000000000000000);
 247 const jlong max_jlong = CONST64(0x7fffffffffffffff);
 248 
 249 //-------------------------------------------
 250 // Constant for jdouble
 251 const jlong min_jlongDouble = CONST64(0x0000000000000001);
 252 const jdouble min_jdouble = jdouble_cast(min_jlongDouble);
 253 const jlong max_jlongDouble = CONST64(0x7fefffffffffffff);
 254 const jdouble max_jdouble = jdouble_cast(max_jlongDouble);
 255 
 256 const size_t K                  = 1024;
 257 const size_t M                  = K*K;
 258 const size_t G                  = M*K;
 259 const size_t HWperKB            = K / sizeof(HeapWord);
 260 
 261 // Constants for converting from a base unit to milli-base units.  For
 262 // example from seconds to milliseconds and microseconds
 263 
 264 const int MILLIUNITS    = 1000;         // milli units per base unit
 265 const int MICROUNITS    = 1000000;      // micro units per base unit
 266 const int NANOUNITS     = 1000000000;   // nano units per base unit
 267 const int NANOUNITS_PER_MILLIUNIT = NANOUNITS / MILLIUNITS;
 268 
 269 const jlong NANOSECS_PER_SEC      = CONST64(1000000000);
 270 const jint  NANOSECS_PER_MILLISEC = 1000000;
 271 
 272 
 273 // Unit conversion functions
 274 // The caller is responsible for considering overlow.
 275 


 453 typedef julong  u8;
 454 
 455 const jubyte  max_jubyte  = (jubyte)-1;  // 0xFF       largest jubyte
 456 const jushort max_jushort = (jushort)-1; // 0xFFFF     largest jushort
 457 const juint   max_juint   = (juint)-1;   // 0xFFFFFFFF largest juint
 458 const julong  max_julong  = (julong)-1;  // 0xFF....FF largest julong
 459 
 460 typedef jbyte  s1;
 461 typedef jshort s2;
 462 typedef jint   s4;
 463 typedef jlong  s8;
 464 
 465 const jbyte min_jbyte = -(1 << 7);       // smallest jbyte
 466 const jbyte max_jbyte = (1 << 7) - 1;    // largest jbyte
 467 const jshort min_jshort = -(1 << 15);    // smallest jshort
 468 const jshort max_jshort = (1 << 15) - 1; // largest jshort
 469 
 470 const jint min_jint = (jint)1 << (sizeof(jint)*BitsPerByte-1); // 0x80000000 == smallest jint
 471 const jint max_jint = (juint)min_jint - 1;                     // 0x7FFFFFFF == largest jint
 472 
 473 const jint min_jintFloat = (jint)(0x00000001);
 474 const jfloat min_jfloat = jfloat_cast(min_jintFloat);
 475 const jint max_jintFloat = (jint)(0x7f7fffff);
 476 const jfloat max_jfloat = jfloat_cast(max_jintFloat);
 477 
 478 //----------------------------------------------------------------------------------------------------
 479 // JVM spec restrictions
 480 
 481 const int max_method_code_size = 64*K - 1;  // JVM spec, 2nd ed. section 4.8.1 (p.134)
 482 
 483 //----------------------------------------------------------------------------------------------------
 484 // Object alignment, in units of HeapWords.
 485 //
 486 // Minimum is max(BytesPerLong, BytesPerDouble, BytesPerOop) / HeapWordSize, so jlong, jdouble and
 487 // reference fields can be naturally aligned.
 488 
 489 extern int MinObjAlignment;
 490 extern int MinObjAlignmentInBytes;
 491 extern int MinObjAlignmentInBytesMask;
 492 
 493 extern int LogMinObjAlignment;
 494 extern int LogMinObjAlignmentInBytes;
 495 
 496 const int LogKlassAlignmentInBytes = 3;
 497 const int LogKlassAlignment        = LogKlassAlignmentInBytes - LogHeapWordSize;


 662   return T_BOOLEAN <= t && t <= T_LONG;
 663 }
 664 
 665 inline bool is_subword_type(BasicType t) {
 666   // these guys are processed exactly like T_INT in calling sequences:
 667   return (t == T_BOOLEAN || t == T_CHAR || t == T_BYTE || t == T_SHORT);
 668 }
 669 
 670 inline bool is_signed_subword_type(BasicType t) {
 671   return (t == T_BYTE || t == T_SHORT);
 672 }
 673 
 674 inline bool is_double_word_type(BasicType t) {
 675   return (t == T_DOUBLE || t == T_LONG);
 676 }
 677 
 678 inline bool is_reference_type(BasicType t) {
 679   return (t == T_OBJECT || t == T_ARRAY);
 680 }
 681 
 682 inline bool is_integral_type(BasicType t) {
 683   return is_subword_type(t) || t == T_INT || t == T_LONG;
 684 }
 685 
 686 extern char type2char_tab[T_CONFLICT+1];     // Map a BasicType to a jchar
 687 inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; }
 688 extern int type2size[T_CONFLICT+1];         // Map BasicType to result stack elements
 689 extern const char* type2name_tab[T_CONFLICT+1];     // Map a BasicType to a jchar
 690 inline const char* type2name(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2name_tab[t] : NULL; }
 691 extern BasicType name2type(const char* name);
 692 
 693 // Auxiliary math routines
 694 // least common multiple
 695 extern size_t lcm(size_t a, size_t b);
 696 
 697 
 698 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
 699 enum BasicTypeSize {
 700   T_BOOLEAN_size     = 1,
 701   T_CHAR_size        = 1,
 702   T_FLOAT_size       = 1,
 703   T_DOUBLE_size      = 2,
 704   T_BYTE_size        = 1,
 705   T_SHORT_size       = 1,


< prev index next >