< prev index next >

src/hotspot/share/oops/fieldInfo.inline.hpp

Print this page

 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_OOPS_FIELDINFO_INLINE_HPP
 26 #define SHARE_OOPS_FIELDINFO_INLINE_HPP
 27 
 28 #include "oops/fieldInfo.hpp"
 29 
 30 #include "memory/metadataFactory.hpp"
 31 #include "oops/constantPool.hpp"

 32 #include "oops/symbol.hpp"
 33 #include "runtime/atomic.hpp"
 34 #include "utilities/checkedCast.hpp"
 35 
 36 inline Symbol* FieldInfo::name(ConstantPool* cp) const {
 37   int index = _name_index;
 38   if (_field_flags.is_injected()) {
 39     return lookup_symbol(index);
 40   }
 41   return cp->symbol_at(index);
 42 }
 43 
 44 inline Symbol* FieldInfo::signature(ConstantPool* cp) const {
 45   int index = _signature_index;
 46   if (_field_flags.is_injected()) {
 47     return lookup_symbol(index);
 48   }
 49   return cp->symbol_at(index);
 50 }
 51 

 68 inline int FieldInfoStream::num_java_fields(const Array<u1>* fis) { return FieldInfoReader(fis).next_uint(); }
 69 
 70 template<typename CON>
 71 inline void Mapper<CON>::map_field_info(const FieldInfo& fi) {
 72   _next_index++;  // pre-increment
 73   _consumer->accept_uint(fi.name_index());
 74   _consumer->accept_uint(fi.signature_index());
 75   _consumer->accept_uint(fi.offset());
 76   _consumer->accept_uint(fi.access_flags().as_int());
 77   _consumer->accept_uint(fi.field_flags().as_uint());
 78   if(fi.field_flags().has_any_optionals()) {
 79     if (fi.field_flags().is_initialized()) {
 80       _consumer->accept_uint(fi.initializer_index());
 81     }
 82     if (fi.field_flags().is_generic()) {
 83       _consumer->accept_uint(fi.generic_signature_index());
 84     }
 85     if (fi.field_flags().is_contended()) {
 86       _consumer->accept_uint(fi.contention_group());
 87     }







 88   } else {
 89     assert(fi.initializer_index() == 0, "");
 90     assert(fi.generic_signature_index() == 0, "");
 91     assert(fi.contention_group() == 0, "");

 92   }
 93 }
 94 
 95 
 96 inline FieldInfoReader::FieldInfoReader(const Array<u1>* fi)
 97   : _r(fi->data(), 0),
 98     _next_index(0) { }
 99 
100 inline void FieldInfoReader::read_field_info(FieldInfo& fi) {
101   fi._index = _next_index++;
102   fi._name_index = checked_cast<u2>(next_uint());
103   fi._signature_index = checked_cast<u2>(next_uint());
104   fi._offset = next_uint();
105   fi._access_flags = AccessFlags(next_uint());
106   fi._field_flags = FieldInfo::FieldFlags(next_uint());
107   if (fi._field_flags.is_initialized()) {
108     fi._initializer_index = checked_cast<u2>(next_uint());
109   } else {
110     fi._initializer_index = 0;
111   }
112   if (fi._field_flags.is_generic()) {
113     fi._generic_signature_index = checked_cast<u2>(next_uint());
114   } else {
115     fi._generic_signature_index = 0;
116   }
117   if (fi._field_flags.is_contended()) {
118     fi._contention_group = checked_cast<u2>(next_uint());
119   } else {
120     fi._contention_group = 0;
121   }








122 }
123 
124 inline FieldInfoReader&  FieldInfoReader::skip_field_info() {
125   _next_index++;
126   const int name_sig_af_off = 4;  // four items
127   skip(name_sig_af_off);
128   FieldInfo::FieldFlags ff(next_uint());
129   if (ff.has_any_optionals()) {
130     const int init_gen_cont = (ff.is_initialized() +
131                                 ff.is_generic() +
132                                 ff.is_contended());


133     skip(init_gen_cont);  // up to three items
134   }
135   return *this;
136 }
137 
138 // Skip to the nth field.  If the reader is freshly initialized to
139 // the zero index, this will call skip_field_info() n times.
140 inline FieldInfoReader& FieldInfoReader::skip_to_field_info(int n) {
141   assert(n >= _next_index, "already past that index");
142   const int count = n - _next_index;
143   for (int i = 0; i < count; i++)  skip_field_info();
144   assert(_next_index == n, "");
145   return *this;
146 }
147 
148 // for random access, if you know where to go up front:
149 inline FieldInfoReader& FieldInfoReader::set_position_and_next_index(int position, int next_index) {
150   _r.set_position(position);
151   _next_index = next_index;
152   return *this;

 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_OOPS_FIELDINFO_INLINE_HPP
 26 #define SHARE_OOPS_FIELDINFO_INLINE_HPP
 27 
 28 #include "oops/fieldInfo.hpp"
 29 
 30 #include "memory/metadataFactory.hpp"
 31 #include "oops/constantPool.hpp"
 32 #include "oops/instanceKlass.hpp"
 33 #include "oops/symbol.hpp"
 34 #include "runtime/atomic.hpp"
 35 #include "utilities/checkedCast.hpp"
 36 
 37 inline Symbol* FieldInfo::name(ConstantPool* cp) const {
 38   int index = _name_index;
 39   if (_field_flags.is_injected()) {
 40     return lookup_symbol(index);
 41   }
 42   return cp->symbol_at(index);
 43 }
 44 
 45 inline Symbol* FieldInfo::signature(ConstantPool* cp) const {
 46   int index = _signature_index;
 47   if (_field_flags.is_injected()) {
 48     return lookup_symbol(index);
 49   }
 50   return cp->symbol_at(index);
 51 }
 52 

 69 inline int FieldInfoStream::num_java_fields(const Array<u1>* fis) { return FieldInfoReader(fis).next_uint(); }
 70 
 71 template<typename CON>
 72 inline void Mapper<CON>::map_field_info(const FieldInfo& fi) {
 73   _next_index++;  // pre-increment
 74   _consumer->accept_uint(fi.name_index());
 75   _consumer->accept_uint(fi.signature_index());
 76   _consumer->accept_uint(fi.offset());
 77   _consumer->accept_uint(fi.access_flags().as_int());
 78   _consumer->accept_uint(fi.field_flags().as_uint());
 79   if(fi.field_flags().has_any_optionals()) {
 80     if (fi.field_flags().is_initialized()) {
 81       _consumer->accept_uint(fi.initializer_index());
 82     }
 83     if (fi.field_flags().is_generic()) {
 84       _consumer->accept_uint(fi.generic_signature_index());
 85     }
 86     if (fi.field_flags().is_contended()) {
 87       _consumer->accept_uint(fi.contention_group());
 88     }
 89     if (fi.field_flags().is_flat()) {
 90       assert(fi.layout_kind() != LayoutKind::UNKNOWN, "Must be set");
 91       _consumer->accept_uint(fi.layout_kind());
 92     }
 93     if (fi.field_flags().has_null_marker()) {
 94       _consumer->accept_uint(fi.null_marker_offset());
 95     }
 96   } else {
 97     assert(fi.initializer_index() == 0, "");
 98     assert(fi.generic_signature_index() == 0, "");
 99     assert(fi.contention_group() == 0, "");
100     assert(fi.null_marker_offset() == 0, "");
101   }
102 }
103 
104 
105 inline FieldInfoReader::FieldInfoReader(const Array<u1>* fi)
106   : _r(fi->data(), 0),
107     _next_index(0) { }
108 
109 inline void FieldInfoReader::read_field_info(FieldInfo& fi) {
110   fi._index = _next_index++;
111   fi._name_index = checked_cast<u2>(next_uint());
112   fi._signature_index = checked_cast<u2>(next_uint());
113   fi._offset = next_uint();
114   fi._access_flags = AccessFlags(next_uint());
115   fi._field_flags = FieldInfo::FieldFlags(next_uint());
116   if (fi._field_flags.is_initialized()) {
117     fi._initializer_index = checked_cast<u2>(next_uint());
118   } else {
119     fi._initializer_index = 0;
120   }
121   if (fi._field_flags.is_generic()) {
122     fi._generic_signature_index = checked_cast<u2>(next_uint());
123   } else {
124     fi._generic_signature_index = 0;
125   }
126   if (fi._field_flags.is_contended()) {
127     fi._contention_group = checked_cast<u2>(next_uint());
128   } else {
129     fi._contention_group = 0;
130   }
131   if (fi._field_flags.is_flat()) {
132     fi._layout_kind = static_cast<LayoutKind>(next_uint());
133   }
134   if (fi._field_flags.has_null_marker()) {
135     fi._null_marker_offset = next_uint();
136   } else {
137     fi._null_marker_offset = 0;
138   }
139 }
140 
141 inline FieldInfoReader&  FieldInfoReader::skip_field_info() {
142   _next_index++;
143   const int name_sig_af_off = 4;  // four items
144   skip(name_sig_af_off);
145   FieldInfo::FieldFlags ff(next_uint());
146   if (ff.has_any_optionals()) {
147     const int init_gen_cont = (ff.is_initialized() +
148                                 ff.is_generic() +
149                                 ff.is_contended() +
150                                 ff.is_flat() +
151                                 ff.has_null_marker());
152     skip(init_gen_cont);  // up to three items
153   }
154   return *this;
155 }
156 
157 // Skip to the nth field.  If the reader is freshly initialized to
158 // the zero index, this will call skip_field_info() n times.
159 inline FieldInfoReader& FieldInfoReader::skip_to_field_info(int n) {
160   assert(n >= _next_index, "already past that index");
161   const int count = n - _next_index;
162   for (int i = 0; i < count; i++)  skip_field_info();
163   assert(_next_index == n, "");
164   return *this;
165 }
166 
167 // for random access, if you know where to go up front:
168 inline FieldInfoReader& FieldInfoReader::set_position_and_next_index(int position, int next_index) {
169   _r.set_position(position);
170   _next_index = next_index;
171   return *this;
< prev index next >