< prev index next >

src/hotspot/share/ci/ciField.hpp

Print this page




  32 #include "ci/ciUtilities.hpp"
  33 
  34 // ciField
  35 //
  36 // This class represents the result of a field lookup in the VM.
  37 // The lookup may not succeed, in which case the information in
  38 // the ciField will be incomplete.
  39 class ciField : public ResourceObj {
  40   CI_PACKAGE_ACCESS
  41   friend class ciEnv;
  42   friend class ciInstanceKlass;
  43 
  44 private:
  45   ciFlags          _flags;
  46   ciInstanceKlass* _holder;
  47   ciSymbol*        _name;
  48   ciSymbol*        _signature;
  49   ciType*          _type;
  50   int              _offset;
  51   bool             _is_constant;


  52   ciMethod*        _known_to_link_with_put;
  53   ciInstanceKlass* _known_to_link_with_get;
  54   ciConstant       _constant_value;
  55 
  56   ciType* compute_type();
  57   ciType* compute_type_impl();
  58 
  59   ciField(ciInstanceKlass* klass, int index);
  60   ciField(fieldDescriptor* fd);

  61 
  62   // shared constructor code
  63   void initialize_from(fieldDescriptor* fd);
  64 
  65 public:
  66   ciFlags flags() const { return _flags; }
  67 
  68   // Of which klass is this field a member?
  69   //
  70   // Usage note: the declared holder of a field is the class
  71   // referenced by name in the bytecodes.  The canonical holder
  72   // is the most general class which holds the field.  This
  73   // method returns the canonical holder.  The declared holder
  74   // can be accessed via a method in ciBytecodeStream.
  75   //
  76   // Ex.
  77   //     class A {
  78   //       public int f = 7;
  79   //     }
  80   //     class B extends A {


  85   //
  86   //   A java compiler is permitted to compile the access to
  87   //   field f as:
  88   //
  89   //     getfield B.f
  90   //
  91   //   In that case the declared holder of f would be B and
  92   //   the canonical holder of f would be A.
  93   ciInstanceKlass* holder() const { return _holder; }
  94 
  95   // Name of this field?
  96   ciSymbol* name() const { return _name; }
  97 
  98   // Signature of this field?
  99   ciSymbol* signature() const { return _signature; }
 100 
 101   // Of what type is this field?
 102   ciType* type() { return (_type == NULL) ? compute_type() : _type; }
 103 
 104   // How is this field actually stored in memory?
 105   BasicType layout_type() { return type2field[(_type == NULL) ? T_OBJECT : _type->basic_type()]; }
 106 
 107   // How big is this field in memory?
 108   int size_in_bytes() { return type2aelembytes(layout_type()); }
 109 
 110   // What is the offset of this field?
 111   int offset() const {
 112     assert(_offset >= 1, "illegal call to offset()");
 113     return _offset;
 114   }
 115 
 116   // Same question, explicit units.  (Fields are aligned to the byte level.)
 117   int offset_in_bytes() const {
 118     return offset();
 119   }
 120 
 121   // Is this field shared?
 122   bool is_shared() {
 123     // non-static fields of shared holders are cached
 124     return _holder->is_shared() && !is_static();
 125   }


 157   // Check for link time errors.  Accessing a field from a
 158   // certain method via a certain bytecode may or may not be legal.
 159   // This call checks to see if an exception may be raised by
 160   // an access of this field.
 161   //
 162   // Usage note: if the same field is accessed multiple times
 163   // in the same compilation, will_link will need to be checked
 164   // at each point of access.
 165   bool will_link(ciMethod* accessing_method,
 166                  Bytecodes::Code bc);
 167 
 168   // Java access flags
 169   bool is_public               () const { return flags().is_public(); }
 170   bool is_private              () const { return flags().is_private(); }
 171   bool is_protected            () const { return flags().is_protected(); }
 172   bool is_static               () const { return flags().is_static(); }
 173   bool is_final                () const { return flags().is_final(); }
 174   bool is_stable               () const { return flags().is_stable(); }
 175   bool is_volatile             () const { return flags().is_volatile(); }
 176   bool is_transient            () const { return flags().is_transient(); }



 177   // The field is modified outside of instance initializer methods
 178   // (or class/initializer methods if the field is static).
 179   bool has_initialized_final_update() const { return flags().has_initialized_final_update(); }
 180 
 181   bool is_call_site_target() {
 182     ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass();
 183     if (callsite_klass == NULL)
 184       return false;
 185     return (holder()->is_subclass_of(callsite_klass) && (name() == ciSymbol::target_name()));
 186   }
 187 
 188   bool is_autobox_cache() {
 189     ciSymbol* klass_name = holder()->name();
 190     return (name() == ciSymbol::cache_field_name() &&
 191             holder()->uses_default_loader() &&
 192             (klass_name == ciSymbol::java_lang_Character_CharacterCache() ||
 193              klass_name == ciSymbol::java_lang_Byte_ByteCache() ||
 194              klass_name == ciSymbol::java_lang_Short_ShortCache() ||
 195              klass_name == ciSymbol::java_lang_Integer_IntegerCache() ||
 196              klass_name == ciSymbol::java_lang_Long_LongCache()));


  32 #include "ci/ciUtilities.hpp"
  33 
  34 // ciField
  35 //
  36 // This class represents the result of a field lookup in the VM.
  37 // The lookup may not succeed, in which case the information in
  38 // the ciField will be incomplete.
  39 class ciField : public ResourceObj {
  40   CI_PACKAGE_ACCESS
  41   friend class ciEnv;
  42   friend class ciInstanceKlass;
  43 
  44 private:
  45   ciFlags          _flags;
  46   ciInstanceKlass* _holder;
  47   ciSymbol*        _name;
  48   ciSymbol*        _signature;
  49   ciType*          _type;
  50   int              _offset;
  51   bool             _is_constant;
  52   bool             _is_flattened;
  53   bool             _is_flattenable;
  54   ciMethod*        _known_to_link_with_put;
  55   ciInstanceKlass* _known_to_link_with_get;
  56   ciConstant       _constant_value;
  57 
  58   ciType* compute_type();
  59   ciType* compute_type_impl();
  60 
  61   ciField(ciInstanceKlass* klass, int index);
  62   ciField(fieldDescriptor* fd);
  63   ciField(ciField* field, ciInstanceKlass* holder, int offset, bool is_final);
  64 
  65   // shared constructor code
  66   void initialize_from(fieldDescriptor* fd);
  67 
  68 public:
  69   ciFlags flags() const { return _flags; }
  70 
  71   // Of which klass is this field a member?
  72   //
  73   // Usage note: the declared holder of a field is the class
  74   // referenced by name in the bytecodes.  The canonical holder
  75   // is the most general class which holds the field.  This
  76   // method returns the canonical holder.  The declared holder
  77   // can be accessed via a method in ciBytecodeStream.
  78   //
  79   // Ex.
  80   //     class A {
  81   //       public int f = 7;
  82   //     }
  83   //     class B extends A {


  88   //
  89   //   A java compiler is permitted to compile the access to
  90   //   field f as:
  91   //
  92   //     getfield B.f
  93   //
  94   //   In that case the declared holder of f would be B and
  95   //   the canonical holder of f would be A.
  96   ciInstanceKlass* holder() const { return _holder; }
  97 
  98   // Name of this field?
  99   ciSymbol* name() const { return _name; }
 100 
 101   // Signature of this field?
 102   ciSymbol* signature() const { return _signature; }
 103 
 104   // Of what type is this field?
 105   ciType* type() { return (_type == NULL) ? compute_type() : _type; }
 106 
 107   // How is this field actually stored in memory?
 108   BasicType layout_type() { return type2field[type()->basic_type()]; }
 109 
 110   // How big is this field in memory?
 111   int size_in_bytes() { return type2aelembytes(layout_type()); }
 112 
 113   // What is the offset of this field?
 114   int offset() const {
 115     assert(_offset >= 1, "illegal call to offset()");
 116     return _offset;
 117   }
 118 
 119   // Same question, explicit units.  (Fields are aligned to the byte level.)
 120   int offset_in_bytes() const {
 121     return offset();
 122   }
 123 
 124   // Is this field shared?
 125   bool is_shared() {
 126     // non-static fields of shared holders are cached
 127     return _holder->is_shared() && !is_static();
 128   }


 160   // Check for link time errors.  Accessing a field from a
 161   // certain method via a certain bytecode may or may not be legal.
 162   // This call checks to see if an exception may be raised by
 163   // an access of this field.
 164   //
 165   // Usage note: if the same field is accessed multiple times
 166   // in the same compilation, will_link will need to be checked
 167   // at each point of access.
 168   bool will_link(ciMethod* accessing_method,
 169                  Bytecodes::Code bc);
 170 
 171   // Java access flags
 172   bool is_public               () const { return flags().is_public(); }
 173   bool is_private              () const { return flags().is_private(); }
 174   bool is_protected            () const { return flags().is_protected(); }
 175   bool is_static               () const { return flags().is_static(); }
 176   bool is_final                () const { return flags().is_final(); }
 177   bool is_stable               () const { return flags().is_stable(); }
 178   bool is_volatile             () const { return flags().is_volatile(); }
 179   bool is_transient            () const { return flags().is_transient(); }
 180   bool is_flattened            () const { return _is_flattened; }
 181   bool is_flattenable          () const { return _is_flattenable; }
 182 
 183   // The field is modified outside of instance initializer methods
 184   // (or class/initializer methods if the field is static).
 185   bool has_initialized_final_update() const { return flags().has_initialized_final_update(); }
 186 
 187   bool is_call_site_target() {
 188     ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass();
 189     if (callsite_klass == NULL)
 190       return false;
 191     return (holder()->is_subclass_of(callsite_klass) && (name() == ciSymbol::target_name()));
 192   }
 193 
 194   bool is_autobox_cache() {
 195     ciSymbol* klass_name = holder()->name();
 196     return (name() == ciSymbol::cache_field_name() &&
 197             holder()->uses_default_loader() &&
 198             (klass_name == ciSymbol::java_lang_Character_CharacterCache() ||
 199              klass_name == ciSymbol::java_lang_Byte_ByteCache() ||
 200              klass_name == ciSymbol::java_lang_Short_ShortCache() ||
 201              klass_name == ciSymbol::java_lang_Integer_IntegerCache() ||
 202              klass_name == ciSymbol::java_lang_Long_LongCache()));
< prev index next >