< prev index next >

src/hotspot/share/oops/fieldInfo.hpp

Print this page

 29 #include "oops/symbol.hpp"
 30 #include "oops/typeArrayOop.hpp"
 31 #include "utilities/vmEnums.hpp"
 32 
 33 // This class represents the field information contained in the fields
 34 // array of an InstanceKlass.  Currently it's laid on top an array of
 35 // Java shorts but in the future it could simply be used as a real
 36 // array type.  FieldInfo generally shouldn't be used directly.
 37 // Fields should be queried either through InstanceKlass or through
 38 // the various FieldStreams.
 39 class FieldInfo {
 40   friend class fieldDescriptor;
 41   friend class JavaFieldStream;
 42   friend class ClassFileParser;
 43 
 44  public:
 45   // fields
 46   // Field info extracted from the class file and stored
 47   // as an array of 6 shorts.
 48 
 49 #define FIELDINFO_TAG_SIZE             2
 50 #define FIELDINFO_TAG_OFFSET           1 << 0
 51 #define FIELDINFO_TAG_CONTENDED        1 << 1

 52 
 53   // Packed field has the tag, and can be either of:
 54   //    hi bits <--------------------------- lo bits
 55   //   |---------high---------|---------low---------|
 56   //    ..........................................CO
 57   //    ..........................................00  - non-contended field
 58   //    [--contention_group--]....................10  - contended field with contention group
 59   //    [------------------offset----------------]01  - real field offset
 60 
 61   // Bit O indicates if the packed field contains an offset (O=1) or not (O=0)
 62   // Bit C indicates if the field is contended (C=1) or not (C=0)
 63   //       (if it is contended, the high packed field contains the contention group)

 64 
 65   enum FieldOffset {
 66     access_flags_offset      = 0,
 67     name_index_offset        = 1,
 68     signature_index_offset   = 2,
 69     initval_index_offset     = 3,
 70     low_packed_offset        = 4,
 71     high_packed_offset       = 5,
 72     field_slots              = 6
 73   };
 74 
 75  private:
 76   u2 _shorts[field_slots];
 77 
 78   void set_name_index(u2 val)                    { _shorts[name_index_offset] = val;         }
 79   void set_signature_index(u2 val)               { _shorts[signature_index_offset] = val;    }
 80   void set_initval_index(u2 val)                 { _shorts[initval_index_offset] = val;      }
 81 
 82   u2 name_index() const                          { return _shorts[name_index_offset];        }
 83   u2 signature_index() const                     { return _shorts[signature_index_offset];   }

125 
126   Symbol* name(ConstantPool* cp) const {
127     int index = name_index();
128     if (is_internal()) {
129       return lookup_symbol(index);
130     }
131     return cp->symbol_at(index);
132   }
133 
134   Symbol* signature(ConstantPool* cp) const {
135     int index = signature_index();
136     if (is_internal()) {
137       return lookup_symbol(index);
138     }
139     return cp->symbol_at(index);
140   }
141 
142   void set_access_flags(u2 val)                  { _shorts[access_flags_offset] = val;             }
143   void set_offset(u4 val)                        {
144     val = val << FIELDINFO_TAG_SIZE; // make room for tag

145     _shorts[low_packed_offset] = extract_low_short_from_int(val) | FIELDINFO_TAG_OFFSET;

146     _shorts[high_packed_offset] = extract_high_short_from_int(val);













147   }
148 
149   void set_contended_group(u2 val) {
150     assert((_shorts[low_packed_offset] & FIELDINFO_TAG_OFFSET) == 0, "Offset must not have been set");
151     assert((_shorts[low_packed_offset] & FIELDINFO_TAG_CONTENDED) == 0, "Overwritting contended group");
152     _shorts[low_packed_offset] |= FIELDINFO_TAG_CONTENDED;
153     _shorts[high_packed_offset] = val;
154   }
155 
156   bool is_internal() const {
157     return (access_flags() & JVM_ACC_FIELD_INTERNAL) != 0;
158   }
159 
160   bool is_stable() const {
161     return (access_flags() & JVM_ACC_FIELD_STABLE) != 0;
162   }
163   void set_stable(bool z) {
164     if (z) _shorts[access_flags_offset] |=  JVM_ACC_FIELD_STABLE;
165     else   _shorts[access_flags_offset] &= ~JVM_ACC_FIELD_STABLE;
166   }

 29 #include "oops/symbol.hpp"
 30 #include "oops/typeArrayOop.hpp"
 31 #include "utilities/vmEnums.hpp"
 32 
 33 // This class represents the field information contained in the fields
 34 // array of an InstanceKlass.  Currently it's laid on top an array of
 35 // Java shorts but in the future it could simply be used as a real
 36 // array type.  FieldInfo generally shouldn't be used directly.
 37 // Fields should be queried either through InstanceKlass or through
 38 // the various FieldStreams.
 39 class FieldInfo {
 40   friend class fieldDescriptor;
 41   friend class JavaFieldStream;
 42   friend class ClassFileParser;
 43 
 44  public:
 45   // fields
 46   // Field info extracted from the class file and stored
 47   // as an array of 6 shorts.
 48 
 49 #define FIELDINFO_TAG_SIZE             3
 50 #define FIELDINFO_TAG_OFFSET           1 << 0
 51 #define FIELDINFO_TAG_CONTENDED        1 << 1
 52 #define FIELDINFO_TAG_INLINED          1 << 2
 53 
 54   // Packed field has the tag, and can be either of:
 55   //    hi bits <--------------------------- lo bits
 56   //   |---------high---------|---------low---------|
 57   //    ..........................................CO
 58   //    ..........................................00  - non-contended field
 59   //    [--contention_group--]...................I10  - contended field with contention group
 60   //    [------------------offset---------------]I01  - real field offset
 61 
 62   // Bit O indicates if the packed field contains an offset (O=1) or not (O=0)
 63   // Bit C indicates if the field is contended (C=1) or not (C=0)
 64   //       (if it is contended, the high packed field contains the contention group)
 65   // Bit I indicates if the field has been inlined  (I=1) or not (I=0)
 66 
 67   enum FieldOffset {
 68     access_flags_offset      = 0,
 69     name_index_offset        = 1,
 70     signature_index_offset   = 2,
 71     initval_index_offset     = 3,
 72     low_packed_offset        = 4,
 73     high_packed_offset       = 5,
 74     field_slots              = 6
 75   };
 76 
 77  private:
 78   u2 _shorts[field_slots];
 79 
 80   void set_name_index(u2 val)                    { _shorts[name_index_offset] = val;         }
 81   void set_signature_index(u2 val)               { _shorts[signature_index_offset] = val;    }
 82   void set_initval_index(u2 val)                 { _shorts[initval_index_offset] = val;      }
 83 
 84   u2 name_index() const                          { return _shorts[name_index_offset];        }
 85   u2 signature_index() const                     { return _shorts[signature_index_offset];   }

127 
128   Symbol* name(ConstantPool* cp) const {
129     int index = name_index();
130     if (is_internal()) {
131       return lookup_symbol(index);
132     }
133     return cp->symbol_at(index);
134   }
135 
136   Symbol* signature(ConstantPool* cp) const {
137     int index = signature_index();
138     if (is_internal()) {
139       return lookup_symbol(index);
140     }
141     return cp->symbol_at(index);
142   }
143 
144   void set_access_flags(u2 val)                  { _shorts[access_flags_offset] = val;             }
145   void set_offset(u4 val)                        {
146     val = val << FIELDINFO_TAG_SIZE; // make room for tag
147     bool inlined = is_inlined();
148     _shorts[low_packed_offset] = extract_low_short_from_int(val) | FIELDINFO_TAG_OFFSET;
149     if (inlined) set_inlined(true);
150     _shorts[high_packed_offset] = extract_high_short_from_int(val);
151     assert(is_inlined() || !inlined, "just checking");
152   }
153 
154   void set_inlined(bool b) {
155     if (b) {
156       _shorts[low_packed_offset] |= FIELDINFO_TAG_INLINED;
157     } else {
158       _shorts[low_packed_offset] &= ~FIELDINFO_TAG_INLINED;
159     }
160   }
161 
162   bool is_inlined() {
163     return (_shorts[low_packed_offset] & FIELDINFO_TAG_INLINED) != 0;
164   }
165 
166   void set_contended_group(u2 val) {
167     assert((_shorts[low_packed_offset] & FIELDINFO_TAG_OFFSET) == 0, "Offset must not have been set");
168     assert((_shorts[low_packed_offset] & FIELDINFO_TAG_CONTENDED) == 0, "Overwritting contended group");
169     _shorts[low_packed_offset] |= FIELDINFO_TAG_CONTENDED;
170     _shorts[high_packed_offset] = val;
171   }
172 
173   bool is_internal() const {
174     return (access_flags() & JVM_ACC_FIELD_INTERNAL) != 0;
175   }
176 
177   bool is_stable() const {
178     return (access_flags() & JVM_ACC_FIELD_STABLE) != 0;
179   }
180   void set_stable(bool z) {
181     if (z) _shorts[access_flags_offset] |=  JVM_ACC_FIELD_STABLE;
182     else   _shorts[access_flags_offset] &= ~JVM_ACC_FIELD_STABLE;
183   }
< prev index next >