21 * questions.
22 *
23 */
24
25 #ifndef SHARE_OOPS_FIELDSTREAMS_HPP
26 #define SHARE_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
51 int init_generic_signature_start_slot() {
52 int length = _fields->length();
53 int num_fields = _index;
54 int skipped_generic_signature_slots = 0;
55 FieldInfo* fi;
56 AccessFlags flags;
57 /* Scan from 0 to the current _index. Count the number of generic
58 signature slots for field[0] to field[_index - 1]. */
59 for (int i = 0; i < _index; i++) {
60 fi = FieldInfo::from_field_array(_fields, i);
117 }
118
119 Symbol* signature() const {
120 return field()->signature(_constants());
121 }
122
123 Symbol* generic_signature() const {
124 if (access_flags().field_has_generic_signature()) {
125 assert(_generic_signature_slot < _fields->length(), "out of bounds");
126 int index = _fields->at(_generic_signature_slot);
127 return _constants->symbol_at(index);
128 } else {
129 return NULL;
130 }
131 }
132
133 int offset() const {
134 return field()->offset();
135 }
136
137 void set_offset(int offset) {
138 field()->set_offset(offset);
139 }
140
141 bool is_offset_set() const {
142 return field()->is_offset_set();
143 }
144
145 bool is_contended() const {
146 return field()->is_contended();
147 }
148
149 int contended_group() const {
150 return field()->contended_group();
151 }
152
153 // bridge to a heavier API:
154 fieldDescriptor& field_descriptor() const {
155 fieldDescriptor& field = const_cast<fieldDescriptor&>(_fd_buf);
156 field.reinitialize(field_holder(), _index);
|
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_OOPS_FIELDSTREAMS_HPP
26 #define SHARE_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
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++) {
61 fi = FieldInfo::from_field_array(_fields, i);
118 }
119
120 Symbol* signature() const {
121 return field()->signature(_constants());
122 }
123
124 Symbol* generic_signature() const {
125 if (access_flags().field_has_generic_signature()) {
126 assert(_generic_signature_slot < _fields->length(), "out of bounds");
127 int index = _fields->at(_generic_signature_slot);
128 return _constants->symbol_at(index);
129 } else {
130 return NULL;
131 }
132 }
133
134 int offset() const {
135 return field()->offset();
136 }
137
138 bool is_inlined() {
139 return field()->is_inlined();
140 }
141
142 void set_inlined(bool b) {
143 field()->set_inlined(b);
144 }
145
146 void set_offset(int offset) {
147 field()->set_offset(offset);
148 }
149
150 bool is_offset_set() const {
151 return field()->is_offset_set();
152 }
153
154 bool is_contended() const {
155 return field()->is_contended();
156 }
157
158 int contended_group() const {
159 return field()->contended_group();
160 }
161
162 // bridge to a heavier API:
163 fieldDescriptor& field_descriptor() const {
164 fieldDescriptor& field = const_cast<fieldDescriptor&>(_fd_buf);
165 field.reinitialize(field_holder(), _index);
|