comparison src/share/vm/opto/type.hpp @ 17810:62c54fcc0a35

Merge
author kvn
date Tue, 25 Mar 2014 17:07:36 -0700
parents 752ba2e5f6d0 9ab9f254cfe2
children 52b4284cb496
comparison
equal deleted inserted replaced
17809:a433eb716ce1 17810:62c54fcc0a35
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];
487 TypeInt( jint lo, jint hi, int w ); 492 TypeInt( jint lo, jint hi, int w );
488 protected: 493 protected:
489 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; 494 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
490 495
491 public: 496 public:
497 typedef jint NativeType;
492 virtual bool eq( const Type *t ) const; 498 virtual bool eq( const Type *t ) const;
493 virtual int hash() const; // Type specific hashing 499 virtual int hash() const; // Type specific hashing
494 virtual bool singleton(void) const; // TRUE if type is a singleton 500 virtual bool singleton(void) const; // TRUE if type is a singleton
495 virtual bool empty(void) const; // TRUE if type is vacuous 501 virtual bool empty(void) const; // TRUE if type is vacuous
496 const jint _lo, _hi; // Lower bound, upper bound 502 const jint _lo, _hi; // Lower bound, upper bound
529 static const TypeInt *SHORT; 535 static const TypeInt *SHORT;
530 static const TypeInt *POS; 536 static const TypeInt *POS;
531 static const TypeInt *POS1; 537 static const TypeInt *POS1;
532 static const TypeInt *INT; 538 static const TypeInt *INT;
533 static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint] 539 static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
540 static const TypeInt *TYPE_DOMAIN; // alias for TypeInt::INT
541
542 static const TypeInt *as_self(const Type *t) { return t->is_int(); }
534 #ifndef PRODUCT 543 #ifndef PRODUCT
535 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 544 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
536 #endif 545 #endif
537 }; 546 };
538 547
544 TypeLong( jlong lo, jlong hi, int w ); 553 TypeLong( jlong lo, jlong hi, int w );
545 protected: 554 protected:
546 // Do not kill _widen bits. 555 // Do not kill _widen bits.
547 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; 556 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
548 public: 557 public:
558 typedef jlong NativeType;
549 virtual bool eq( const Type *t ) const; 559 virtual bool eq( const Type *t ) const;
550 virtual int hash() const; // Type specific hashing 560 virtual int hash() const; // Type specific hashing
551 virtual bool singleton(void) const; // TRUE if type is a singleton 561 virtual bool singleton(void) const; // TRUE if type is a singleton
552 virtual bool empty(void) const; // TRUE if type is vacuous 562 virtual bool empty(void) const; // TRUE if type is vacuous
553 public: 563 public:
565 575
566 // Check for positive 32-bit value. 576 // Check for positive 32-bit value.
567 int is_positive_int() const { return _lo >= 0 && _hi <= (jlong)max_jint; } 577 int is_positive_int() const { return _lo >= 0 && _hi <= (jlong)max_jint; }
568 578
569 virtual bool is_finite() const; // Has a finite value 579 virtual bool is_finite() const; // Has a finite value
580
570 581
571 virtual const Type *xmeet( const Type *t ) const; 582 virtual const Type *xmeet( const Type *t ) const;
572 virtual const Type *xdual() const; // Compute dual right now. 583 virtual const Type *xdual() const; // Compute dual right now.
573 virtual const Type *widen( const Type *t, const Type* limit_type ) const; 584 virtual const Type *widen( const Type *t, const Type* limit_type ) const;
574 virtual const Type *narrow( const Type *t ) const; 585 virtual const Type *narrow( const Type *t ) const;
578 static const TypeLong *ONE; 589 static const TypeLong *ONE;
579 static const TypeLong *POS; 590 static const TypeLong *POS;
580 static const TypeLong *LONG; 591 static const TypeLong *LONG;
581 static const TypeLong *INT; // 32-bit subrange [min_jint..max_jint] 592 static const TypeLong *INT; // 32-bit subrange [min_jint..max_jint]
582 static const TypeLong *UINT; // 32-bit unsigned [0..max_juint] 593 static const TypeLong *UINT; // 32-bit unsigned [0..max_juint]
594 static const TypeLong *TYPE_DOMAIN; // alias for TypeLong::LONG
595
596 // static convenience methods.
597 static const TypeLong *as_self(const Type *t) { return t->is_long(); }
598
583 #ifndef PRODUCT 599 #ifndef PRODUCT
584 virtual void dump2( Dict &d, uint, outputStream *st ) const;// Specialized per-Type dumping 600 virtual void dump2( Dict &d, uint, outputStream *st ) const;// Specialized per-Type dumping
585 #endif 601 #endif
586 }; 602 };
587 603
832 848
833 //------------------------------TypeOopPtr------------------------------------- 849 //------------------------------TypeOopPtr-------------------------------------
834 // 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.
835 class TypeOopPtr : public TypePtr { 851 class TypeOopPtr : public TypePtr {
836 protected: 852 protected:
837 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);
838 public: 854 public:
839 virtual bool eq( const Type *t ) const; 855 virtual bool eq( const Type *t ) const;
840 virtual int hash() const; // Type specific hashing 856 virtual int hash() const; // Type specific hashing
841 virtual bool singleton(void) const; // TRUE if type is a singleton 857 virtual bool singleton(void) const; // TRUE if type is a singleton
842 enum { 858 enum {
843 InstanceTop = -1, // undefined instance 859 InstanceTop = -1, // undefined instance
844 InstanceBot = 0 // any possible instance 860 InstanceBot = 0 // any possible instance
845 }; 861 };
846 protected: 862 protected:
847 863
864 enum {
865 InlineDepthBottom = INT_MAX,
866 InlineDepthTop = -InlineDepthBottom
867 };
848 // Oop is NULL, unless this is a constant oop. 868 // Oop is NULL, unless this is a constant oop.
849 ciObject* _const_oop; // Constant oop 869 ciObject* _const_oop; // Constant oop
850 // 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.
851 ciKlass* _klass; // Klass object 871 ciKlass* _klass; // Klass object
852 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) 872 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
863 // Extra type information profiling gave us. We propagate it the 883 // Extra type information profiling gave us. We propagate it the
864 // 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
865 // 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
866 // not something we know but something we speculate about the type. 886 // not something we know but something we speculate about the type.
867 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;
868 893
869 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);
870 895
871 int dual_instance_id() const; 896 int dual_instance_id() const;
872 int meet_instance_id(int uid) const; 897 int meet_instance_id(int uid) const;
877 bool eq_speculative(const TypeOopPtr* other) const; 902 bool eq_speculative(const TypeOopPtr* other) const;
878 int hash_speculative() const; 903 int hash_speculative() const;
879 const TypeOopPtr* add_offset_speculative(intptr_t offset) const; 904 const TypeOopPtr* add_offset_speculative(intptr_t offset) const;
880 #ifndef PRODUCT 905 #ifndef PRODUCT
881 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;
882 #endif 913 #endif
883 914
884 // Do not allow interface-vs.-noninterface joins to collapse to top. 915 // Do not allow interface-vs.-noninterface joins to collapse to top.
885 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;
886 917
908 static const TypeOopPtr* make_from_constant(ciObject* o, 939 static const TypeOopPtr* make_from_constant(ciObject* o,
909 bool require_constant = false, 940 bool require_constant = false,
910 bool not_null_elements = false); 941 bool not_null_elements = false);
911 942
912 // Make a generic (unclassed) pointer to an oop. 943 // Make a generic (unclassed) pointer to an oop.
913 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);
914 945
915 ciObject* const_oop() const { return _const_oop; } 946 ciObject* const_oop() const { return _const_oop; }
916 virtual ciKlass* klass() const { return _klass; } 947 virtual ciKlass* klass() const { return _klass; }
917 bool klass_is_exact() const { return _klass_is_exact; } 948 bool klass_is_exact() const { return _klass_is_exact; }
918 949
922 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; }
923 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; }
924 bool is_known_instance() const { return _instance_id > 0; } 955 bool is_known_instance() const { return _instance_id > 0; }
925 int instance_id() const { return _instance_id; } 956 int instance_id() const { return _instance_id; }
926 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; }
927 const TypeOopPtr* speculative() const { return _speculative; } 958 virtual const TypeOopPtr* speculative() const { return _speculative; }
928 959
929 virtual intptr_t get_con() const; 960 virtual intptr_t get_con() const;
930 961
931 virtual const Type *cast_to_ptr_type(PTR ptr) const; 962 virtual const Type *cast_to_ptr_type(PTR ptr) const;
932 963
955 // Return the speculative type if any 986 // Return the speculative type if any
956 ciKlass* speculative_type() const { 987 ciKlass* speculative_type() const {
957 if (_speculative != NULL) { 988 if (_speculative != NULL) {
958 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr(); 989 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr();
959 if (speculative->klass_is_exact()) { 990 if (speculative->klass_is_exact()) {
960 return speculative->klass(); 991 return speculative->klass();
961 } 992 }
962 } 993 }
963 return NULL; 994 return NULL;
964 } 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;
965 }; 1001 };
966 1002
967 //------------------------------TypeInstPtr------------------------------------ 1003 //------------------------------TypeInstPtr------------------------------------
968 // 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
969 // or to a Klass* (including array klasses). 1005 // or to a Klass* (including array klasses).
970 class TypeInstPtr : public TypeOopPtr { 1006 class TypeInstPtr : public TypeOopPtr {
971 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);
972 virtual bool eq( const Type *t ) const; 1008 virtual bool eq( const Type *t ) const;
973 virtual int hash() const; // Type specific hashing 1009 virtual int hash() const; // Type specific hashing
974 1010
975 ciSymbol* _name; // class name 1011 ciSymbol* _name; // class name
976 1012
1002 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) { 1038 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1003 return make(ptr, klass, false, NULL, offset, InstanceBot); 1039 return make(ptr, klass, false, NULL, offset, InstanceBot);
1004 } 1040 }
1005 1041
1006 // Make a pointer to an oop. 1042 // Make a pointer to an oop.
1007 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);
1008 1044
1009 /** Create constant type for a constant boxed value */ 1045 /** Create constant type for a constant boxed value */
1010 const Type* get_const_boxed_value() const; 1046 const Type* get_const_boxed_value() const;
1011 1047
1012 // 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.
1021 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; 1057 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1022 1058
1023 virtual const TypePtr *add_offset( intptr_t offset ) const; 1059 virtual const TypePtr *add_offset( intptr_t offset ) const;
1024 // Return same type without a speculative part 1060 // Return same type without a speculative part
1025 virtual const Type* remove_speculative() const; 1061 virtual const Type* remove_speculative() const;
1062 virtual const TypeOopPtr* with_inline_depth(int depth) const;
1026 1063
1027 // the core of the computation of the meet of 2 types 1064 // the core of the computation of the meet of 2 types
1028 virtual const Type *xmeet_helper(const Type *t) const; 1065 virtual const Type *xmeet_helper(const Type *t) const;
1029 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; 1066 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1030 virtual const Type *xdual() const; // Compute dual right now. 1067 virtual const Type *xdual() const; // Compute dual right now.
1042 1079
1043 //------------------------------TypeAryPtr------------------------------------- 1080 //------------------------------TypeAryPtr-------------------------------------
1044 // Class of Java array pointers 1081 // Class of Java array pointers
1045 class TypeAryPtr : public TypeOopPtr { 1082 class TypeAryPtr : public TypeOopPtr {
1046 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,
1047 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)
1048 : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative), 1085 : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth),
1049 _ary(ary), 1086 _ary(ary),
1050 _is_autobox_cache(is_autobox_cache) 1087 _is_autobox_cache(is_autobox_cache)
1051 { 1088 {
1052 #ifdef ASSERT 1089 #ifdef ASSERT
1053 if (k != NULL) { 1090 if (k != NULL) {
1081 const TypeInt* size() const { return _ary->_size; } 1118 const TypeInt* size() const { return _ary->_size; }
1082 bool is_stable() const { return _ary->_stable; } 1119 bool is_stable() const { return _ary->_stable; }
1083 1120
1084 bool is_autobox_cache() const { return _is_autobox_cache; } 1121 bool is_autobox_cache() const { return _is_autobox_cache; }
1085 1122
1086 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);
1087 // Constant pointer to array 1124 // Constant pointer to array
1088 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);
1089 1126
1090 // Return a 'ptr' version of this type 1127 // Return a 'ptr' version of this type
1091 virtual const Type *cast_to_ptr_type(PTR ptr) const; 1128 virtual const Type *cast_to_ptr_type(PTR ptr) const;
1092 1129
1093 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 1130 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1099 1136
1100 virtual bool empty(void) const; // TRUE if type is vacuous 1137 virtual bool empty(void) const; // TRUE if type is vacuous
1101 virtual const TypePtr *add_offset( intptr_t offset ) const; 1138 virtual const TypePtr *add_offset( intptr_t offset ) const;
1102 // Return same type without a speculative part 1139 // Return same type without a speculative part
1103 virtual const Type* remove_speculative() const; 1140 virtual const Type* remove_speculative() const;
1141 virtual const TypeOopPtr* with_inline_depth(int depth) const;
1104 1142
1105 // the core of the computation of the meet of 2 types 1143 // the core of the computation of the meet of 2 types
1106 virtual const Type *xmeet_helper(const Type *t) const; 1144 virtual const Type *xmeet_helper(const Type *t) const;
1107 virtual const Type *xdual() const; // Compute dual right now. 1145 virtual const Type *xdual() const; // Compute dual right now.
1108 1146
1676 // conversions 1714 // conversions
1677 #define ConvI2X(x) ConvI2L(x) 1715 #define ConvI2X(x) ConvI2L(x)
1678 #define ConvL2X(x) (x) 1716 #define ConvL2X(x) (x)
1679 #define ConvX2I(x) ConvL2I(x) 1717 #define ConvX2I(x) ConvL2I(x)
1680 #define ConvX2L(x) (x) 1718 #define ConvX2L(x) (x)
1719 #define ConvX2UL(x) (x)
1681 1720
1682 #else 1721 #else
1683 1722
1684 // For type queries and asserts 1723 // For type queries and asserts
1685 #define is_intptr_t is_int 1724 #define is_intptr_t is_int
1720 // conversions 1759 // conversions
1721 #define ConvI2X(x) (x) 1760 #define ConvI2X(x) (x)
1722 #define ConvL2X(x) ConvL2I(x) 1761 #define ConvL2X(x) ConvL2I(x)
1723 #define ConvX2I(x) (x) 1762 #define ConvX2I(x) (x)
1724 #define ConvX2L(x) ConvI2L(x) 1763 #define ConvX2L(x) ConvI2L(x)
1764 #define ConvX2UL(x) ConvI2UL(x)
1725 1765
1726 #endif 1766 #endif
1727 1767
1728 #endif // SHARE_VM_OPTO_TYPE_HPP 1768 #endif // SHARE_VM_OPTO_TYPE_HPP