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