Mercurial > hg > truffle
annotate src/share/vm/oops/fieldStreams.hpp @ 14247:2e96b2d61686
8031530: [TESTBUG] Enable test runtime/LoadClass/LoadClassNegative.java
Summary: Re-enabled the test. The issue that prevents this test from running was fixed by 8020675
Reviewed-by: sla, ccheung
author | zgu |
---|---|
date | Mon, 13 Jan 2014 10:05:37 -0500 |
parents | b2e698d2276c |
children |
rev | line source |
---|---|
3938 | 1 /* |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
3938 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
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_VM_OOPS_FIELDSTREAMS_HPP | |
26 #define SHARE_VM_OOPS_FIELDSTREAMS_HPP | |
27 | |
28 #include "oops/instanceKlass.hpp" | |
29 #include "oops/fieldInfo.hpp" | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
30 #include "runtime/fieldDescriptor.hpp" |
3938 | 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: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
42 Array<u2>* _fields; |
3938 | 43 constantPoolHandle _constants; |
44 int _index; | |
45 int _limit; | |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
46 int _generic_signature_slot; |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
47 fieldDescriptor _fd_buf; |
3938 | 48 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
49 FieldInfo* field() const { return FieldInfo::from_field_array(_fields, _index); } |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
50 InstanceKlass* field_holder() const { return _constants->pool_holder(); } |
3938 | 51 |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
52 int init_generic_signature_start_slot() { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
53 int length = _fields->length(); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
54 int num_fields = 0; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
55 int skipped_generic_signature_slots = 0; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
56 FieldInfo* fi; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
57 AccessFlags flags; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
58 /* Scan from 0 to the current _index. Count the number of generic |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
59 signature slots for field[0] to field[_index - 1]. */ |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
60 for (int i = 0; i < _index; i++) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
61 fi = FieldInfo::from_field_array(_fields, i); |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
62 flags.set_flags(fi->access_flags()); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
63 if (flags.field_has_generic_signature()) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
64 length --; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
65 skipped_generic_signature_slots ++; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
66 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
67 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
68 /* Scan from the current _index. */ |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
69 for (int i = _index; i*FieldInfo::field_slots < length; i++) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
70 fi = FieldInfo::from_field_array(_fields, i); |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
71 flags.set_flags(fi->access_flags()); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
72 if (flags.field_has_generic_signature()) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
73 length --; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
74 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
75 num_fields ++; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
76 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
77 _generic_signature_slot = length + skipped_generic_signature_slots; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
78 assert(_generic_signature_slot <= _fields->length(), ""); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
79 return num_fields; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
80 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
81 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
82 FieldStreamBase(Array<u2>* fields, constantPoolHandle constants, int start, int limit) { |
3938 | 83 _fields = fields; |
84 _constants = constants; | |
85 _index = start; | |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
86 int num_fields = init_generic_signature_start_slot(); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
87 if (limit < start) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
88 _limit = num_fields; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
89 } else { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
90 _limit = limit; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
91 } |
3938 | 92 } |
93 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
94 FieldStreamBase(Array<u2>* fields, constantPoolHandle constants) { |
3938 | 95 _fields = fields; |
96 _constants = constants; | |
97 _index = 0; | |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
98 _limit = init_generic_signature_start_slot(); |
3938 | 99 } |
100 | |
101 public: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
102 FieldStreamBase(InstanceKlass* klass) { |
3938 | 103 _fields = klass->fields(); |
104 _constants = klass->constants(); | |
105 _index = 0; | |
106 _limit = klass->java_fields_count(); | |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
107 init_generic_signature_start_slot(); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
108 assert(klass == field_holder(), ""); |
3938 | 109 } |
110 FieldStreamBase(instanceKlassHandle klass) { | |
111 _fields = klass->fields(); | |
112 _constants = klass->constants(); | |
113 _index = 0; | |
114 _limit = klass->java_fields_count(); | |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
115 init_generic_signature_start_slot(); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
116 assert(klass == field_holder(), ""); |
3938 | 117 } |
118 | |
119 // accessors | |
120 int index() const { return _index; } | |
121 | |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
122 void next() { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
123 if (access_flags().field_has_generic_signature()) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
124 _generic_signature_slot ++; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
125 assert(_generic_signature_slot <= _fields->length(), ""); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
126 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
127 _index += 1; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
128 } |
3938 | 129 bool done() const { return _index >= _limit; } |
130 | |
131 // Accessors for current field | |
132 AccessFlags access_flags() const { | |
133 AccessFlags flags; | |
134 flags.set_flags(field()->access_flags()); | |
135 return flags; | |
136 } | |
137 | |
138 void set_access_flags(u2 flags) const { | |
139 field()->set_access_flags(flags); | |
140 } | |
141 | |
142 void set_access_flags(AccessFlags flags) const { | |
143 set_access_flags(flags.as_short()); | |
144 } | |
145 | |
146 Symbol* name() const { | |
147 return field()->name(_constants); | |
148 } | |
149 | |
150 Symbol* signature() const { | |
151 return field()->signature(_constants); | |
152 } | |
153 | |
154 Symbol* generic_signature() const { | |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
155 if (access_flags().field_has_generic_signature()) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
156 assert(_generic_signature_slot < _fields->length(), "out of bounds"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
157 int index = _fields->at(_generic_signature_slot); |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
158 return _constants->symbol_at(index); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
159 } else { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
160 return NULL; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
161 } |
3938 | 162 } |
163 | |
164 int offset() const { | |
165 return field()->offset(); | |
166 } | |
167 | |
7587 | 168 int allocation_type() const { |
169 return field()->allocation_type(); | |
170 } | |
171 | |
3938 | 172 void set_offset(int offset) { |
173 field()->set_offset(offset); | |
174 } | |
7587 | 175 |
176 bool is_offset_set() const { | |
177 return field()->is_offset_set(); | |
178 } | |
179 | |
180 bool is_contended() const { | |
181 return field()->is_contended(); | |
182 } | |
183 | |
184 int contended_group() const { | |
185 return field()->contended_group(); | |
186 } | |
187 | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
188 // bridge to a heavier API: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
189 fieldDescriptor& field_descriptor() const { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
190 fieldDescriptor& field = const_cast<fieldDescriptor&>(_fd_buf); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
191 field.reinitialize(field_holder(), _index); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
192 return field; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
7587
diff
changeset
|
193 } |
3938 | 194 }; |
195 | |
196 // Iterate over only the internal fields | |
197 class JavaFieldStream : public FieldStreamBase { | |
198 public: | |
199 JavaFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants(), 0, k->java_fields_count()) {} | |
200 | |
201 int name_index() const { | |
202 assert(!field()->is_internal(), "regular only"); | |
203 return field()->name_index(); | |
204 } | |
205 void set_name_index(int index) { | |
206 assert(!field()->is_internal(), "regular only"); | |
207 field()->set_name_index(index); | |
208 } | |
209 int signature_index() const { | |
210 assert(!field()->is_internal(), "regular only"); | |
211 return field()->signature_index(); | |
212 } | |
213 void set_signature_index(int index) { | |
214 assert(!field()->is_internal(), "regular only"); | |
215 field()->set_signature_index(index); | |
216 } | |
217 int generic_signature_index() const { | |
218 assert(!field()->is_internal(), "regular only"); | |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
219 if (access_flags().field_has_generic_signature()) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
220 assert(_generic_signature_slot < _fields->length(), "out of bounds"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
221 return _fields->at(_generic_signature_slot); |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
222 } else { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
223 return 0; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
224 } |
3938 | 225 } |
226 void set_generic_signature_index(int index) { | |
227 assert(!field()->is_internal(), "regular only"); | |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
228 if (access_flags().field_has_generic_signature()) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
229 assert(_generic_signature_slot < _fields->length(), "out of bounds"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
230 _fields->at_put(_generic_signature_slot, index); |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
231 } |
3938 | 232 } |
233 int initval_index() const { | |
234 assert(!field()->is_internal(), "regular only"); | |
235 return field()->initval_index(); | |
236 } | |
237 void set_initval_index(int index) { | |
238 assert(!field()->is_internal(), "regular only"); | |
239 return field()->set_initval_index(index); | |
240 } | |
241 }; | |
242 | |
243 | |
244 // Iterate over only the internal fields | |
245 class InternalFieldStream : public FieldStreamBase { | |
246 public: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
247 InternalFieldStream(InstanceKlass* k): FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), 0) {} |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
3938
diff
changeset
|
248 InternalFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), 0) {} |
3938 | 249 }; |
250 | |
251 | |
252 class AllFieldStream : public FieldStreamBase { | |
253 public: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
254 AllFieldStream(Array<u2>* fields, constantPoolHandle constants): FieldStreamBase(fields, constants) {} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6100
diff
changeset
|
255 AllFieldStream(InstanceKlass* k): FieldStreamBase(k->fields(), k->constants()) {} |
3938 | 256 AllFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants()) {} |
257 }; | |
258 | |
259 #endif // SHARE_VM_OOPS_FIELDSTREAMS_HPP |