< prev index next >

src/hotspot/share/utilities/globalDefinitions.hpp

Print this page

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









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

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

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

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

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

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

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

 860 #endif
 861   T_NARROWOOP_aelem_bytes   = 4,
 862   T_NARROWKLASS_aelem_bytes = 4,
 863   T_VOID_aelem_bytes        = 0
 864 };
 865 
 866 extern int _type2aelembytes[T_CONFLICT+1]; // maps a BasicType to nof bytes used by its array element
 867 #ifdef ASSERT
 868 extern int type2aelembytes(BasicType t, bool allow_address = false); // asserts
 869 #else
 870 inline int type2aelembytes(BasicType t, bool allow_address = false) { return _type2aelembytes[t]; }
 871 #endif
 872 
 873 inline bool same_type_or_subword_size(BasicType t1, BasicType t2) {
 874   return (t1 == t2) || (is_subword_type(t1) && type2aelembytes(t1) == type2aelembytes(t2));
 875 }
 876 
 877 // JavaValue serves as a container for arbitrary Java values.
 878 
 879 class JavaValue {

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

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

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

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

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