< prev index next >

src/hotspot/share/utilities/globalDefinitions.hpp

Print this page

 606 #ifdef CPU_MULTI_COPY_ATOMIC
 607 // Not needed.
 608 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = false;
 609 #else
 610 // From all non-multi-copy-atomic architectures, only PPC64 supports IRIW at the moment.
 611 // Final decision is subject to JEP 188: Java Memory Model Update.
 612 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = PPC64_ONLY(true) NOT_PPC64(false);
 613 #endif
 614 
 615 // The expected size in bytes of a cache line.
 616 #ifndef DEFAULT_CACHE_LINE_SIZE
 617 #error "Platform should define DEFAULT_CACHE_LINE_SIZE"
 618 #endif
 619 
 620 // The default padding size for data structures to avoid false sharing.
 621 #ifndef DEFAULT_PADDING_SIZE
 622 #error "Platform should define DEFAULT_PADDING_SIZE"
 623 #endif
 624 
 625 









 626 //----------------------------------------------------------------------------------------------------
 627 // Miscellaneous
 628 
 629 // 6302670 Eliminate Hotspot __fabsf dependency
 630 // All fabs() callers should call this function instead, which will implicitly
 631 // convert the operand to double, avoiding a dependency on __fabsf which
 632 // doesn't exist in early versions of Solaris 8.
 633 inline double fabsd(double value) {
 634   return fabs(value);
 635 }
 636 
 637 // Returns numerator/denominator as percentage value from 0 to 100. If denominator
 638 // is zero, return 0.0.
 639 template<typename T>
 640 inline double percent_of(T numerator, T denominator) {
 641   return denominator != 0 ? (double)numerator / (double)denominator * 100.0 : 0.0;
 642 }
 643 
 644 //----------------------------------------------------------------------------------------------------
 645 // Special casts

 691 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
 692 enum BasicType : u1 {
 693 // The values T_BOOLEAN..T_LONG (4..11) are derived from the JVMS.
 694   T_BOOLEAN     = JVM_T_BOOLEAN,
 695   T_CHAR        = JVM_T_CHAR,
 696   T_FLOAT       = JVM_T_FLOAT,
 697   T_DOUBLE      = JVM_T_DOUBLE,
 698   T_BYTE        = JVM_T_BYTE,
 699   T_SHORT       = JVM_T_SHORT,
 700   T_INT         = JVM_T_INT,
 701   T_LONG        = JVM_T_LONG,
 702   // The remaining values are not part of any standard.
 703   // T_OBJECT and T_VOID denote two more semantic choices
 704   // for method return values.
 705   // T_OBJECT and T_ARRAY describe signature syntax.
 706   // T_ADDRESS, T_METADATA, T_NARROWOOP, T_NARROWKLASS describe
 707   // internal references within the JVM as if they were Java
 708   // types in their own right.
 709   T_OBJECT      = 12,
 710   T_ARRAY       = 13,
 711   T_VOID        = 14,
 712   T_ADDRESS     = 15,
 713   T_NARROWOOP   = 16,
 714   T_METADATA    = 17,
 715   T_NARROWKLASS = 18,
 716   T_CONFLICT    = 19, // for stack value type with conflicting contents

 717   T_ILLEGAL     = 99
 718 };
 719 
 720 #define SIGNATURE_TYPES_DO(F, N)                \
 721     F(JVM_SIGNATURE_BOOLEAN, T_BOOLEAN, N)      \
 722     F(JVM_SIGNATURE_CHAR,    T_CHAR,    N)      \
 723     F(JVM_SIGNATURE_FLOAT,   T_FLOAT,   N)      \
 724     F(JVM_SIGNATURE_DOUBLE,  T_DOUBLE,  N)      \
 725     F(JVM_SIGNATURE_BYTE,    T_BYTE,    N)      \
 726     F(JVM_SIGNATURE_SHORT,   T_SHORT,   N)      \
 727     F(JVM_SIGNATURE_INT,     T_INT,     N)      \
 728     F(JVM_SIGNATURE_LONG,    T_LONG,    N)      \
 729     F(JVM_SIGNATURE_CLASS,   T_OBJECT,  N)      \
 730     F(JVM_SIGNATURE_ARRAY,   T_ARRAY,   N)      \

 731     F(JVM_SIGNATURE_VOID,    T_VOID,    N)      \
 732     /*end*/
 733 
 734 inline bool is_java_type(BasicType t) {
 735   return T_BOOLEAN <= t && t <= T_VOID;
 736 }
 737 
 738 inline bool is_java_primitive(BasicType t) {
 739   return T_BOOLEAN <= t && t <= T_LONG;
 740 }
 741 
 742 inline bool is_subword_type(BasicType t) {
 743   // these guys are processed exactly like T_INT in calling sequences:
 744   return (t == T_BOOLEAN || t == T_CHAR || t == T_BYTE || t == T_SHORT);
 745 }
 746 
 747 inline bool is_signed_subword_type(BasicType t) {
 748   return (t == T_BYTE || t == T_SHORT);
 749 }
 750 
 751 inline bool is_unsigned_subword_type(BasicType t) {
 752   return (t == T_BOOLEAN || t == T_CHAR);
 753 }
 754 
 755 inline bool is_double_word_type(BasicType t) {
 756   return (t == T_DOUBLE || t == T_LONG);
 757 }
 758 
 759 inline bool is_reference_type(BasicType t, bool include_narrow_oop = false) {
 760   return (t == T_OBJECT || t == T_ARRAY || (include_narrow_oop && t == T_NARROWOOP));
 761 }
 762 
 763 inline bool is_integral_type(BasicType t) {
 764   return is_subword_type(t) || t == T_INT || t == T_LONG;
 765 }
 766 
 767 inline bool is_non_subword_integral_type(BasicType t) {
 768   return t == T_INT || t == T_LONG;
 769 }
 770 
 771 inline bool is_floating_point_type(BasicType t) {
 772   return (t == T_FLOAT || t == T_DOUBLE);
 773 }
 774 
 775 extern char type2char_tab[T_CONFLICT+1];     // Map a BasicType to a jchar
 776 inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; }
 777 extern int type2size[T_CONFLICT+1];         // Map BasicType to result stack elements
 778 extern const char* type2name_tab[T_CONFLICT+1];     // Map a BasicType to a char*
 779 extern BasicType name2type(const char* name);
 780 

 806 
 807 // Auxiliary math routines
 808 // least common multiple
 809 extern size_t lcm(size_t a, size_t b);
 810 
 811 
 812 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
 813 enum BasicTypeSize {
 814   T_BOOLEAN_size     = 1,
 815   T_CHAR_size        = 1,
 816   T_FLOAT_size       = 1,
 817   T_DOUBLE_size      = 2,
 818   T_BYTE_size        = 1,
 819   T_SHORT_size       = 1,
 820   T_INT_size         = 1,
 821   T_LONG_size        = 2,
 822   T_OBJECT_size      = 1,
 823   T_ARRAY_size       = 1,
 824   T_NARROWOOP_size   = 1,
 825   T_NARROWKLASS_size = 1,
 826   T_VOID_size        = 0

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

 856 #else
 857   T_OBJECT_aelem_bytes      = 4,
 858   T_ARRAY_aelem_bytes       = 4,

 859 #endif
 860   T_NARROWOOP_aelem_bytes   = 4,
 861   T_NARROWKLASS_aelem_bytes = 4,
 862   T_VOID_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 {

 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 }

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

 700 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
 701 enum BasicType : u1 {
 702 // The values T_BOOLEAN..T_LONG (4..11) are derived from the JVMS.
 703   T_BOOLEAN     = JVM_T_BOOLEAN,
 704   T_CHAR        = JVM_T_CHAR,
 705   T_FLOAT       = JVM_T_FLOAT,
 706   T_DOUBLE      = JVM_T_DOUBLE,
 707   T_BYTE        = JVM_T_BYTE,
 708   T_SHORT       = JVM_T_SHORT,
 709   T_INT         = JVM_T_INT,
 710   T_LONG        = JVM_T_LONG,
 711   // The remaining values are not part of any standard.
 712   // T_OBJECT and T_VOID denote two more semantic choices
 713   // for method return values.
 714   // T_OBJECT and T_ARRAY describe signature syntax.
 715   // T_ADDRESS, T_METADATA, T_NARROWOOP, T_NARROWKLASS describe
 716   // internal references within the JVM as if they were Java
 717   // types in their own right.
 718   T_OBJECT      = 12,
 719   T_ARRAY       = 13,
 720   T_FLAT_ELEMENT = 14, // Not a true BasicType, only use in headers of flat arrays
 721   T_VOID        = 15,
 722   T_ADDRESS     = 16,
 723   T_NARROWOOP   = 17,
 724   T_METADATA    = 18,
 725   T_NARROWKLASS = 19,
 726   T_CONFLICT    = 20, // for stack value type with conflicting contents
 727   T_ILLEGAL     = 99
 728 };
 729 
 730 #define SIGNATURE_TYPES_DO(F, N)                \
 731     F(JVM_SIGNATURE_BOOLEAN, T_BOOLEAN, N)      \
 732     F(JVM_SIGNATURE_CHAR,    T_CHAR,    N)      \
 733     F(JVM_SIGNATURE_FLOAT,   T_FLOAT,   N)      \
 734     F(JVM_SIGNATURE_DOUBLE,  T_DOUBLE,  N)      \
 735     F(JVM_SIGNATURE_BYTE,    T_BYTE,    N)      \
 736     F(JVM_SIGNATURE_SHORT,   T_SHORT,   N)      \
 737     F(JVM_SIGNATURE_INT,     T_INT,     N)      \
 738     F(JVM_SIGNATURE_LONG,    T_LONG,    N)      \
 739     F(JVM_SIGNATURE_CLASS,   T_OBJECT,  N)      \
 740     F(JVM_SIGNATURE_ARRAY,   T_ARRAY,   N)      \
 741     F(JVM_SIGNATURE_FLAT_ELEMENT, T_FLAT_ELEMENT, N) \
 742     F(JVM_SIGNATURE_VOID,    T_VOID,    N)      \
 743     /*end*/
 744 
 745 inline bool is_java_type(BasicType t) {
 746   return T_BOOLEAN <= t && t <= T_VOID;
 747 }
 748 
 749 inline bool is_java_primitive(BasicType t) {
 750   return T_BOOLEAN <= t && t <= T_LONG;
 751 }
 752 
 753 inline bool is_subword_type(BasicType t) {
 754   // these guys are processed exactly like T_INT in calling sequences:
 755   return (t == T_BOOLEAN || t == T_CHAR || t == T_BYTE || t == T_SHORT);
 756 }
 757 
 758 inline bool is_signed_subword_type(BasicType t) {
 759   return (t == T_BYTE || t == T_SHORT);
 760 }
 761 
 762 inline bool is_unsigned_subword_type(BasicType t) {
 763   return (t == T_BOOLEAN || t == T_CHAR);
 764 }
 765 
 766 inline bool is_double_word_type(BasicType t) {
 767   return (t == T_DOUBLE || t == T_LONG);
 768 }
 769 
 770 inline bool is_reference_type(BasicType t, bool include_narrow_oop = false) {
 771   return (t == T_OBJECT || t == T_ARRAY || t == T_FLAT_ELEMENT || (include_narrow_oop && t == T_NARROWOOP));
 772 }
 773 
 774 inline bool is_integral_type(BasicType t) {
 775   return is_subword_type(t) || t == T_INT || t == T_LONG;
 776 }
 777 
 778 inline bool is_non_subword_integral_type(BasicType t) {
 779   return t == T_INT || t == T_LONG;
 780 }
 781 
 782 inline bool is_floating_point_type(BasicType t) {
 783   return (t == T_FLOAT || t == T_DOUBLE);
 784 }
 785 
 786 extern char type2char_tab[T_CONFLICT+1];     // Map a BasicType to a jchar
 787 inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; }
 788 extern int type2size[T_CONFLICT+1];         // Map BasicType to result stack elements
 789 extern const char* type2name_tab[T_CONFLICT+1];     // Map a BasicType to a char*
 790 extern BasicType name2type(const char* name);
 791 

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

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