< prev index next >

src/hotspot/share/utilities/globalDefinitions.hpp

Print this page

 593 #ifdef CPU_MULTI_COPY_ATOMIC
 594 // Not needed.
 595 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = false;
 596 #else
 597 // From all non-multi-copy-atomic architectures, only PPC64 supports IRIW at the moment.
 598 // Final decision is subject to JEP 188: Java Memory Model Update.
 599 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = PPC64_ONLY(true) NOT_PPC64(false);
 600 #endif
 601 
 602 // The expected size in bytes of a cache line.
 603 #ifndef DEFAULT_CACHE_LINE_SIZE
 604 #error "Platform should define DEFAULT_CACHE_LINE_SIZE"
 605 #endif
 606 
 607 // The default padding size for data structures to avoid false sharing.
 608 #ifndef DEFAULT_PADDING_SIZE
 609 #error "Platform should define DEFAULT_PADDING_SIZE"
 610 #endif
 611 
 612 









 613 //----------------------------------------------------------------------------------------------------
 614 // Miscellaneous
 615 
 616 // 6302670 Eliminate Hotspot __fabsf dependency
 617 // All fabs() callers should call this function instead, which will implicitly
 618 // convert the operand to double, avoiding a dependency on __fabsf which
 619 // doesn't exist in early versions of Solaris 8.
 620 inline double fabsd(double value) {
 621   return fabs(value);
 622 }
 623 
 624 // Returns numerator/denominator as percentage value from 0 to 100. If denominator
 625 // is zero, return 0.0.
 626 template<typename T>
 627 inline double percent_of(T numerator, T denominator) {
 628   return denominator != 0 ? (double)numerator / (double)denominator * 100.0 : 0.0;
 629 }
 630 
 631 //----------------------------------------------------------------------------------------------------
 632 // Special casts

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

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

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

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

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

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

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

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

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

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

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

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

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