< prev index next >

src/hotspot/share/utilities/globalDefinitions.hpp

Print this page

 582 #ifdef CPU_MULTI_COPY_ATOMIC
 583 // Not needed.
 584 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = false;
 585 #else
 586 // From all non-multi-copy-atomic architectures, only PPC64 supports IRIW at the moment.
 587 // Final decision is subject to JEP 188: Java Memory Model Update.
 588 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = PPC64_ONLY(true) NOT_PPC64(false);
 589 #endif
 590 
 591 // The expected size in bytes of a cache line.
 592 #ifndef DEFAULT_CACHE_LINE_SIZE
 593 #error "Platform should define DEFAULT_CACHE_LINE_SIZE"
 594 #endif
 595 
 596 // The default padding size for data structures to avoid false sharing.
 597 #ifndef DEFAULT_PADDING_SIZE
 598 #error "Platform should define DEFAULT_PADDING_SIZE"
 599 #endif
 600 
 601 









 602 //----------------------------------------------------------------------------------------------------
 603 // Miscellaneous
 604 
 605 // 6302670 Eliminate Hotspot __fabsf dependency
 606 // All fabs() callers should call this function instead, which will implicitly
 607 // convert the operand to double, avoiding a dependency on __fabsf which
 608 // doesn't exist in early versions of Solaris 8.
 609 inline double fabsd(double value) {
 610   return fabs(value);
 611 }
 612 
 613 // Returns numerator/denominator as percentage value from 0 to 100. If denominator
 614 // is zero, return 0.0.
 615 template<typename T>
 616 inline double percent_of(T numerator, T denominator) {
 617   return denominator != 0 ? (double)numerator / (double)denominator * 100.0 : 0.0;
 618 }
 619 
 620 //----------------------------------------------------------------------------------------------------
 621 // Special casts

 668 enum BasicType : u1 {
 669 // The values T_BOOLEAN..T_LONG (4..11) are derived from the JVMS.
 670   T_BOOLEAN     = JVM_T_BOOLEAN,
 671   T_CHAR        = JVM_T_CHAR,
 672   T_FLOAT       = JVM_T_FLOAT,
 673   T_DOUBLE      = JVM_T_DOUBLE,
 674   T_BYTE        = JVM_T_BYTE,
 675   T_SHORT       = JVM_T_SHORT,
 676   T_INT         = JVM_T_INT,
 677   T_LONG        = JVM_T_LONG,
 678   // The remaining values are not part of any standard.
 679   // T_OBJECT and T_VOID denote two more semantic choices
 680   // for method return values.
 681   // T_OBJECT and T_ARRAY describe signature syntax.
 682   // T_ADDRESS, T_METADATA, T_NARROWOOP, T_NARROWKLASS describe
 683   // internal references within the JVM as if they were Java
 684   // types in their own right.
 685   T_OBJECT      = 12,
 686   T_ARRAY       = 13,
 687   T_VOID        = 14,
 688   T_ADDRESS     = 15,
 689   T_NARROWOOP   = 16,
 690   T_METADATA    = 17,
 691   T_NARROWKLASS = 18,
 692   T_CONFLICT    = 19, // for stack value type with conflicting contents

 693   T_ILLEGAL     = 99
 694 };
 695 
 696 #define SIGNATURE_TYPES_DO(F, N)                \
 697     F(JVM_SIGNATURE_BOOLEAN, T_BOOLEAN, N)      \
 698     F(JVM_SIGNATURE_CHAR,    T_CHAR,    N)      \
 699     F(JVM_SIGNATURE_FLOAT,   T_FLOAT,   N)      \
 700     F(JVM_SIGNATURE_DOUBLE,  T_DOUBLE,  N)      \
 701     F(JVM_SIGNATURE_BYTE,    T_BYTE,    N)      \
 702     F(JVM_SIGNATURE_SHORT,   T_SHORT,   N)      \
 703     F(JVM_SIGNATURE_INT,     T_INT,     N)      \
 704     F(JVM_SIGNATURE_LONG,    T_LONG,    N)      \
 705     F(JVM_SIGNATURE_CLASS,   T_OBJECT,  N)      \
 706     F(JVM_SIGNATURE_ARRAY,   T_ARRAY,   N)      \
 707     F(JVM_SIGNATURE_VOID,    T_VOID,    N)      \
 708     /*end*/
 709 
 710 inline bool is_java_type(BasicType t) {
 711   return T_BOOLEAN <= t && t <= T_VOID;
 712 }

 716 }
 717 
 718 inline bool is_subword_type(BasicType t) {
 719   // these guys are processed exactly like T_INT in calling sequences:
 720   return (t == T_BOOLEAN || t == T_CHAR || t == T_BYTE || t == T_SHORT);
 721 }
 722 
 723 inline bool is_signed_subword_type(BasicType t) {
 724   return (t == T_BYTE || t == T_SHORT);
 725 }
 726 
 727 inline bool is_unsigned_subword_type(BasicType t) {
 728   return (t == T_BOOLEAN || t == T_CHAR);
 729 }
 730 
 731 inline bool is_double_word_type(BasicType t) {
 732   return (t == T_DOUBLE || t == T_LONG);
 733 }
 734 
 735 inline bool is_reference_type(BasicType t, bool include_narrow_oop = false) {

 736   return (t == T_OBJECT || t == T_ARRAY || (include_narrow_oop && t == T_NARROWOOP));
 737 }
 738 
 739 inline bool is_integral_type(BasicType t) {
 740   return is_subword_type(t) || t == T_INT || t == T_LONG;
 741 }
 742 
 743 inline bool is_non_subword_integral_type(BasicType t) {
 744   return t == T_INT || t == T_LONG;
 745 }
 746 
 747 inline bool is_floating_point_type(BasicType t) {
 748   return (t == T_FLOAT || t == T_DOUBLE);
 749 }
 750 
 751 extern char type2char_tab[T_CONFLICT+1];     // Map a BasicType to a jchar
 752 inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; }
 753 extern int type2size[T_CONFLICT+1];         // Map BasicType to result stack elements
 754 extern const char* type2name_tab[T_CONFLICT+1];     // Map a BasicType to a char*
 755 extern BasicType name2type(const char* name);

 790 
 791 // Auxiliary math routines
 792 // least common multiple
 793 extern size_t lcm(size_t a, size_t b);
 794 
 795 
 796 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
 797 enum BasicTypeSize {
 798   T_BOOLEAN_size     = 1,
 799   T_CHAR_size        = 1,
 800   T_FLOAT_size       = 1,
 801   T_DOUBLE_size      = 2,
 802   T_BYTE_size        = 1,
 803   T_SHORT_size       = 1,
 804   T_INT_size         = 1,
 805   T_LONG_size        = 2,
 806   T_OBJECT_size      = 1,
 807   T_ARRAY_size       = 1,
 808   T_NARROWOOP_size   = 1,
 809   T_NARROWKLASS_size = 1,
 810   T_VOID_size        = 0

 811 };
 812 
 813 // this works on valid parameter types but not T_VOID, T_CONFLICT, etc.
 814 inline int parameter_type_word_count(BasicType t) {
 815   if (is_double_word_type(t))  return 2;
 816   assert(is_java_primitive(t) || is_reference_type(t), "no goofy types here please");
 817   assert(type2size[t] == 1, "must be");
 818   return 1;
 819 }
 820 
 821 // maps a BasicType to its instance field storage type:
 822 // all sub-word integral types are widened to T_INT
 823 extern BasicType type2field[T_CONFLICT+1];
 824 extern BasicType type2wfield[T_CONFLICT+1];
 825 
 826 
 827 // size in bytes
 828 enum ArrayElementSize {
 829   T_BOOLEAN_aelem_bytes     = 1,
 830   T_CHAR_aelem_bytes        = 2,
 831   T_FLOAT_aelem_bytes       = 4,
 832   T_DOUBLE_aelem_bytes      = 8,
 833   T_BYTE_aelem_bytes        = 1,
 834   T_SHORT_aelem_bytes       = 2,
 835   T_INT_aelem_bytes         = 4,
 836   T_LONG_aelem_bytes        = 8,
 837 #ifdef _LP64
 838   T_OBJECT_aelem_bytes      = 8,
 839   T_ARRAY_aelem_bytes       = 8,
 840 #else
 841   T_OBJECT_aelem_bytes      = 4,
 842   T_ARRAY_aelem_bytes       = 4,
 843 #endif
 844   T_NARROWOOP_aelem_bytes   = 4,
 845   T_NARROWKLASS_aelem_bytes = 4,
 846   T_VOID_aelem_bytes        = 0

 847 };
 848 
 849 extern int _type2aelembytes[T_CONFLICT+1]; // maps a BasicType to nof bytes used by its array element
 850 #ifdef ASSERT
 851 extern int type2aelembytes(BasicType t, bool allow_address = false); // asserts
 852 #else
 853 inline int type2aelembytes(BasicType t, bool allow_address = false) { return _type2aelembytes[t]; }
 854 #endif
 855 
 856 inline bool same_type_or_subword_size(BasicType t1, BasicType t2) {
 857   return (t1 == t2) || (is_subword_type(t1) && type2aelembytes(t1) == type2aelembytes(t2));
 858 }
 859 
 860 // JavaValue serves as a container for arbitrary Java values.
 861 
 862 class JavaValue {
 863 
 864  public:
 865   typedef union JavaCallValue {
 866     jfloat   f;

 916 
 917 // TosState describes the top-of-stack state before and after the execution of
 918 // a bytecode or method. The top-of-stack value may be cached in one or more CPU
 919 // registers. The TosState corresponds to the 'machine representation' of this cached
 920 // value. There's 4 states corresponding to the JAVA types int, long, float & double
 921 // as well as a 5th state in case the top-of-stack value is actually on the top
 922 // of stack (in memory) and thus not cached. The atos state corresponds to the itos
 923 // state when it comes to machine representation but is used separately for (oop)
 924 // type specific operations (e.g. verification code).
 925 
 926 enum TosState {         // describes the tos cache contents
 927   btos = 0,             // byte, bool tos cached
 928   ztos = 1,             // byte, bool tos cached
 929   ctos = 2,             // char tos cached
 930   stos = 3,             // short tos cached
 931   itos = 4,             // int tos cached
 932   ltos = 5,             // long tos cached
 933   ftos = 6,             // float tos cached
 934   dtos = 7,             // double tos cached
 935   atos = 8,             // object cached
 936   vtos = 9,             // tos not cached
 937   number_of_states,
 938   ilgl                  // illegal state: should not occur
 939 };
 940 
 941 
 942 inline TosState as_TosState(BasicType type) {
 943   switch (type) {
 944     case T_BYTE   : return btos;
 945     case T_BOOLEAN: return ztos;
 946     case T_CHAR   : return ctos;
 947     case T_SHORT  : return stos;
 948     case T_INT    : return itos;
 949     case T_LONG   : return ltos;
 950     case T_FLOAT  : return ftos;
 951     case T_DOUBLE : return dtos;
 952     case T_VOID   : return vtos;
 953     case T_ARRAY  : // fall through
 954     case T_OBJECT : return atos;
 955     default       : return ilgl;
 956   }
 957 }
 958 
 959 inline BasicType as_BasicType(TosState state) {
 960   switch (state) {
 961     case btos : return T_BYTE;
 962     case ztos : return T_BOOLEAN;
 963     case ctos : return T_CHAR;
 964     case stos : return T_SHORT;
 965     case itos : return T_INT;
 966     case ltos : return T_LONG;
 967     case ftos : return T_FLOAT;
 968     case dtos : return T_DOUBLE;
 969     case atos : return T_OBJECT;
 970     case vtos : return T_VOID;
 971     default   : return T_ILLEGAL;
 972   }
 973 }

 582 #ifdef CPU_MULTI_COPY_ATOMIC
 583 // Not needed.
 584 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = false;
 585 #else
 586 // From all non-multi-copy-atomic architectures, only PPC64 supports IRIW at the moment.
 587 // Final decision is subject to JEP 188: Java Memory Model Update.
 588 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = PPC64_ONLY(true) NOT_PPC64(false);
 589 #endif
 590 
 591 // The expected size in bytes of a cache line.
 592 #ifndef DEFAULT_CACHE_LINE_SIZE
 593 #error "Platform should define DEFAULT_CACHE_LINE_SIZE"
 594 #endif
 595 
 596 // The default padding size for data structures to avoid false sharing.
 597 #ifndef DEFAULT_PADDING_SIZE
 598 #error "Platform should define DEFAULT_PADDING_SIZE"
 599 #endif
 600 
 601 
 602 //----------------------------------------------------------------------------------------------------
 603 // Prototyping
 604 // "Code Missing Here" macro, un-define when integrating back from prototyping stage and break
 605 // compilation on purpose (i.e. "forget me not")
 606 #define PROTOTYPE
 607 #ifdef PROTOTYPE
 608 #define CMH(m)
 609 #endif
 610 
 611 //----------------------------------------------------------------------------------------------------
 612 // Miscellaneous
 613 
 614 // 6302670 Eliminate Hotspot __fabsf dependency
 615 // All fabs() callers should call this function instead, which will implicitly
 616 // convert the operand to double, avoiding a dependency on __fabsf which
 617 // doesn't exist in early versions of Solaris 8.
 618 inline double fabsd(double value) {
 619   return fabs(value);
 620 }
 621 
 622 // Returns numerator/denominator as percentage value from 0 to 100. If denominator
 623 // is zero, return 0.0.
 624 template<typename T>
 625 inline double percent_of(T numerator, T denominator) {
 626   return denominator != 0 ? (double)numerator / (double)denominator * 100.0 : 0.0;
 627 }
 628 
 629 //----------------------------------------------------------------------------------------------------
 630 // Special casts

 677 enum BasicType : u1 {
 678 // The values T_BOOLEAN..T_LONG (4..11) are derived from the JVMS.
 679   T_BOOLEAN     = JVM_T_BOOLEAN,
 680   T_CHAR        = JVM_T_CHAR,
 681   T_FLOAT       = JVM_T_FLOAT,
 682   T_DOUBLE      = JVM_T_DOUBLE,
 683   T_BYTE        = JVM_T_BYTE,
 684   T_SHORT       = JVM_T_SHORT,
 685   T_INT         = JVM_T_INT,
 686   T_LONG        = JVM_T_LONG,
 687   // The remaining values are not part of any standard.
 688   // T_OBJECT and T_VOID denote two more semantic choices
 689   // for method return values.
 690   // T_OBJECT and T_ARRAY describe signature syntax.
 691   // T_ADDRESS, T_METADATA, T_NARROWOOP, T_NARROWKLASS describe
 692   // internal references within the JVM as if they were Java
 693   // types in their own right.
 694   T_OBJECT      = 12,
 695   T_ARRAY       = 13,
 696   T_VOID        = 14,
 697   T_FLAT_ELEMENT = 15, // Not a true BasicType, only used in layout helpers of flat arrays
 698   T_ADDRESS     = 16,
 699   T_NARROWOOP   = 17,
 700   T_METADATA    = 18,
 701   T_NARROWKLASS = 19,
 702   T_CONFLICT    = 20, // for stack value type with conflicting contents
 703   T_ILLEGAL     = 99
 704 };
 705 
 706 #define SIGNATURE_TYPES_DO(F, N)                \
 707     F(JVM_SIGNATURE_BOOLEAN, T_BOOLEAN, N)      \
 708     F(JVM_SIGNATURE_CHAR,    T_CHAR,    N)      \
 709     F(JVM_SIGNATURE_FLOAT,   T_FLOAT,   N)      \
 710     F(JVM_SIGNATURE_DOUBLE,  T_DOUBLE,  N)      \
 711     F(JVM_SIGNATURE_BYTE,    T_BYTE,    N)      \
 712     F(JVM_SIGNATURE_SHORT,   T_SHORT,   N)      \
 713     F(JVM_SIGNATURE_INT,     T_INT,     N)      \
 714     F(JVM_SIGNATURE_LONG,    T_LONG,    N)      \
 715     F(JVM_SIGNATURE_CLASS,   T_OBJECT,  N)      \
 716     F(JVM_SIGNATURE_ARRAY,   T_ARRAY,   N)      \
 717     F(JVM_SIGNATURE_VOID,    T_VOID,    N)      \
 718     /*end*/
 719 
 720 inline bool is_java_type(BasicType t) {
 721   return T_BOOLEAN <= t && t <= T_VOID;
 722 }

 726 }
 727 
 728 inline bool is_subword_type(BasicType t) {
 729   // these guys are processed exactly like T_INT in calling sequences:
 730   return (t == T_BOOLEAN || t == T_CHAR || t == T_BYTE || t == T_SHORT);
 731 }
 732 
 733 inline bool is_signed_subword_type(BasicType t) {
 734   return (t == T_BYTE || t == T_SHORT);
 735 }
 736 
 737 inline bool is_unsigned_subword_type(BasicType t) {
 738   return (t == T_BOOLEAN || t == T_CHAR);
 739 }
 740 
 741 inline bool is_double_word_type(BasicType t) {
 742   return (t == T_DOUBLE || t == T_LONG);
 743 }
 744 
 745 inline bool is_reference_type(BasicType t, bool include_narrow_oop = false) {
 746   assert(t != T_FLAT_ELEMENT, "");  // Strong assert to detect misuses of T_FLAT_ELEMENT
 747   return (t == T_OBJECT || t == T_ARRAY || (include_narrow_oop && t == T_NARROWOOP));
 748 }
 749 
 750 inline bool is_integral_type(BasicType t) {
 751   return is_subword_type(t) || t == T_INT || t == T_LONG;
 752 }
 753 
 754 inline bool is_non_subword_integral_type(BasicType t) {
 755   return t == T_INT || t == T_LONG;
 756 }
 757 
 758 inline bool is_floating_point_type(BasicType t) {
 759   return (t == T_FLOAT || t == T_DOUBLE);
 760 }
 761 
 762 extern char type2char_tab[T_CONFLICT+1];     // Map a BasicType to a jchar
 763 inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; }
 764 extern int type2size[T_CONFLICT+1];         // Map BasicType to result stack elements
 765 extern const char* type2name_tab[T_CONFLICT+1];     // Map a BasicType to a char*
 766 extern BasicType name2type(const char* name);

 801 
 802 // Auxiliary math routines
 803 // least common multiple
 804 extern size_t lcm(size_t a, size_t b);
 805 
 806 
 807 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
 808 enum BasicTypeSize {
 809   T_BOOLEAN_size     = 1,
 810   T_CHAR_size        = 1,
 811   T_FLOAT_size       = 1,
 812   T_DOUBLE_size      = 2,
 813   T_BYTE_size        = 1,
 814   T_SHORT_size       = 1,
 815   T_INT_size         = 1,
 816   T_LONG_size        = 2,
 817   T_OBJECT_size      = 1,
 818   T_ARRAY_size       = 1,
 819   T_NARROWOOP_size   = 1,
 820   T_NARROWKLASS_size = 1,
 821   T_VOID_size        = 0,
 822   T_FLAT_ELEMENT_size = 0
 823 };
 824 
 825 // this works on valid parameter types but not T_VOID, T_CONFLICT, etc.
 826 inline int parameter_type_word_count(BasicType t) {
 827   if (is_double_word_type(t))  return 2;
 828   assert(is_java_primitive(t) || is_reference_type(t), "no goofy types here please");
 829   assert(type2size[t] == 1, "must be");
 830   return 1;
 831 }
 832 
 833 // maps a BasicType to its instance field storage type:
 834 // all sub-word integral types are widened to T_INT
 835 extern BasicType type2field[T_CONFLICT+1];
 836 extern BasicType type2wfield[T_CONFLICT+1];
 837 
 838 
 839 // size in bytes
 840 enum ArrayElementSize {
 841   T_BOOLEAN_aelem_bytes     = 1,
 842   T_CHAR_aelem_bytes        = 2,
 843   T_FLOAT_aelem_bytes       = 4,
 844   T_DOUBLE_aelem_bytes      = 8,
 845   T_BYTE_aelem_bytes        = 1,
 846   T_SHORT_aelem_bytes       = 2,
 847   T_INT_aelem_bytes         = 4,
 848   T_LONG_aelem_bytes        = 8,
 849 #ifdef _LP64
 850   T_OBJECT_aelem_bytes      = 8,
 851   T_ARRAY_aelem_bytes       = 8,
 852 #else
 853   T_OBJECT_aelem_bytes      = 4,
 854   T_ARRAY_aelem_bytes       = 4,
 855 #endif
 856   T_NARROWOOP_aelem_bytes   = 4,
 857   T_NARROWKLASS_aelem_bytes = 4,
 858   T_VOID_aelem_bytes        = 0,
 859   T_FLAT_ELEMENT_aelem_bytes = 0
 860 };
 861 
 862 extern int _type2aelembytes[T_CONFLICT+1]; // maps a BasicType to nof bytes used by its array element
 863 #ifdef ASSERT
 864 extern int type2aelembytes(BasicType t, bool allow_address = false); // asserts
 865 #else
 866 inline int type2aelembytes(BasicType t, bool allow_address = false) { return _type2aelembytes[t]; }
 867 #endif
 868 
 869 inline bool same_type_or_subword_size(BasicType t1, BasicType t2) {
 870   return (t1 == t2) || (is_subword_type(t1) && type2aelembytes(t1) == type2aelembytes(t2));
 871 }
 872 
 873 // JavaValue serves as a container for arbitrary Java values.
 874 
 875 class JavaValue {
 876 
 877  public:
 878   typedef union JavaCallValue {
 879     jfloat   f;

 929 
 930 // TosState describes the top-of-stack state before and after the execution of
 931 // a bytecode or method. The top-of-stack value may be cached in one or more CPU
 932 // registers. The TosState corresponds to the 'machine representation' of this cached
 933 // value. There's 4 states corresponding to the JAVA types int, long, float & double
 934 // as well as a 5th state in case the top-of-stack value is actually on the top
 935 // of stack (in memory) and thus not cached. The atos state corresponds to the itos
 936 // state when it comes to machine representation but is used separately for (oop)
 937 // type specific operations (e.g. verification code).
 938 
 939 enum TosState {         // describes the tos cache contents
 940   btos = 0,             // byte, bool tos cached
 941   ztos = 1,             // byte, bool tos cached
 942   ctos = 2,             // char tos cached
 943   stos = 3,             // short tos cached
 944   itos = 4,             // int tos cached
 945   ltos = 5,             // long tos cached
 946   ftos = 6,             // float tos cached
 947   dtos = 7,             // double tos cached
 948   atos = 8,             // object cached
 949   vtos = 9,             // tos not cached,
 950   number_of_states,
 951   ilgl                  // illegal state: should not occur
 952 };
 953 
 954 
 955 inline TosState as_TosState(BasicType type) {
 956   switch (type) {
 957     case T_BYTE   : return btos;
 958     case T_BOOLEAN: return ztos;
 959     case T_CHAR   : return ctos;
 960     case T_SHORT  : return stos;
 961     case T_INT    : return itos;
 962     case T_LONG   : return ltos;
 963     case T_FLOAT  : return ftos;
 964     case T_DOUBLE : return dtos;
 965     case T_VOID   : return vtos;
 966     case T_ARRAY  :   // fall through
 967     case T_OBJECT : return atos;
 968     default       : return ilgl;
 969   }
 970 }
 971 
 972 inline BasicType as_BasicType(TosState state) {
 973   switch (state) {
 974     case btos : return T_BYTE;
 975     case ztos : return T_BOOLEAN;
 976     case ctos : return T_CHAR;
 977     case stos : return T_SHORT;
 978     case itos : return T_INT;
 979     case ltos : return T_LONG;
 980     case ftos : return T_FLOAT;
 981     case dtos : return T_DOUBLE;
 982     case atos : return T_OBJECT;
 983     case vtos : return T_VOID;
 984     default   : return T_ILLEGAL;
 985   }
 986 }
< prev index next >