comparison src/share/vm/opto/type.hpp @ 14512:484a359ff649

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, 28 Feb 2014 13:44:16 +0100
parents cd5d10655495
children 4ca6dc0799b6
comparison
equal deleted inserted replaced
14511:7e8e4d1a41d6 14512:484a359ff649
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];
843 848
844 //------------------------------TypeOopPtr------------------------------------- 849 //------------------------------TypeOopPtr-------------------------------------
845 // Some kind of oop (Java pointer), either klass or instance or array. 850 // Some kind of oop (Java pointer), either klass or instance or array.
846 class TypeOopPtr : public TypePtr { 851 class TypeOopPtr : public TypePtr {
847 protected: 852 protected:
848 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative); 853 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth);
849 public: 854 public:
850 virtual bool eq( const Type *t ) const; 855 virtual bool eq( const Type *t ) const;
851 virtual int hash() const; // Type specific hashing 856 virtual int hash() const; // Type specific hashing
852 virtual bool singleton(void) const; // TRUE if type is a singleton 857 virtual bool singleton(void) const; // TRUE if type is a singleton
853 enum { 858 enum {
854 InstanceTop = -1, // undefined instance 859 InstanceTop = -1, // undefined instance
855 InstanceBot = 0 // any possible instance 860 InstanceBot = 0 // any possible instance
856 }; 861 };
857 protected: 862 protected:
858 863
864 enum {
865 InlineDepthBottom = INT_MAX,
866 InlineDepthTop = -InlineDepthBottom
867 };
859 // Oop is NULL, unless this is a constant oop. 868 // Oop is NULL, unless this is a constant oop.
860 ciObject* _const_oop; // Constant oop 869 ciObject* _const_oop; // Constant oop
861 // If _klass is NULL, then so is _sig. This is an unloaded klass. 870 // If _klass is NULL, then so is _sig. This is an unloaded klass.
862 ciKlass* _klass; // Klass object 871 ciKlass* _klass; // Klass object
863 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) 872 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
874 // Extra type information profiling gave us. We propagate it the 883 // Extra type information profiling gave us. We propagate it the
875 // same way the rest of the type info is propagated. If we want to 884 // same way the rest of the type info is propagated. If we want to
876 // use it, then we have to emit a guard: this part of the type is 885 // use it, then we have to emit a guard: this part of the type is
877 // not something we know but something we speculate about the type. 886 // not something we know but something we speculate about the type.
878 const TypeOopPtr* _speculative; 887 const TypeOopPtr* _speculative;
888 // For speculative types, we record at what inlining depth the
889 // profiling point that provided the data is. We want to favor
890 // profile data coming from outer scopes which are likely better for
891 // the current compilation.
892 int _inline_depth;
879 893
880 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact); 894 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
881 895
882 int dual_instance_id() const; 896 int dual_instance_id() const;
883 int meet_instance_id(int uid) const; 897 int meet_instance_id(int uid) const;
888 bool eq_speculative(const TypeOopPtr* other) const; 902 bool eq_speculative(const TypeOopPtr* other) const;
889 int hash_speculative() const; 903 int hash_speculative() const;
890 const TypeOopPtr* add_offset_speculative(intptr_t offset) const; 904 const TypeOopPtr* add_offset_speculative(intptr_t offset) const;
891 #ifndef PRODUCT 905 #ifndef PRODUCT
892 void dump_speculative(outputStream *st) const; 906 void dump_speculative(outputStream *st) const;
907 #endif
908 // utility methods to work on the inline depth of the type
909 int dual_inline_depth() const;
910 int meet_inline_depth(int depth) const;
911 #ifndef PRODUCT
912 void dump_inline_depth(outputStream *st) const;
893 #endif 913 #endif
894 914
895 // Do not allow interface-vs.-noninterface joins to collapse to top. 915 // Do not allow interface-vs.-noninterface joins to collapse to top.
896 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; 916 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
897 917
919 static const TypeOopPtr* make_from_constant(ciObject* o, 939 static const TypeOopPtr* make_from_constant(ciObject* o,
920 bool require_constant = false, 940 bool require_constant = false,
921 bool not_null_elements = false); 941 bool not_null_elements = false);
922 942
923 // Make a generic (unclassed) pointer to an oop. 943 // Make a generic (unclassed) pointer to an oop.
924 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative); 944 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom);
925 945
926 ciObject* const_oop() const { return _const_oop; } 946 ciObject* const_oop() const { return _const_oop; }
927 virtual ciKlass* klass() const { return _klass; } 947 virtual ciKlass* klass() const { return _klass; }
928 bool klass_is_exact() const { return _klass_is_exact; } 948 bool klass_is_exact() const { return _klass_is_exact; }
929 949
933 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; } 953 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
934 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; } 954 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; }
935 bool is_known_instance() const { return _instance_id > 0; } 955 bool is_known_instance() const { return _instance_id > 0; }
936 int instance_id() const { return _instance_id; } 956 int instance_id() const { return _instance_id; }
937 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; } 957 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
938 const TypeOopPtr* speculative() const { return _speculative; } 958 virtual const TypeOopPtr* speculative() const { return _speculative; }
939 959
940 virtual intptr_t get_con() const; 960 virtual intptr_t get_con() const;
941 961
942 virtual const Type *cast_to_ptr_type(PTR ptr) const; 962 virtual const Type *cast_to_ptr_type(PTR ptr) const;
943 963
966 // Return the speculative type if any 986 // Return the speculative type if any
967 ciKlass* speculative_type() const { 987 ciKlass* speculative_type() const {
968 if (_speculative != NULL) { 988 if (_speculative != NULL) {
969 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr(); 989 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr();
970 if (speculative->klass_is_exact()) { 990 if (speculative->klass_is_exact()) {
971 return speculative->klass(); 991 return speculative->klass();
972 } 992 }
973 } 993 }
974 return NULL; 994 return NULL;
975 } 995 }
996 int inline_depth() const {
997 return _inline_depth;
998 }
999 virtual const TypeOopPtr* with_inline_depth(int depth) const;
1000 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
976 }; 1001 };
977 1002
978 //------------------------------TypeInstPtr------------------------------------ 1003 //------------------------------TypeInstPtr------------------------------------
979 // Class of Java object pointers, pointing either to non-array Java instances 1004 // Class of Java object pointers, pointing either to non-array Java instances
980 // or to a Klass* (including array klasses). 1005 // or to a Klass* (including array klasses).
981 class TypeInstPtr : public TypeOopPtr { 1006 class TypeInstPtr : public TypeOopPtr {
982 TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative); 1007 TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth);
983 virtual bool eq( const Type *t ) const; 1008 virtual bool eq( const Type *t ) const;
984 virtual int hash() const; // Type specific hashing 1009 virtual int hash() const; // Type specific hashing
985 1010
986 ciSymbol* _name; // class name 1011 ciSymbol* _name; // class name
987 1012
1013 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) { 1038 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1014 return make(ptr, klass, false, NULL, offset, InstanceBot); 1039 return make(ptr, klass, false, NULL, offset, InstanceBot);
1015 } 1040 }
1016 1041
1017 // Make a pointer to an oop. 1042 // Make a pointer to an oop.
1018 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL); 1043 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);
1019 1044
1020 /** Create constant type for a constant boxed value */ 1045 /** Create constant type for a constant boxed value */
1021 const Type* get_const_boxed_value() const; 1046 const Type* get_const_boxed_value() const;
1022 1047
1023 // If this is a java.lang.Class constant, return the type for it or NULL. 1048 // If this is a java.lang.Class constant, return the type for it or NULL.
1032 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; 1057 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1033 1058
1034 virtual const TypePtr *add_offset( intptr_t offset ) const; 1059 virtual const TypePtr *add_offset( intptr_t offset ) const;
1035 // Return same type without a speculative part 1060 // Return same type without a speculative part
1036 virtual const Type* remove_speculative() const; 1061 virtual const Type* remove_speculative() const;
1062 virtual const TypeOopPtr* with_inline_depth(int depth) const;
1037 1063
1038 // the core of the computation of the meet of 2 types 1064 // the core of the computation of the meet of 2 types
1039 virtual const Type *xmeet_helper(const Type *t) const; 1065 virtual const Type *xmeet_helper(const Type *t) const;
1040 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; 1066 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1041 virtual const Type *xdual() const; // Compute dual right now. 1067 virtual const Type *xdual() const; // Compute dual right now.
1053 1079
1054 //------------------------------TypeAryPtr------------------------------------- 1080 //------------------------------TypeAryPtr-------------------------------------
1055 // Class of Java array pointers 1081 // Class of Java array pointers
1056 class TypeAryPtr : public TypeOopPtr { 1082 class TypeAryPtr : public TypeOopPtr {
1057 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, 1083 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1058 int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative) 1084 int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative, int inline_depth)
1059 : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative), 1085 : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth),
1060 _ary(ary), 1086 _ary(ary),
1061 _is_autobox_cache(is_autobox_cache) 1087 _is_autobox_cache(is_autobox_cache)
1062 { 1088 {
1063 #ifdef ASSERT 1089 #ifdef ASSERT
1064 if (k != NULL) { 1090 if (k != NULL) {
1092 const TypeInt* size() const { return _ary->_size; } 1118 const TypeInt* size() const { return _ary->_size; }
1093 bool is_stable() const { return _ary->_stable; } 1119 bool is_stable() const { return _ary->_stable; }
1094 1120
1095 bool is_autobox_cache() const { return _is_autobox_cache; } 1121 bool is_autobox_cache() const { return _is_autobox_cache; }
1096 1122
1097 static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL); 1123 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);
1098 // Constant pointer to array 1124 // Constant pointer to array
1099 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); 1125 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);
1100 1126
1101 // Return a 'ptr' version of this type 1127 // Return a 'ptr' version of this type
1102 virtual const Type *cast_to_ptr_type(PTR ptr) const; 1128 virtual const Type *cast_to_ptr_type(PTR ptr) const;
1103 1129
1104 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 1130 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1110 1136
1111 virtual bool empty(void) const; // TRUE if type is vacuous 1137 virtual bool empty(void) const; // TRUE if type is vacuous
1112 virtual const TypePtr *add_offset( intptr_t offset ) const; 1138 virtual const TypePtr *add_offset( intptr_t offset ) const;
1113 // Return same type without a speculative part 1139 // Return same type without a speculative part
1114 virtual const Type* remove_speculative() const; 1140 virtual const Type* remove_speculative() const;
1141 virtual const TypeOopPtr* with_inline_depth(int depth) const;
1115 1142
1116 // the core of the computation of the meet of 2 types 1143 // the core of the computation of the meet of 2 types
1117 virtual const Type *xmeet_helper(const Type *t) const; 1144 virtual const Type *xmeet_helper(const Type *t) const;
1118 virtual const Type *xdual() const; // Compute dual right now. 1145 virtual const Type *xdual() const; // Compute dual right now.
1119 1146