Mercurial > hg > truffle
comparison src/share/vm/opto/type.hpp @ 17731:62825ea7e51f
8031754: Type speculation should favor profile data from outermost inlined method
Summary: favor profile data coming from outer most method
Reviewed-by: kvn, twisti
author | roland |
---|---|
date | Fri, 14 Mar 2014 17:15:32 +0100 |
parents | 085b304a1cc5 |
children | 9ab9f254cfe2 |
comparison
equal
deleted
inserted
replaced
17728:b8413a9cbb84 | 17731:62825ea7e51f |
---|---|
413 static const Type* make_from_constant(ciConstant constant, | 413 static const Type* make_from_constant(ciConstant constant, |
414 bool require_constant = false, | 414 bool require_constant = false, |
415 bool is_autobox_cache = false); | 415 bool is_autobox_cache = false); |
416 | 416 |
417 // Speculative type. See TypeInstPtr | 417 // Speculative type. See TypeInstPtr |
418 virtual const TypeOopPtr* speculative() const { return NULL; } | |
418 virtual ciKlass* speculative_type() const { return NULL; } | 419 virtual ciKlass* speculative_type() const { return NULL; } |
419 const Type* maybe_remove_speculative(bool include_speculative) const; | 420 const Type* maybe_remove_speculative(bool include_speculative) const; |
420 virtual const Type* remove_speculative() const { return this; } | 421 virtual const Type* remove_speculative() const { return this; } |
422 | |
423 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { | |
424 return exact_kls != NULL; | |
425 } | |
421 | 426 |
422 private: | 427 private: |
423 // support arrays | 428 // support arrays |
424 static const BasicType _basic_type[]; | 429 static const BasicType _basic_type[]; |
425 static const Type* _zero_type[T_CONFLICT+1]; | 430 static const Type* _zero_type[T_CONFLICT+1]; |
840 | 845 |
841 //------------------------------TypeOopPtr------------------------------------- | 846 //------------------------------TypeOopPtr------------------------------------- |
842 // Some kind of oop (Java pointer), either klass or instance or array. | 847 // Some kind of oop (Java pointer), either klass or instance or array. |
843 class TypeOopPtr : public TypePtr { | 848 class TypeOopPtr : public TypePtr { |
844 protected: | 849 protected: |
845 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative); | 850 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth); |
846 public: | 851 public: |
847 virtual bool eq( const Type *t ) const; | 852 virtual bool eq( const Type *t ) const; |
848 virtual int hash() const; // Type specific hashing | 853 virtual int hash() const; // Type specific hashing |
849 virtual bool singleton(void) const; // TRUE if type is a singleton | 854 virtual bool singleton(void) const; // TRUE if type is a singleton |
850 enum { | 855 enum { |
851 InstanceTop = -1, // undefined instance | 856 InstanceTop = -1, // undefined instance |
852 InstanceBot = 0 // any possible instance | 857 InstanceBot = 0 // any possible instance |
853 }; | 858 }; |
854 protected: | 859 protected: |
855 | 860 |
861 enum { | |
862 InlineDepthBottom = INT_MAX, | |
863 InlineDepthTop = -InlineDepthBottom | |
864 }; | |
856 // Oop is NULL, unless this is a constant oop. | 865 // Oop is NULL, unless this is a constant oop. |
857 ciObject* _const_oop; // Constant oop | 866 ciObject* _const_oop; // Constant oop |
858 // If _klass is NULL, then so is _sig. This is an unloaded klass. | 867 // If _klass is NULL, then so is _sig. This is an unloaded klass. |
859 ciKlass* _klass; // Klass object | 868 ciKlass* _klass; // Klass object |
860 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) | 869 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) |
871 // Extra type information profiling gave us. We propagate it the | 880 // Extra type information profiling gave us. We propagate it the |
872 // same way the rest of the type info is propagated. If we want to | 881 // same way the rest of the type info is propagated. If we want to |
873 // use it, then we have to emit a guard: this part of the type is | 882 // use it, then we have to emit a guard: this part of the type is |
874 // not something we know but something we speculate about the type. | 883 // not something we know but something we speculate about the type. |
875 const TypeOopPtr* _speculative; | 884 const TypeOopPtr* _speculative; |
885 // For speculative types, we record at what inlining depth the | |
886 // profiling point that provided the data is. We want to favor | |
887 // profile data coming from outer scopes which are likely better for | |
888 // the current compilation. | |
889 int _inline_depth; | |
876 | 890 |
877 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact); | 891 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact); |
878 | 892 |
879 int dual_instance_id() const; | 893 int dual_instance_id() const; |
880 int meet_instance_id(int uid) const; | 894 int meet_instance_id(int uid) const; |
885 bool eq_speculative(const TypeOopPtr* other) const; | 899 bool eq_speculative(const TypeOopPtr* other) const; |
886 int hash_speculative() const; | 900 int hash_speculative() const; |
887 const TypeOopPtr* add_offset_speculative(intptr_t offset) const; | 901 const TypeOopPtr* add_offset_speculative(intptr_t offset) const; |
888 #ifndef PRODUCT | 902 #ifndef PRODUCT |
889 void dump_speculative(outputStream *st) const; | 903 void dump_speculative(outputStream *st) const; |
904 #endif | |
905 // utility methods to work on the inline depth of the type | |
906 int dual_inline_depth() const; | |
907 int meet_inline_depth(int depth) const; | |
908 #ifndef PRODUCT | |
909 void dump_inline_depth(outputStream *st) const; | |
890 #endif | 910 #endif |
891 | 911 |
892 // Do not allow interface-vs.-noninterface joins to collapse to top. | 912 // Do not allow interface-vs.-noninterface joins to collapse to top. |
893 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; | 913 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; |
894 | 914 |
916 static const TypeOopPtr* make_from_constant(ciObject* o, | 936 static const TypeOopPtr* make_from_constant(ciObject* o, |
917 bool require_constant = false, | 937 bool require_constant = false, |
918 bool not_null_elements = false); | 938 bool not_null_elements = false); |
919 | 939 |
920 // Make a generic (unclassed) pointer to an oop. | 940 // Make a generic (unclassed) pointer to an oop. |
921 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative); | 941 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom); |
922 | 942 |
923 ciObject* const_oop() const { return _const_oop; } | 943 ciObject* const_oop() const { return _const_oop; } |
924 virtual ciKlass* klass() const { return _klass; } | 944 virtual ciKlass* klass() const { return _klass; } |
925 bool klass_is_exact() const { return _klass_is_exact; } | 945 bool klass_is_exact() const { return _klass_is_exact; } |
926 | 946 |
930 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; } | 950 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; } |
931 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; } | 951 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; } |
932 bool is_known_instance() const { return _instance_id > 0; } | 952 bool is_known_instance() const { return _instance_id > 0; } |
933 int instance_id() const { return _instance_id; } | 953 int instance_id() const { return _instance_id; } |
934 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; } | 954 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; } |
935 const TypeOopPtr* speculative() const { return _speculative; } | 955 virtual const TypeOopPtr* speculative() const { return _speculative; } |
936 | 956 |
937 virtual intptr_t get_con() const; | 957 virtual intptr_t get_con() const; |
938 | 958 |
939 virtual const Type *cast_to_ptr_type(PTR ptr) const; | 959 virtual const Type *cast_to_ptr_type(PTR ptr) const; |
940 | 960 |
963 // Return the speculative type if any | 983 // Return the speculative type if any |
964 ciKlass* speculative_type() const { | 984 ciKlass* speculative_type() const { |
965 if (_speculative != NULL) { | 985 if (_speculative != NULL) { |
966 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr(); | 986 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr(); |
967 if (speculative->klass_is_exact()) { | 987 if (speculative->klass_is_exact()) { |
968 return speculative->klass(); | 988 return speculative->klass(); |
969 } | 989 } |
970 } | 990 } |
971 return NULL; | 991 return NULL; |
972 } | 992 } |
993 int inline_depth() const { | |
994 return _inline_depth; | |
995 } | |
996 virtual const TypeOopPtr* with_inline_depth(int depth) const; | |
997 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const; | |
973 }; | 998 }; |
974 | 999 |
975 //------------------------------TypeInstPtr------------------------------------ | 1000 //------------------------------TypeInstPtr------------------------------------ |
976 // Class of Java object pointers, pointing either to non-array Java instances | 1001 // Class of Java object pointers, pointing either to non-array Java instances |
977 // or to a Klass* (including array klasses). | 1002 // or to a Klass* (including array klasses). |
978 class TypeInstPtr : public TypeOopPtr { | 1003 class TypeInstPtr : public TypeOopPtr { |
979 TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative); | 1004 TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth); |
980 virtual bool eq( const Type *t ) const; | 1005 virtual bool eq( const Type *t ) const; |
981 virtual int hash() const; // Type specific hashing | 1006 virtual int hash() const; // Type specific hashing |
982 | 1007 |
983 ciSymbol* _name; // class name | 1008 ciSymbol* _name; // class name |
984 | 1009 |
1010 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) { | 1035 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) { |
1011 return make(ptr, klass, false, NULL, offset, InstanceBot); | 1036 return make(ptr, klass, false, NULL, offset, InstanceBot); |
1012 } | 1037 } |
1013 | 1038 |
1014 // Make a pointer to an oop. | 1039 // Make a pointer to an oop. |
1015 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL); | 1040 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom); |
1016 | 1041 |
1017 /** Create constant type for a constant boxed value */ | 1042 /** Create constant type for a constant boxed value */ |
1018 const Type* get_const_boxed_value() const; | 1043 const Type* get_const_boxed_value() const; |
1019 | 1044 |
1020 // If this is a java.lang.Class constant, return the type for it or NULL. | 1045 // If this is a java.lang.Class constant, return the type for it or NULL. |
1029 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; | 1054 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; |
1030 | 1055 |
1031 virtual const TypePtr *add_offset( intptr_t offset ) const; | 1056 virtual const TypePtr *add_offset( intptr_t offset ) const; |
1032 // Return same type without a speculative part | 1057 // Return same type without a speculative part |
1033 virtual const Type* remove_speculative() const; | 1058 virtual const Type* remove_speculative() const; |
1059 virtual const TypeOopPtr* with_inline_depth(int depth) const; | |
1034 | 1060 |
1035 // the core of the computation of the meet of 2 types | 1061 // the core of the computation of the meet of 2 types |
1036 virtual const Type *xmeet_helper(const Type *t) const; | 1062 virtual const Type *xmeet_helper(const Type *t) const; |
1037 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; | 1063 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; |
1038 virtual const Type *xdual() const; // Compute dual right now. | 1064 virtual const Type *xdual() const; // Compute dual right now. |
1050 | 1076 |
1051 //------------------------------TypeAryPtr------------------------------------- | 1077 //------------------------------TypeAryPtr------------------------------------- |
1052 // Class of Java array pointers | 1078 // Class of Java array pointers |
1053 class TypeAryPtr : public TypeOopPtr { | 1079 class TypeAryPtr : public TypeOopPtr { |
1054 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, | 1080 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, |
1055 int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative) | 1081 int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative, int inline_depth) |
1056 : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative), | 1082 : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth), |
1057 _ary(ary), | 1083 _ary(ary), |
1058 _is_autobox_cache(is_autobox_cache) | 1084 _is_autobox_cache(is_autobox_cache) |
1059 { | 1085 { |
1060 #ifdef ASSERT | 1086 #ifdef ASSERT |
1061 if (k != NULL) { | 1087 if (k != NULL) { |
1089 const TypeInt* size() const { return _ary->_size; } | 1115 const TypeInt* size() const { return _ary->_size; } |
1090 bool is_stable() const { return _ary->_stable; } | 1116 bool is_stable() const { return _ary->_stable; } |
1091 | 1117 |
1092 bool is_autobox_cache() const { return _is_autobox_cache; } | 1118 bool is_autobox_cache() const { return _is_autobox_cache; } |
1093 | 1119 |
1094 static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL); | 1120 static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom); |
1095 // Constant pointer to array | 1121 // Constant pointer to array |
1096 static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, bool is_autobox_cache = false); | 1122 static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom, bool is_autobox_cache= false); |
1097 | 1123 |
1098 // Return a 'ptr' version of this type | 1124 // Return a 'ptr' version of this type |
1099 virtual const Type *cast_to_ptr_type(PTR ptr) const; | 1125 virtual const Type *cast_to_ptr_type(PTR ptr) const; |
1100 | 1126 |
1101 virtual const Type *cast_to_exactness(bool klass_is_exact) const; | 1127 virtual const Type *cast_to_exactness(bool klass_is_exact) const; |
1107 | 1133 |
1108 virtual bool empty(void) const; // TRUE if type is vacuous | 1134 virtual bool empty(void) const; // TRUE if type is vacuous |
1109 virtual const TypePtr *add_offset( intptr_t offset ) const; | 1135 virtual const TypePtr *add_offset( intptr_t offset ) const; |
1110 // Return same type without a speculative part | 1136 // Return same type without a speculative part |
1111 virtual const Type* remove_speculative() const; | 1137 virtual const Type* remove_speculative() const; |
1138 virtual const TypeOopPtr* with_inline_depth(int depth) const; | |
1112 | 1139 |
1113 // the core of the computation of the meet of 2 types | 1140 // the core of the computation of the meet of 2 types |
1114 virtual const Type *xmeet_helper(const Type *t) const; | 1141 virtual const Type *xmeet_helper(const Type *t) const; |
1115 virtual const Type *xdual() const; // Compute dual right now. | 1142 virtual const Type *xdual() const; // Compute dual right now. |
1116 | 1143 |