592 #ifdef CPU_MULTI_COPY_ATOMIC
593 // Not needed.
594 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = false;
595 #else
596 // From all non-multi-copy-atomic architectures, only PPC64 supports IRIW at the moment.
597 // Final decision is subject to JEP 188: Java Memory Model Update.
598 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = PPC64_ONLY(true) NOT_PPC64(false);
599 #endif
600
601 // The expected size in bytes of a cache line.
602 #ifndef DEFAULT_CACHE_LINE_SIZE
603 #error "Platform should define DEFAULT_CACHE_LINE_SIZE"
604 #endif
605
606 // The default padding size for data structures to avoid false sharing.
607 #ifndef DEFAULT_PADDING_SIZE
608 #error "Platform should define DEFAULT_PADDING_SIZE"
609 #endif
610
611
612 //----------------------------------------------------------------------------------------------------
613 // Miscellaneous
614
615 // 6302670 Eliminate Hotspot __fabsf dependency
616 // All fabs() callers should call this function instead, which will implicitly
617 // convert the operand to double, avoiding a dependency on __fabsf which
618 // doesn't exist in early versions of Solaris 8.
619 inline double fabsd(double value) {
620 return fabs(value);
621 }
622
623 // Returns numerator/denominator as percentage value from 0 to 100. If denominator
624 // is zero, return 0.0.
625 template<typename T>
626 inline double percent_of(T numerator, T denominator) {
627 return denominator != 0 ? (double)numerator / (double)denominator * 100.0 : 0.0;
628 }
629
630 //----------------------------------------------------------------------------------------------------
631 // Special casts
670 enum BasicType : u1 {
671 // The values T_BOOLEAN..T_LONG (4..11) are derived from the JVMS.
672 T_BOOLEAN = JVM_T_BOOLEAN,
673 T_CHAR = JVM_T_CHAR,
674 T_FLOAT = JVM_T_FLOAT,
675 T_DOUBLE = JVM_T_DOUBLE,
676 T_BYTE = JVM_T_BYTE,
677 T_SHORT = JVM_T_SHORT,
678 T_INT = JVM_T_INT,
679 T_LONG = JVM_T_LONG,
680 // The remaining values are not part of any standard.
681 // T_OBJECT and T_VOID denote two more semantic choices
682 // for method return values.
683 // T_OBJECT and T_ARRAY describe signature syntax.
684 // T_ADDRESS, T_METADATA, T_NARROWOOP, T_NARROWKLASS describe
685 // internal references within the JVM as if they were Java
686 // types in their own right.
687 T_OBJECT = 12,
688 T_ARRAY = 13,
689 T_VOID = 14,
690 T_ADDRESS = 15,
691 T_NARROWOOP = 16,
692 T_METADATA = 17,
693 T_NARROWKLASS = 18,
694 T_CONFLICT = 19, // for stack value type with conflicting contents
695 T_ILLEGAL = 99
696 };
697
698 #define SIGNATURE_TYPES_DO(F, N) \
699 F(JVM_SIGNATURE_BOOLEAN, T_BOOLEAN, N) \
700 F(JVM_SIGNATURE_CHAR, T_CHAR, N) \
701 F(JVM_SIGNATURE_FLOAT, T_FLOAT, N) \
702 F(JVM_SIGNATURE_DOUBLE, T_DOUBLE, N) \
703 F(JVM_SIGNATURE_BYTE, T_BYTE, N) \
704 F(JVM_SIGNATURE_SHORT, T_SHORT, N) \
705 F(JVM_SIGNATURE_INT, T_INT, N) \
706 F(JVM_SIGNATURE_LONG, T_LONG, N) \
707 F(JVM_SIGNATURE_CLASS, T_OBJECT, N) \
708 F(JVM_SIGNATURE_ARRAY, T_ARRAY, N) \
709 F(JVM_SIGNATURE_VOID, T_VOID, N) \
710 /*end*/
711
712 inline bool is_java_type(BasicType t) {
713 return T_BOOLEAN <= t && t <= T_VOID;
714 }
718 }
719
720 inline bool is_subword_type(BasicType t) {
721 // these guys are processed exactly like T_INT in calling sequences:
722 return (t == T_BOOLEAN || t == T_CHAR || t == T_BYTE || t == T_SHORT);
723 }
724
725 inline bool is_signed_subword_type(BasicType t) {
726 return (t == T_BYTE || t == T_SHORT);
727 }
728
729 inline bool is_unsigned_subword_type(BasicType t) {
730 return (t == T_BOOLEAN || t == T_CHAR);
731 }
732
733 inline bool is_double_word_type(BasicType t) {
734 return (t == T_DOUBLE || t == T_LONG);
735 }
736
737 inline bool is_reference_type(BasicType t, bool include_narrow_oop = false) {
738 return (t == T_OBJECT || t == T_ARRAY || (include_narrow_oop && t == T_NARROWOOP));
739 }
740
741 inline bool is_integral_type(BasicType t) {
742 return is_subword_type(t) || t == T_INT || t == T_LONG;
743 }
744
745 inline bool is_non_subword_integral_type(BasicType t) {
746 return t == T_INT || t == T_LONG;
747 }
748
749 inline bool is_floating_point_type(BasicType t) {
750 return (t == T_FLOAT || t == T_DOUBLE);
751 }
752
753 extern char type2char_tab[T_CONFLICT+1]; // Map a BasicType to a jchar
754 inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; }
755 extern int type2size[T_CONFLICT+1]; // Map BasicType to result stack elements
756 extern const char* type2name_tab[T_CONFLICT+1]; // Map a BasicType to a char*
757 extern BasicType name2type(const char* name);
792
793 // Auxiliary math routines
794 // least common multiple
795 extern size_t lcm(size_t a, size_t b);
796
797
798 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
799 enum BasicTypeSize {
800 T_BOOLEAN_size = 1,
801 T_CHAR_size = 1,
802 T_FLOAT_size = 1,
803 T_DOUBLE_size = 2,
804 T_BYTE_size = 1,
805 T_SHORT_size = 1,
806 T_INT_size = 1,
807 T_LONG_size = 2,
808 T_OBJECT_size = 1,
809 T_ARRAY_size = 1,
810 T_NARROWOOP_size = 1,
811 T_NARROWKLASS_size = 1,
812 T_VOID_size = 0
813 };
814
815 // this works on valid parameter types but not T_VOID, T_CONFLICT, etc.
816 inline int parameter_type_word_count(BasicType t) {
817 if (is_double_word_type(t)) return 2;
818 assert(is_java_primitive(t) || is_reference_type(t), "no goofy types here please");
819 assert(type2size[t] == 1, "must be");
820 return 1;
821 }
822
823 // maps a BasicType to its instance field storage type:
824 // all sub-word integral types are widened to T_INT
825 extern BasicType type2field[T_CONFLICT+1];
826 extern BasicType type2wfield[T_CONFLICT+1];
827
828
829 // size in bytes
830 enum ArrayElementSize {
831 T_BOOLEAN_aelem_bytes = 1,
832 T_CHAR_aelem_bytes = 2,
833 T_FLOAT_aelem_bytes = 4,
834 T_DOUBLE_aelem_bytes = 8,
835 T_BYTE_aelem_bytes = 1,
836 T_SHORT_aelem_bytes = 2,
837 T_INT_aelem_bytes = 4,
838 T_LONG_aelem_bytes = 8,
839 #ifdef _LP64
840 T_OBJECT_aelem_bytes = 8,
841 T_ARRAY_aelem_bytes = 8,
842 #else
843 T_OBJECT_aelem_bytes = 4,
844 T_ARRAY_aelem_bytes = 4,
845 #endif
846 T_NARROWOOP_aelem_bytes = 4,
847 T_NARROWKLASS_aelem_bytes = 4,
848 T_VOID_aelem_bytes = 0
849 };
850
851 extern int _type2aelembytes[T_CONFLICT+1]; // maps a BasicType to nof bytes used by its array element
852 #ifdef ASSERT
853 extern int type2aelembytes(BasicType t, bool allow_address = false); // asserts
854 #else
855 inline int type2aelembytes(BasicType t, bool allow_address = false) { return _type2aelembytes[t]; }
856 #endif
857
858 inline bool same_type_or_subword_size(BasicType t1, BasicType t2) {
859 return (t1 == t2) || (is_subword_type(t1) && type2aelembytes(t1) == type2aelembytes(t2));
860 }
861
862 // JavaValue serves as a container for arbitrary Java values.
863
864 class JavaValue {
865
866 public:
867 typedef union JavaCallValue {
868 jfloat f;
918
919 // TosState describes the top-of-stack state before and after the execution of
920 // a bytecode or method. The top-of-stack value may be cached in one or more CPU
921 // registers. The TosState corresponds to the 'machine representation' of this cached
922 // value. There's 4 states corresponding to the JAVA types int, long, float & double
923 // as well as a 5th state in case the top-of-stack value is actually on the top
924 // of stack (in memory) and thus not cached. The atos state corresponds to the itos
925 // state when it comes to machine representation but is used separately for (oop)
926 // type specific operations (e.g. verification code).
927
928 enum TosState { // describes the tos cache contents
929 btos = 0, // byte, bool tos cached
930 ztos = 1, // byte, bool tos cached
931 ctos = 2, // char tos cached
932 stos = 3, // short tos cached
933 itos = 4, // int tos cached
934 ltos = 5, // long tos cached
935 ftos = 6, // float tos cached
936 dtos = 7, // double tos cached
937 atos = 8, // object cached
938 vtos = 9, // tos not cached
939 number_of_states,
940 ilgl // illegal state: should not occur
941 };
942
943
944 inline TosState as_TosState(BasicType type) {
945 switch (type) {
946 case T_BYTE : return btos;
947 case T_BOOLEAN: return ztos;
948 case T_CHAR : return ctos;
949 case T_SHORT : return stos;
950 case T_INT : return itos;
951 case T_LONG : return ltos;
952 case T_FLOAT : return ftos;
953 case T_DOUBLE : return dtos;
954 case T_VOID : return vtos;
955 case T_ARRAY : // fall through
956 case T_OBJECT : return atos;
957 default : return ilgl;
958 }
959 }
960
961 inline BasicType as_BasicType(TosState state) {
962 switch (state) {
963 case btos : return T_BYTE;
964 case ztos : return T_BOOLEAN;
965 case ctos : return T_CHAR;
966 case stos : return T_SHORT;
967 case itos : return T_INT;
968 case ltos : return T_LONG;
969 case ftos : return T_FLOAT;
970 case dtos : return T_DOUBLE;
971 case atos : return T_OBJECT;
972 case vtos : return T_VOID;
973 default : return T_ILLEGAL;
974 }
975 }
|
592 #ifdef CPU_MULTI_COPY_ATOMIC
593 // Not needed.
594 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = false;
595 #else
596 // From all non-multi-copy-atomic architectures, only PPC64 supports IRIW at the moment.
597 // Final decision is subject to JEP 188: Java Memory Model Update.
598 const bool support_IRIW_for_not_multiple_copy_atomic_cpu = PPC64_ONLY(true) NOT_PPC64(false);
599 #endif
600
601 // The expected size in bytes of a cache line.
602 #ifndef DEFAULT_CACHE_LINE_SIZE
603 #error "Platform should define DEFAULT_CACHE_LINE_SIZE"
604 #endif
605
606 // The default padding size for data structures to avoid false sharing.
607 #ifndef DEFAULT_PADDING_SIZE
608 #error "Platform should define DEFAULT_PADDING_SIZE"
609 #endif
610
611
612 //----------------------------------------------------------------------------------------------------
613 // Prototyping
614 // "Code Missing Here" macro, un-define when integrating back from prototyping stage and break
615 // compilation on purpose (i.e. "forget me not")
616 #define PROTOTYPE
617 #ifdef PROTOTYPE
618 #define CMH(m)
619 #endif
620
621 //----------------------------------------------------------------------------------------------------
622 // Miscellaneous
623
624 // 6302670 Eliminate Hotspot __fabsf dependency
625 // All fabs() callers should call this function instead, which will implicitly
626 // convert the operand to double, avoiding a dependency on __fabsf which
627 // doesn't exist in early versions of Solaris 8.
628 inline double fabsd(double value) {
629 return fabs(value);
630 }
631
632 // Returns numerator/denominator as percentage value from 0 to 100. If denominator
633 // is zero, return 0.0.
634 template<typename T>
635 inline double percent_of(T numerator, T denominator) {
636 return denominator != 0 ? (double)numerator / (double)denominator * 100.0 : 0.0;
637 }
638
639 //----------------------------------------------------------------------------------------------------
640 // Special casts
679 enum BasicType : u1 {
680 // The values T_BOOLEAN..T_LONG (4..11) are derived from the JVMS.
681 T_BOOLEAN = JVM_T_BOOLEAN,
682 T_CHAR = JVM_T_CHAR,
683 T_FLOAT = JVM_T_FLOAT,
684 T_DOUBLE = JVM_T_DOUBLE,
685 T_BYTE = JVM_T_BYTE,
686 T_SHORT = JVM_T_SHORT,
687 T_INT = JVM_T_INT,
688 T_LONG = JVM_T_LONG,
689 // The remaining values are not part of any standard.
690 // T_OBJECT and T_VOID denote two more semantic choices
691 // for method return values.
692 // T_OBJECT and T_ARRAY describe signature syntax.
693 // T_ADDRESS, T_METADATA, T_NARROWOOP, T_NARROWKLASS describe
694 // internal references within the JVM as if they were Java
695 // types in their own right.
696 T_OBJECT = 12,
697 T_ARRAY = 13,
698 T_VOID = 14,
699 T_FLAT_ELEMENT = 15, // Not a true BasicType, only used in layout helpers of flat arrays
700 T_ADDRESS = 16,
701 T_NARROWOOP = 17,
702 T_METADATA = 18,
703 T_NARROWKLASS = 19,
704 T_CONFLICT = 20, // for stack value type with conflicting contents
705 T_ILLEGAL = 99
706 };
707
708 #define SIGNATURE_TYPES_DO(F, N) \
709 F(JVM_SIGNATURE_BOOLEAN, T_BOOLEAN, N) \
710 F(JVM_SIGNATURE_CHAR, T_CHAR, N) \
711 F(JVM_SIGNATURE_FLOAT, T_FLOAT, N) \
712 F(JVM_SIGNATURE_DOUBLE, T_DOUBLE, N) \
713 F(JVM_SIGNATURE_BYTE, T_BYTE, N) \
714 F(JVM_SIGNATURE_SHORT, T_SHORT, N) \
715 F(JVM_SIGNATURE_INT, T_INT, N) \
716 F(JVM_SIGNATURE_LONG, T_LONG, N) \
717 F(JVM_SIGNATURE_CLASS, T_OBJECT, N) \
718 F(JVM_SIGNATURE_ARRAY, T_ARRAY, N) \
719 F(JVM_SIGNATURE_VOID, T_VOID, N) \
720 /*end*/
721
722 inline bool is_java_type(BasicType t) {
723 return T_BOOLEAN <= t && t <= T_VOID;
724 }
728 }
729
730 inline bool is_subword_type(BasicType t) {
731 // these guys are processed exactly like T_INT in calling sequences:
732 return (t == T_BOOLEAN || t == T_CHAR || t == T_BYTE || t == T_SHORT);
733 }
734
735 inline bool is_signed_subword_type(BasicType t) {
736 return (t == T_BYTE || t == T_SHORT);
737 }
738
739 inline bool is_unsigned_subword_type(BasicType t) {
740 return (t == T_BOOLEAN || t == T_CHAR);
741 }
742
743 inline bool is_double_word_type(BasicType t) {
744 return (t == T_DOUBLE || t == T_LONG);
745 }
746
747 inline bool is_reference_type(BasicType t, bool include_narrow_oop = false) {
748 assert(t != T_FLAT_ELEMENT, ""); // Strong assert to detect misuses of T_FLAT_ELEMENT
749 return (t == T_OBJECT || t == T_ARRAY || (include_narrow_oop && t == T_NARROWOOP));
750 }
751
752 inline bool is_integral_type(BasicType t) {
753 return is_subword_type(t) || t == T_INT || t == T_LONG;
754 }
755
756 inline bool is_non_subword_integral_type(BasicType t) {
757 return t == T_INT || t == T_LONG;
758 }
759
760 inline bool is_floating_point_type(BasicType t) {
761 return (t == T_FLOAT || t == T_DOUBLE);
762 }
763
764 extern char type2char_tab[T_CONFLICT+1]; // Map a BasicType to a jchar
765 inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; }
766 extern int type2size[T_CONFLICT+1]; // Map BasicType to result stack elements
767 extern const char* type2name_tab[T_CONFLICT+1]; // Map a BasicType to a char*
768 extern BasicType name2type(const char* name);
803
804 // Auxiliary math routines
805 // least common multiple
806 extern size_t lcm(size_t a, size_t b);
807
808
809 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/runtime/BasicType.java
810 enum BasicTypeSize {
811 T_BOOLEAN_size = 1,
812 T_CHAR_size = 1,
813 T_FLOAT_size = 1,
814 T_DOUBLE_size = 2,
815 T_BYTE_size = 1,
816 T_SHORT_size = 1,
817 T_INT_size = 1,
818 T_LONG_size = 2,
819 T_OBJECT_size = 1,
820 T_ARRAY_size = 1,
821 T_NARROWOOP_size = 1,
822 T_NARROWKLASS_size = 1,
823 T_VOID_size = 0,
824 T_FLAT_ELEMENT_size = 0
825 };
826
827 // this works on valid parameter types but not T_VOID, T_CONFLICT, etc.
828 inline int parameter_type_word_count(BasicType t) {
829 if (is_double_word_type(t)) return 2;
830 assert(is_java_primitive(t) || is_reference_type(t), "no goofy types here please");
831 assert(type2size[t] == 1, "must be");
832 return 1;
833 }
834
835 // maps a BasicType to its instance field storage type:
836 // all sub-word integral types are widened to T_INT
837 extern BasicType type2field[T_CONFLICT+1];
838 extern BasicType type2wfield[T_CONFLICT+1];
839
840
841 // size in bytes
842 enum ArrayElementSize {
843 T_BOOLEAN_aelem_bytes = 1,
844 T_CHAR_aelem_bytes = 2,
845 T_FLOAT_aelem_bytes = 4,
846 T_DOUBLE_aelem_bytes = 8,
847 T_BYTE_aelem_bytes = 1,
848 T_SHORT_aelem_bytes = 2,
849 T_INT_aelem_bytes = 4,
850 T_LONG_aelem_bytes = 8,
851 #ifdef _LP64
852 T_OBJECT_aelem_bytes = 8,
853 T_ARRAY_aelem_bytes = 8,
854 #else
855 T_OBJECT_aelem_bytes = 4,
856 T_ARRAY_aelem_bytes = 4,
857 #endif
858 T_NARROWOOP_aelem_bytes = 4,
859 T_NARROWKLASS_aelem_bytes = 4,
860 T_VOID_aelem_bytes = 0,
861 T_FLAT_ELEMENT_aelem_bytes = 0
862 };
863
864 extern int _type2aelembytes[T_CONFLICT+1]; // maps a BasicType to nof bytes used by its array element
865 #ifdef ASSERT
866 extern int type2aelembytes(BasicType t, bool allow_address = false); // asserts
867 #else
868 inline int type2aelembytes(BasicType t, bool allow_address = false) { return _type2aelembytes[t]; }
869 #endif
870
871 inline bool same_type_or_subword_size(BasicType t1, BasicType t2) {
872 return (t1 == t2) || (is_subword_type(t1) && type2aelembytes(t1) == type2aelembytes(t2));
873 }
874
875 // JavaValue serves as a container for arbitrary Java values.
876
877 class JavaValue {
878
879 public:
880 typedef union JavaCallValue {
881 jfloat f;
931
932 // TosState describes the top-of-stack state before and after the execution of
933 // a bytecode or method. The top-of-stack value may be cached in one or more CPU
934 // registers. The TosState corresponds to the 'machine representation' of this cached
935 // value. There's 4 states corresponding to the JAVA types int, long, float & double
936 // as well as a 5th state in case the top-of-stack value is actually on the top
937 // of stack (in memory) and thus not cached. The atos state corresponds to the itos
938 // state when it comes to machine representation but is used separately for (oop)
939 // type specific operations (e.g. verification code).
940
941 enum TosState { // describes the tos cache contents
942 btos = 0, // byte, bool tos cached
943 ztos = 1, // byte, bool tos cached
944 ctos = 2, // char tos cached
945 stos = 3, // short tos cached
946 itos = 4, // int tos cached
947 ltos = 5, // long tos cached
948 ftos = 6, // float tos cached
949 dtos = 7, // double tos cached
950 atos = 8, // object cached
951 vtos = 9, // tos not cached,
952 number_of_states,
953 ilgl // illegal state: should not occur
954 };
955
956
957 inline TosState as_TosState(BasicType type) {
958 switch (type) {
959 case T_BYTE : return btos;
960 case T_BOOLEAN: return ztos;
961 case T_CHAR : return ctos;
962 case T_SHORT : return stos;
963 case T_INT : return itos;
964 case T_LONG : return ltos;
965 case T_FLOAT : return ftos;
966 case T_DOUBLE : return dtos;
967 case T_VOID : return vtos;
968 case T_ARRAY : // fall through
969 case T_OBJECT : return atos;
970 default : return ilgl;
971 }
972 }
973
974 inline BasicType as_BasicType(TosState state) {
975 switch (state) {
976 case btos : return T_BYTE;
977 case ztos : return T_BOOLEAN;
978 case ctos : return T_CHAR;
979 case stos : return T_SHORT;
980 case itos : return T_INT;
981 case ltos : return T_LONG;
982 case ftos : return T_FLOAT;
983 case dtos : return T_DOUBLE;
984 case atos : return T_OBJECT;
985 case vtos : return T_VOID;
986 default : return T_ILLEGAL;
987 }
988 }
|