src/share/vm/opto/type.hpp

changeset 6507
752ba2e5f6d0
parent 6487
15120a36272d
parent 6313
de95063c0e34
child 6518
62c54fcc0a35
     1.1 --- a/src/share/vm/opto/type.hpp	Wed Feb 19 20:12:43 2014 -0800
     1.2 +++ b/src/share/vm/opto/type.hpp	Tue Feb 25 15:11:18 2014 -0800
     1.3 @@ -164,6 +164,8 @@
     1.4    virtual bool interface_vs_oop_helper(const Type *t) const;
     1.5  #endif
     1.6  
     1.7 +  const Type *meet_helper(const Type *t, bool include_speculative) const;
     1.8 +
     1.9  protected:
    1.10    // Each class of type is also identified by its base.
    1.11    const TYPES _base;            // Enum of Types type
    1.12 @@ -171,6 +173,10 @@
    1.13    Type( TYPES t ) : _dual(NULL),  _base(t) {} // Simple types
    1.14    // ~Type();                   // Use fast deallocation
    1.15    const Type *hashcons();       // Hash-cons the type
    1.16 +  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
    1.17 +  const Type *join_helper(const Type *t, bool include_speculative) const {
    1.18 +    return dual()->meet_helper(t->dual(), include_speculative)->dual();
    1.19 +  }
    1.20  
    1.21  public:
    1.22  
    1.23 @@ -202,10 +208,24 @@
    1.24    // Test for equivalence of types
    1.25    static int cmp( const Type *const t1, const Type *const t2 );
    1.26    // Test for higher or equal in lattice
    1.27 -  int higher_equal( const Type *t ) const { return !cmp(meet(t),t); }
    1.28 +  // Variant that drops the speculative part of the types
    1.29 +  int higher_equal(const Type *t) const {
    1.30 +    return !cmp(meet(t),t->remove_speculative());
    1.31 +  }
    1.32 +  // Variant that keeps the speculative part of the types
    1.33 +  int higher_equal_speculative(const Type *t) const {
    1.34 +    return !cmp(meet_speculative(t),t);
    1.35 +  }
    1.36  
    1.37    // MEET operation; lower in lattice.
    1.38 -  const Type *meet( const Type *t ) const;
    1.39 +  // Variant that drops the speculative part of the types
    1.40 +  const Type *meet(const Type *t) const {
    1.41 +    return meet_helper(t, false);
    1.42 +  }
    1.43 +  // Variant that keeps the speculative part of the types
    1.44 +  const Type *meet_speculative(const Type *t) const {
    1.45 +    return meet_helper(t, true);
    1.46 +  }
    1.47    // WIDEN: 'widens' for Ints and other range types
    1.48    virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
    1.49    // NARROW: complement for widen, used by pessimistic phases
    1.50 @@ -221,13 +241,26 @@
    1.51  
    1.52    // JOIN operation; higher in lattice.  Done by finding the dual of the
    1.53    // meet of the dual of the 2 inputs.
    1.54 -  const Type *join( const Type *t ) const {
    1.55 -    return dual()->meet(t->dual())->dual(); }
    1.56 +  // Variant that drops the speculative part of the types
    1.57 +  const Type *join(const Type *t) const {
    1.58 +    return join_helper(t, false);
    1.59 +  }
    1.60 +  // Variant that keeps the speculative part of the types
    1.61 +  const Type *join_speculative(const Type *t) const {
    1.62 +    return join_helper(t, true);
    1.63 +  }
    1.64  
    1.65    // Modified version of JOIN adapted to the needs Node::Value.
    1.66    // Normalizes all empty values to TOP.  Does not kill _widen bits.
    1.67    // Currently, it also works around limitations involving interface types.
    1.68 -  virtual const Type *filter( const Type *kills ) const;
    1.69 +  // Variant that drops the speculative part of the types
    1.70 +  const Type *filter(const Type *kills) const {
    1.71 +    return filter_helper(kills, false);
    1.72 +  }
    1.73 +  // Variant that keeps the speculative part of the types
    1.74 +  const Type *filter_speculative(const Type *kills) const {
    1.75 +    return filter_helper(kills, true);
    1.76 +  }
    1.77  
    1.78  #ifdef ASSERT
    1.79    // One type is interface, the other is oop
    1.80 @@ -383,6 +416,8 @@
    1.81  
    1.82    // Speculative type. See TypeInstPtr
    1.83    virtual ciKlass* speculative_type() const { return NULL; }
    1.84 +  const Type* maybe_remove_speculative(bool include_speculative) const;
    1.85 +  virtual const Type* remove_speculative() const { return this; }
    1.86  
    1.87  private:
    1.88    // support arrays
    1.89 @@ -450,12 +485,14 @@
    1.90  // upper bound, inclusive.
    1.91  class TypeInt : public Type {
    1.92    TypeInt( jint lo, jint hi, int w );
    1.93 +protected:
    1.94 +  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
    1.95 +
    1.96  public:
    1.97    virtual bool eq( const Type *t ) const;
    1.98    virtual int  hash() const;             // Type specific hashing
    1.99    virtual bool singleton(void) const;    // TRUE if type is a singleton
   1.100    virtual bool empty(void) const;        // TRUE if type is vacuous
   1.101 -public:
   1.102    const jint _lo, _hi;          // Lower bound, upper bound
   1.103    const short _widen;           // Limit on times we widen this sucker
   1.104  
   1.105 @@ -475,7 +512,6 @@
   1.106    virtual const Type *widen( const Type *t, const Type* limit_type ) const;
   1.107    virtual const Type *narrow( const Type *t ) const;
   1.108    // Do not kill _widen bits.
   1.109 -  virtual const Type *filter( const Type *kills ) const;
   1.110    // Convenience common pre-built types.
   1.111    static const TypeInt *MINUS_1;
   1.112    static const TypeInt *ZERO;
   1.113 @@ -506,6 +542,9 @@
   1.114  // an upper bound, inclusive.
   1.115  class TypeLong : public Type {
   1.116    TypeLong( jlong lo, jlong hi, int w );
   1.117 +protected:
   1.118 +  // Do not kill _widen bits.
   1.119 +  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
   1.120  public:
   1.121    virtual bool eq( const Type *t ) const;
   1.122    virtual int  hash() const;             // Type specific hashing
   1.123 @@ -533,8 +572,6 @@
   1.124    virtual const Type *xdual() const;    // Compute dual right now.
   1.125    virtual const Type *widen( const Type *t, const Type* limit_type ) const;
   1.126    virtual const Type *narrow( const Type *t ) const;
   1.127 -  // Do not kill _widen bits.
   1.128 -  virtual const Type *filter( const Type *kills ) const;
   1.129    // Convenience common pre-built types.
   1.130    static const TypeLong *MINUS_1;
   1.131    static const TypeLong *ZERO;
   1.132 @@ -625,6 +662,7 @@
   1.133    virtual const Type *xmeet( const Type *t ) const;
   1.134    virtual const Type *xdual() const;    // Compute dual right now.
   1.135    bool ary_must_be_exact() const;  // true if arrays of such are never generic
   1.136 +  virtual const Type* remove_speculative() const;
   1.137  #ifdef ASSERT
   1.138    // One type is interface, the other is oop
   1.139    virtual bool interface_vs_oop(const Type *t) const;
   1.140 @@ -835,7 +873,7 @@
   1.141  
   1.142    // utility methods to work on the speculative part of the type
   1.143    const TypeOopPtr* dual_speculative() const;
   1.144 -  const TypeOopPtr* meet_speculative(const TypeOopPtr* other) const;
   1.145 +  const TypeOopPtr* xmeet_speculative(const TypeOopPtr* other) const;
   1.146    bool eq_speculative(const TypeOopPtr* other) const;
   1.147    int hash_speculative() const;
   1.148    const TypeOopPtr* add_offset_speculative(intptr_t offset) const;
   1.149 @@ -843,6 +881,9 @@
   1.150    void dump_speculative(outputStream *st) const;
   1.151  #endif
   1.152  
   1.153 +  // Do not allow interface-vs.-noninterface joins to collapse to top.
   1.154 +  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
   1.155 +
   1.156  public:
   1.157    // Creates a type given a klass. Correctly handles multi-dimensional arrays
   1.158    // Respects UseUniqueSubclasses.
   1.159 @@ -898,16 +939,13 @@
   1.160  
   1.161    virtual const TypePtr *add_offset( intptr_t offset ) const;
   1.162    // Return same type without a speculative part
   1.163 -  virtual const TypeOopPtr* remove_speculative() const;
   1.164 +  virtual const Type* remove_speculative() const;
   1.165  
   1.166    virtual const Type *xmeet(const Type *t) const;
   1.167    virtual const Type *xdual() const;    // Compute dual right now.
   1.168    // the core of the computation of the meet for TypeOopPtr and for its subclasses
   1.169    virtual const Type *xmeet_helper(const Type *t) const;
   1.170  
   1.171 -  // Do not allow interface-vs.-noninterface joins to collapse to top.
   1.172 -  virtual const Type *filter( const Type *kills ) const;
   1.173 -
   1.174    // Convenience common pre-built type.
   1.175    static const TypeOopPtr *BOTTOM;
   1.176  #ifndef PRODUCT
   1.177 @@ -984,7 +1022,7 @@
   1.178  
   1.179    virtual const TypePtr *add_offset( intptr_t offset ) const;
   1.180    // Return same type without a speculative part
   1.181 -  virtual const TypeOopPtr* remove_speculative() const;
   1.182 +  virtual const Type* remove_speculative() const;
   1.183  
   1.184    // the core of the computation of the meet of 2 types
   1.185    virtual const Type *xmeet_helper(const Type *t) const;
   1.186 @@ -1062,7 +1100,7 @@
   1.187    virtual bool empty(void) const;        // TRUE if type is vacuous
   1.188    virtual const TypePtr *add_offset( intptr_t offset ) const;
   1.189    // Return same type without a speculative part
   1.190 -  virtual const TypeOopPtr* remove_speculative() const;
   1.191 +  virtual const Type* remove_speculative() const;
   1.192  
   1.193    // the core of the computation of the meet of 2 types
   1.194    virtual const Type *xmeet_helper(const Type *t) const;
   1.195 @@ -1103,6 +1141,8 @@
   1.196  class TypeMetadataPtr : public TypePtr {
   1.197  protected:
   1.198    TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
   1.199 +  // Do not allow interface-vs.-noninterface joins to collapse to top.
   1.200 +  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
   1.201  public:
   1.202    virtual bool eq( const Type *t ) const;
   1.203    virtual int  hash() const;             // Type specific hashing
   1.204 @@ -1128,9 +1168,6 @@
   1.205  
   1.206    virtual intptr_t get_con() const;
   1.207  
   1.208 -  // Do not allow interface-vs.-noninterface joins to collapse to top.
   1.209 -  virtual const Type *filter( const Type *kills ) const;
   1.210 -
   1.211    // Convenience common pre-built types.
   1.212    static const TypeMetadataPtr *BOTTOM;
   1.213  
   1.214 @@ -1144,6 +1181,8 @@
   1.215  class TypeKlassPtr : public TypePtr {
   1.216    TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
   1.217  
   1.218 +protected:
   1.219 +  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
   1.220   public:
   1.221    virtual bool eq( const Type *t ) const;
   1.222    virtual int hash() const;             // Type specific hashing
   1.223 @@ -1205,9 +1244,6 @@
   1.224  
   1.225    virtual intptr_t get_con() const;
   1.226  
   1.227 -  // Do not allow interface-vs.-noninterface joins to collapse to top.
   1.228 -  virtual const Type *filter( const Type *kills ) const;
   1.229 -
   1.230    // Convenience common pre-built types.
   1.231    static const TypeKlassPtr* OBJECT; // Not-null object klass or below
   1.232    static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
   1.233 @@ -1231,6 +1267,8 @@
   1.234    virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
   1.235    virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
   1.236    virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
   1.237 +  // Do not allow interface-vs.-noninterface joins to collapse to top.
   1.238 +  virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
   1.239  public:
   1.240    virtual bool eq( const Type *t ) const;
   1.241    virtual int  hash() const;             // Type specific hashing
   1.242 @@ -1241,9 +1279,6 @@
   1.243  
   1.244    virtual intptr_t get_con() const;
   1.245  
   1.246 -  // Do not allow interface-vs.-noninterface joins to collapse to top.
   1.247 -  virtual const Type *filter( const Type *kills ) const;
   1.248 -
   1.249    virtual bool empty(void) const;        // TRUE if type is vacuous
   1.250  
   1.251    // returns the equivalent ptr type for this compressed pointer
   1.252 @@ -1294,6 +1329,10 @@
   1.253    static const TypeNarrowOop *BOTTOM;
   1.254    static const TypeNarrowOop *NULL_PTR;
   1.255  
   1.256 +  virtual const Type* remove_speculative() const {
   1.257 +    return make(_ptrtype->remove_speculative()->is_ptr());
   1.258 +  }
   1.259 +
   1.260  #ifndef PRODUCT
   1.261    virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   1.262  #endif

mercurial