< prev index next >

src/share/vm/oops/fieldStreams.hpp

Print this page




  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_FIELDSTREAMS_HPP
  26 #define SHARE_VM_OOPS_FIELDSTREAMS_HPP
  27 
  28 #include "oops/instanceKlass.hpp"
  29 #include "oops/fieldInfo.hpp"
  30 #include "runtime/fieldDescriptor.hpp"
  31 
  32 // The is the base class for iteration over the fields array
  33 // describing the declared fields in the class.  Several subclasses
  34 // are provided depending on the kind of iteration required.  The
  35 // JavaFieldStream is for iterating over regular Java fields and it
  36 // generally the preferred iterator.  InternalFieldStream only
  37 // iterates over fields that have been injected by the JVM.
  38 // AllFieldStream exposes all fields and should only be used in rare
  39 // cases.
  40 class FieldStreamBase : public StackObj {

  41  protected:
  42   Array<u2>*          _fields;
  43   constantPoolHandle  _constants;
  44   int                 _index;
  45   int                 _limit;
  46   int                 _generic_signature_slot;
  47   fieldDescriptor     _fd_buf;
  48 
  49   FieldInfo* field() const { return FieldInfo::from_field_array(_fields, _index); }
  50   InstanceKlass* field_holder() const { return _constants->pool_holder(); }
  51 
  52   int init_generic_signature_start_slot() {
  53     int length = _fields->length();
  54     int num_fields = _index;
  55     int skipped_generic_signature_slots = 0;
  56     FieldInfo* fi;
  57     AccessFlags flags;
  58     /* Scan from 0 to the current _index. Count the number of generic
  59        signature slots for field[0] to field[_index - 1]. */
  60     for (int i = 0; i < _index; i++) {


 142   Symbol* signature() const {
 143     return field()->signature(_constants);
 144   }
 145 
 146   Symbol* generic_signature() const {
 147     if (access_flags().field_has_generic_signature()) {
 148       assert(_generic_signature_slot < _fields->length(), "out of bounds");
 149       int index = _fields->at(_generic_signature_slot);
 150       return _constants->symbol_at(index);
 151     } else {
 152       return NULL;
 153     }
 154   }
 155 
 156   int offset() const {
 157     return field()->offset();
 158   }
 159 
 160   int allocation_type() const {
 161     return field()->allocation_type();








 162   }
 163 
 164   void set_offset(int offset) {
 165     field()->set_offset(offset);
 166   }
 167 
 168   bool is_offset_set() const {
 169     return field()->is_offset_set();
 170   }
 171 
 172   bool is_contended() const {
 173     return field()->is_contended();
 174   }
 175 
 176   int contended_group() const {
 177     return field()->contended_group();
 178   }
 179 
 180   // bridge to a heavier API:
 181   fieldDescriptor& field_descriptor() const {




  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_FIELDSTREAMS_HPP
  26 #define SHARE_VM_OOPS_FIELDSTREAMS_HPP
  27 
  28 #include "oops/instanceKlass.hpp"
  29 #include "oops/fieldInfo.hpp"
  30 #include "runtime/fieldDescriptor.hpp"
  31 
  32 // The is the base class for iteration over the fields array
  33 // describing the declared fields in the class.  Several subclasses
  34 // are provided depending on the kind of iteration required.  The
  35 // JavaFieldStream is for iterating over regular Java fields and it
  36 // generally the preferred iterator.  InternalFieldStream only
  37 // iterates over fields that have been injected by the JVM.
  38 // AllFieldStream exposes all fields and should only be used in rare
  39 // cases.
  40 class FieldStreamBase : public StackObj {
  41 
  42  protected:
  43   Array<u2>*          _fields;
  44   constantPoolHandle  _constants;
  45   int                 _index;
  46   int                 _limit;
  47   int                 _generic_signature_slot;
  48   fieldDescriptor     _fd_buf;
  49 
  50   FieldInfo* field() const { return FieldInfo::from_field_array(_fields, _index); }
  51   InstanceKlass* field_holder() const { return _constants->pool_holder(); }
  52 
  53   int init_generic_signature_start_slot() {
  54     int length = _fields->length();
  55     int num_fields = _index;
  56     int skipped_generic_signature_slots = 0;
  57     FieldInfo* fi;
  58     AccessFlags flags;
  59     /* Scan from 0 to the current _index. Count the number of generic
  60        signature slots for field[0] to field[_index - 1]. */
  61     for (int i = 0; i < _index; i++) {


 143   Symbol* signature() const {
 144     return field()->signature(_constants);
 145   }
 146 
 147   Symbol* generic_signature() const {
 148     if (access_flags().field_has_generic_signature()) {
 149       assert(_generic_signature_slot < _fields->length(), "out of bounds");
 150       int index = _fields->at(_generic_signature_slot);
 151       return _constants->symbol_at(index);
 152     } else {
 153       return NULL;
 154     }
 155   }
 156 
 157   int offset() const {
 158     return field()->offset();
 159   }
 160 
 161   int allocation_type() const {
 162     return field()->allocation_type();
 163   }
 164 
 165   bool is_flatten() {
 166     return field()->is_flatten();
 167   }
 168 
 169   void set_flattening(bool b) {
 170     field()->set_flattening(b);
 171   }
 172 
 173   void set_offset(int offset) {
 174     field()->set_offset(offset);
 175   }
 176 
 177   bool is_offset_set() const {
 178     return field()->is_offset_set();
 179   }
 180 
 181   bool is_contended() const {
 182     return field()->is_contended();
 183   }
 184 
 185   int contended_group() const {
 186     return field()->contended_group();
 187   }
 188 
 189   // bridge to a heavier API:
 190   fieldDescriptor& field_descriptor() const {


< prev index next >