Mercurial > hg > truffle
annotate src/share/vm/oops/constantPoolKlass.cpp @ 1913:3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
Summary: Allow CONSTANT_InvokeDynamic nodes to have any number of extra operands.
Reviewed-by: twisti
author | jrose |
---|---|
date | Sat, 30 Oct 2010 13:08:23 -0700 |
parents | 7fcd5f39bd7a |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_constantPoolKlass.cpp.incl" | |
27 | |
518
0af8b0718fc9
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
431
diff
changeset
|
28 constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS) { |
0 | 29 int size = constantPoolOopDesc::object_size(length); |
30 KlassHandle klass (THREAD, as_klassOop()); | |
31 constantPoolOop c = | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
32 (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); |
0 | 33 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
34 c->set_length(length); |
0 | 35 c->set_tags(NULL); |
36 c->set_cache(NULL); | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
37 c->set_operands(NULL); |
0 | 38 c->set_pool_holder(NULL); |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
39 c->set_flags(0); |
0 | 40 // only set to non-zero if constant pool is merged by RedefineClasses |
41 c->set_orig_length(0); | |
518
0af8b0718fc9
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
431
diff
changeset
|
42 // if constant pool may change during RedefineClasses, it is created |
0af8b0718fc9
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
431
diff
changeset
|
43 // unsafe for GC concurrent processing. |
0af8b0718fc9
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
431
diff
changeset
|
44 c->set_is_conc_safe(is_conc_safe); |
0 | 45 // all fields are initialized; needed for GC |
46 | |
47 // initialize tag array | |
48 // Note: cannot introduce constant pool handle before since it is not | |
49 // completely initialized (no class) -> would cause assertion failure | |
50 constantPoolHandle pool (THREAD, c); | |
51 typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL); | |
52 typeArrayHandle tags (THREAD, t_oop); | |
53 for (int index = 0; index < length; index++) { | |
54 tags()->byte_at_put(index, JVM_CONSTANT_Invalid); | |
55 } | |
56 pool->set_tags(tags()); | |
57 | |
58 return pool(); | |
59 } | |
60 | |
61 klassOop constantPoolKlass::create_klass(TRAPS) { | |
62 constantPoolKlass o; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
63 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj()); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
64 KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
65 // Make sure size calculation is right |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
66 assert(k()->size() == align_object_size(header_size()), "wrong size for object"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
67 java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror |
0 | 68 return k(); |
69 } | |
70 | |
71 int constantPoolKlass::oop_size(oop obj) const { | |
72 assert(obj->is_constantPool(), "must be constantPool"); | |
73 return constantPoolOop(obj)->object_size(); | |
74 } | |
75 | |
76 | |
77 void constantPoolKlass::oop_follow_contents(oop obj) { | |
78 assert (obj->is_constantPool(), "obj must be constant pool"); | |
79 constantPoolOop cp = (constantPoolOop) obj; | |
80 // Performance tweak: We skip iterating over the klass pointer since we | |
81 // know that Universe::constantPoolKlassObj never moves. | |
82 | |
83 // If the tags array is null we are in the middle of allocating this constant pool | |
84 if (cp->tags() != NULL) { | |
85 // gc of constant pool contents | |
86 oop* base = (oop*)cp->base(); | |
87 for (int i = 0; i < cp->length(); i++) { | |
88 if (cp->is_pointer_entry(i)) { | |
89 if (*base != NULL) MarkSweep::mark_and_push(base); | |
90 } | |
91 base++; | |
92 } | |
93 // gc of constant pool instance variables | |
94 MarkSweep::mark_and_push(cp->tags_addr()); | |
95 MarkSweep::mark_and_push(cp->cache_addr()); | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
96 MarkSweep::mark_and_push(cp->operands_addr()); |
0 | 97 MarkSweep::mark_and_push(cp->pool_holder_addr()); |
98 } | |
99 } | |
100 | |
101 #ifndef SERIALGC | |
102 void constantPoolKlass::oop_follow_contents(ParCompactionManager* cm, | |
103 oop obj) { | |
104 assert (obj->is_constantPool(), "obj must be constant pool"); | |
105 constantPoolOop cp = (constantPoolOop) obj; | |
106 // Performance tweak: We skip iterating over the klass pointer since we | |
107 // know that Universe::constantPoolKlassObj never moves. | |
108 | |
109 // If the tags array is null we are in the middle of allocating this constant | |
110 // pool. | |
111 if (cp->tags() != NULL) { | |
112 // gc of constant pool contents | |
113 oop* base = (oop*)cp->base(); | |
114 for (int i = 0; i < cp->length(); i++) { | |
115 if (cp->is_pointer_entry(i)) { | |
116 if (*base != NULL) PSParallelCompact::mark_and_push(cm, base); | |
117 } | |
118 base++; | |
119 } | |
120 // gc of constant pool instance variables | |
121 PSParallelCompact::mark_and_push(cm, cp->tags_addr()); | |
122 PSParallelCompact::mark_and_push(cm, cp->cache_addr()); | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
123 PSParallelCompact::mark_and_push(cm, cp->operands_addr()); |
0 | 124 PSParallelCompact::mark_and_push(cm, cp->pool_holder_addr()); |
125 } | |
126 } | |
127 #endif // SERIALGC | |
128 | |
129 | |
130 int constantPoolKlass::oop_adjust_pointers(oop obj) { | |
131 assert (obj->is_constantPool(), "obj must be constant pool"); | |
132 constantPoolOop cp = (constantPoolOop) obj; | |
133 // Get size before changing pointers. | |
134 // Don't call size() or oop_size() since that is a virtual call. | |
135 int size = cp->object_size(); | |
136 // Performance tweak: We skip iterating over the klass pointer since we | |
137 // know that Universe::constantPoolKlassObj never moves. | |
138 | |
139 // If the tags array is null we are in the middle of allocating this constant | |
140 // pool. | |
141 if (cp->tags() != NULL) { | |
142 oop* base = (oop*)cp->base(); | |
143 for (int i = 0; i< cp->length(); i++) { | |
144 if (cp->is_pointer_entry(i)) { | |
145 MarkSweep::adjust_pointer(base); | |
146 } | |
147 base++; | |
148 } | |
149 } | |
150 MarkSweep::adjust_pointer(cp->tags_addr()); | |
151 MarkSweep::adjust_pointer(cp->cache_addr()); | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
152 MarkSweep::adjust_pointer(cp->operands_addr()); |
0 | 153 MarkSweep::adjust_pointer(cp->pool_holder_addr()); |
154 return size; | |
155 } | |
156 | |
157 | |
158 int constantPoolKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
159 assert (obj->is_constantPool(), "obj must be constant pool"); | |
160 // Performance tweak: We skip iterating over the klass pointer since we | |
161 // know that Universe::constantPoolKlassObj never moves. | |
162 constantPoolOop cp = (constantPoolOop) obj; | |
163 // Get size before changing pointers. | |
164 // Don't call size() or oop_size() since that is a virtual call. | |
165 int size = cp->object_size(); | |
166 | |
167 // If the tags array is null we are in the middle of allocating this constant | |
168 // pool. | |
169 if (cp->tags() != NULL) { | |
170 oop* base = (oop*)cp->base(); | |
171 for (int i = 0; i < cp->length(); i++) { | |
172 if (cp->is_pointer_entry(i)) { | |
173 blk->do_oop(base); | |
174 } | |
175 base++; | |
176 } | |
177 } | |
178 blk->do_oop(cp->tags_addr()); | |
179 blk->do_oop(cp->cache_addr()); | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
180 blk->do_oop(cp->operands_addr()); |
0 | 181 blk->do_oop(cp->pool_holder_addr()); |
182 return size; | |
183 } | |
184 | |
185 | |
186 int constantPoolKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { | |
187 assert (obj->is_constantPool(), "obj must be constant pool"); | |
188 // Performance tweak: We skip iterating over the klass pointer since we | |
189 // know that Universe::constantPoolKlassObj never moves. | |
190 constantPoolOop cp = (constantPoolOop) obj; | |
191 // Get size before changing pointers. | |
192 // Don't call size() or oop_size() since that is a virtual call. | |
193 int size = cp->object_size(); | |
194 | |
195 // If the tags array is null we are in the middle of allocating this constant | |
196 // pool. | |
197 if (cp->tags() != NULL) { | |
198 oop* base = (oop*)cp->base(); | |
199 for (int i = 0; i < cp->length(); i++) { | |
200 if (mr.contains(base)) { | |
201 if (cp->is_pointer_entry(i)) { | |
202 blk->do_oop(base); | |
203 } | |
204 } | |
205 base++; | |
206 } | |
207 } | |
208 oop* addr; | |
209 addr = cp->tags_addr(); | |
210 blk->do_oop(addr); | |
211 addr = cp->cache_addr(); | |
212 blk->do_oop(addr); | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
213 addr = cp->operands_addr(); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
214 blk->do_oop(addr); |
0 | 215 addr = cp->pool_holder_addr(); |
216 blk->do_oop(addr); | |
217 return size; | |
218 } | |
219 | |
518
0af8b0718fc9
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
431
diff
changeset
|
220 bool constantPoolKlass::oop_is_conc_safe(oop obj) const { |
0af8b0718fc9
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
431
diff
changeset
|
221 assert(obj->is_constantPool(), "must be constantPool"); |
0af8b0718fc9
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
431
diff
changeset
|
222 return constantPoolOop(obj)->is_conc_safe(); |
0af8b0718fc9
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
431
diff
changeset
|
223 } |
0af8b0718fc9
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
431
diff
changeset
|
224 |
0 | 225 #ifndef SERIALGC |
226 int constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
227 assert (obj->is_constantPool(), "obj must be constant pool"); | |
228 constantPoolOop cp = (constantPoolOop) obj; | |
229 | |
230 // If the tags array is null we are in the middle of allocating this constant | |
231 // pool. | |
232 if (cp->tags() != NULL) { | |
233 oop* base = (oop*)cp->base(); | |
234 for (int i = 0; i < cp->length(); ++i, ++base) { | |
235 if (cp->is_pointer_entry(i)) { | |
236 PSParallelCompact::adjust_pointer(base); | |
237 } | |
238 } | |
239 } | |
240 PSParallelCompact::adjust_pointer(cp->tags_addr()); | |
241 PSParallelCompact::adjust_pointer(cp->cache_addr()); | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
242 PSParallelCompact::adjust_pointer(cp->operands_addr()); |
0 | 243 PSParallelCompact::adjust_pointer(cp->pool_holder_addr()); |
244 return cp->object_size(); | |
245 } | |
246 | |
247 int | |
248 constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, | |
249 HeapWord* beg_addr, HeapWord* end_addr) { | |
250 assert (obj->is_constantPool(), "obj must be constant pool"); | |
251 constantPoolOop cp = (constantPoolOop) obj; | |
252 | |
253 // If the tags array is null we are in the middle of allocating this constant | |
254 // pool. | |
255 if (cp->tags() != NULL) { | |
256 oop* base = (oop*)cp->base(); | |
257 oop* const beg_oop = MAX2((oop*)beg_addr, base); | |
258 oop* const end_oop = MIN2((oop*)end_addr, base + cp->length()); | |
259 const size_t beg_idx = pointer_delta(beg_oop, base, sizeof(oop*)); | |
260 const size_t end_idx = pointer_delta(end_oop, base, sizeof(oop*)); | |
261 for (size_t cur_idx = beg_idx; cur_idx < end_idx; ++cur_idx, ++base) { | |
262 if (cp->is_pointer_entry(int(cur_idx))) { | |
263 PSParallelCompact::adjust_pointer(base); | |
264 } | |
265 } | |
266 } | |
267 | |
268 oop* p; | |
269 p = cp->tags_addr(); | |
270 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
271 p = cp->cache_addr(); | |
272 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
273 p = cp->operands_addr(); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
274 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); |
0 | 275 p = cp->pool_holder_addr(); |
276 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
277 | |
278 return cp->object_size(); | |
279 } | |
280 | |
281 void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
282 assert(obj->is_constantPool(), "should be constant pool"); | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
283 constantPoolOop cp = (constantPoolOop) obj; |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
284 if (AnonymousClasses && cp->has_pseudo_string() && cp->tags() != NULL) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
285 oop* base = (oop*)cp->base(); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
286 for (int i = 0; i < cp->length(); ++i, ++base) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
287 if (cp->tag_at(i).is_string()) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
288 if (PSScavenge::should_scavenge(base)) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
289 pm->claim_or_forward_depth(base); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
290 } |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
291 } |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
292 } |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
293 } |
0 | 294 } |
295 #endif // SERIALGC | |
296 | |
297 // Printing | |
298 | |
299 void constantPoolKlass::oop_print_on(oop obj, outputStream* st) { | |
300 EXCEPTION_MARK; | |
301 oop anObj; | |
302 assert(obj->is_constantPool(), "must be constantPool"); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
303 Klass::oop_print_on(obj, st); |
0 | 304 constantPoolOop cp = constantPoolOop(obj); |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
305 if (cp->flags() != 0) { |
1573
beb77f0d41b3
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
1155
diff
changeset
|
306 st->print(" - flags: 0x%x", cp->flags()); |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
307 if (cp->has_pseudo_string()) st->print(" has_pseudo_string"); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
579
diff
changeset
|
308 if (cp->has_invokedynamic()) st->print(" has_invokedynamic"); |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
309 st->cr(); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
310 } |
1573
beb77f0d41b3
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
1155
diff
changeset
|
311 st->print_cr(" - cache: " INTPTR_FORMAT, cp->cache()); |
0 | 312 |
313 for (int index = 1; index < cp->length(); index++) { // Index 0 is unused | |
314 st->print(" - %3d : ", index); | |
315 cp->tag_at(index).print_on(st); | |
316 st->print(" : "); | |
317 switch (cp->tag_at(index).value()) { | |
318 case JVM_CONSTANT_Class : | |
319 { anObj = cp->klass_at(index, CATCH); | |
320 anObj->print_value_on(st); | |
321 st->print(" {0x%lx}", (address)anObj); | |
322 } | |
323 break; | |
324 case JVM_CONSTANT_Fieldref : | |
325 case JVM_CONSTANT_Methodref : | |
326 case JVM_CONSTANT_InterfaceMethodref : | |
1573
beb77f0d41b3
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
1155
diff
changeset
|
327 st->print("klass_index=%d", cp->uncached_klass_ref_index_at(index)); |
beb77f0d41b3
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
1155
diff
changeset
|
328 st->print(" name_and_type_index=%d", cp->uncached_name_and_type_ref_index_at(index)); |
0 | 329 break; |
330 case JVM_CONSTANT_UnresolvedString : | |
331 case JVM_CONSTANT_String : | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
332 if (cp->is_pseudo_string_at(index)) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
333 anObj = cp->pseudo_string_at(index); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
334 } else { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
335 anObj = cp->string_at(index, CATCH); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
336 } |
0 | 337 anObj->print_value_on(st); |
338 st->print(" {0x%lx}", (address)anObj); | |
339 break; | |
340 case JVM_CONSTANT_Integer : | |
341 st->print("%d", cp->int_at(index)); | |
342 break; | |
343 case JVM_CONSTANT_Float : | |
344 st->print("%f", cp->float_at(index)); | |
345 break; | |
346 case JVM_CONSTANT_Long : | |
347 st->print_jlong(cp->long_at(index)); | |
348 index++; // Skip entry following eigth-byte constant | |
349 break; | |
350 case JVM_CONSTANT_Double : | |
351 st->print("%lf", cp->double_at(index)); | |
352 index++; // Skip entry following eigth-byte constant | |
353 break; | |
354 case JVM_CONSTANT_NameAndType : | |
355 st->print("name_index=%d", cp->name_ref_index_at(index)); | |
356 st->print(" signature_index=%d", cp->signature_ref_index_at(index)); | |
357 break; | |
358 case JVM_CONSTANT_Utf8 : | |
359 cp->symbol_at(index)->print_value_on(st); | |
360 break; | |
361 case JVM_CONSTANT_UnresolvedClass : // fall-through | |
362 case JVM_CONSTANT_UnresolvedClassInError: { | |
363 // unresolved_klass_at requires lock or safe world. | |
364 oop entry = *cp->obj_at_addr(index); | |
365 entry->print_value_on(st); | |
366 } | |
367 break; | |
1602 | 368 case JVM_CONSTANT_MethodHandle : |
369 st->print("ref_kind=%d", cp->method_handle_ref_kind_at(index)); | |
370 st->print(" ref_index=%d", cp->method_handle_index_at(index)); | |
371 break; | |
372 case JVM_CONSTANT_MethodType : | |
373 st->print("signature_index=%d", cp->method_type_index_at(index)); | |
374 break; | |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
375 case JVM_CONSTANT_InvokeDynamic : |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
376 { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
377 st->print("bootstrap_method_index=%d", cp->invoke_dynamic_bootstrap_method_ref_index_at(index)); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
378 st->print(" name_and_type_index=%d", cp->invoke_dynamic_name_and_type_ref_index_at(index)); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
379 int argc = cp->invoke_dynamic_argument_count_at(index); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
380 if (argc > 0) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
381 for (int arg_i = 0; arg_i < argc; arg_i++) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
382 int arg = cp->invoke_dynamic_argument_index_at(index, arg_i); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
383 st->print((arg_i == 0 ? " arguments={%d" : ", %d"), arg); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
384 } |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
385 st->print("}"); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
386 } |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
387 } |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1602
diff
changeset
|
388 break; |
0 | 389 default: |
390 ShouldNotReachHere(); | |
391 break; | |
392 } | |
393 st->cr(); | |
394 } | |
395 st->cr(); | |
396 } | |
397 | |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
726
diff
changeset
|
398 void constantPoolKlass::oop_print_value_on(oop obj, outputStream* st) { |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
726
diff
changeset
|
399 assert(obj->is_constantPool(), "must be constantPool"); |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
726
diff
changeset
|
400 constantPoolOop cp = constantPoolOop(obj); |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
726
diff
changeset
|
401 st->print("constant pool [%d]", cp->length()); |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
726
diff
changeset
|
402 if (cp->has_pseudo_string()) st->print("/pseudo_string"); |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
726
diff
changeset
|
403 if (cp->has_invokedynamic()) st->print("/invokedynamic"); |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
404 if (cp->operands() != NULL) st->print("/operands[%d]", cp->operands()->length()); |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
726
diff
changeset
|
405 cp->print_address_on(st); |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
726
diff
changeset
|
406 st->print(" for "); |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
726
diff
changeset
|
407 cp->pool_holder()->print_value_on(st); |
1573
beb77f0d41b3
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
1155
diff
changeset
|
408 if (cp->cache() != NULL) { |
beb77f0d41b3
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
1155
diff
changeset
|
409 st->print(" cache=" PTR_FORMAT, cp->cache()); |
beb77f0d41b3
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
1155
diff
changeset
|
410 } |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
726
diff
changeset
|
411 } |
0 | 412 |
413 const char* constantPoolKlass::internal_name() const { | |
414 return "{constant pool}"; | |
415 } | |
416 | |
417 // Verification | |
418 | |
419 void constantPoolKlass::oop_verify_on(oop obj, outputStream* st) { | |
420 Klass::oop_verify_on(obj, st); | |
421 guarantee(obj->is_constantPool(), "object must be constant pool"); | |
422 constantPoolOop cp = constantPoolOop(obj); | |
423 guarantee(cp->is_perm(), "should be in permspace"); | |
424 if (!cp->partially_loaded()) { | |
425 oop* base = (oop*)cp->base(); | |
426 for (int i = 0; i< cp->length(); i++) { | |
427 if (cp->tag_at(i).is_klass()) { | |
428 guarantee((*base)->is_perm(), "should be in permspace"); | |
429 guarantee((*base)->is_klass(), "should be klass"); | |
430 } | |
431 if (cp->tag_at(i).is_unresolved_klass()) { | |
432 guarantee((*base)->is_perm(), "should be in permspace"); | |
433 guarantee((*base)->is_symbol() || (*base)->is_klass(), | |
434 "should be symbol or klass"); | |
435 } | |
436 if (cp->tag_at(i).is_symbol()) { | |
437 guarantee((*base)->is_perm(), "should be in permspace"); | |
438 guarantee((*base)->is_symbol(), "should be symbol"); | |
439 } | |
440 if (cp->tag_at(i).is_unresolved_string()) { | |
441 guarantee((*base)->is_perm(), "should be in permspace"); | |
442 guarantee((*base)->is_symbol() || (*base)->is_instance(), | |
443 "should be symbol or instance"); | |
444 } | |
445 if (cp->tag_at(i).is_string()) { | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
446 if (!cp->has_pseudo_string()) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
447 guarantee((*base)->is_perm(), "should be in permspace"); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
448 guarantee((*base)->is_instance(), "should be instance"); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
449 } else { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
450 // can be non-perm, can be non-instance (array) |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
451 } |
0 | 452 } |
1602 | 453 // FIXME: verify JSR 292 tags JVM_CONSTANT_MethodHandle, etc. |
0 | 454 base++; |
455 } | |
456 guarantee(cp->tags()->is_perm(), "should be in permspace"); | |
457 guarantee(cp->tags()->is_typeArray(), "should be type array"); | |
458 if (cp->cache() != NULL) { | |
459 // Note: cache() can be NULL before a class is completely setup or | |
460 // in temporary constant pools used during constant pool merging | |
461 guarantee(cp->cache()->is_perm(), "should be in permspace"); | |
462 guarantee(cp->cache()->is_constantPoolCache(), "should be constant pool cache"); | |
463 } | |
1913
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
464 if (cp->operands() != NULL) { |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
465 guarantee(cp->operands()->is_perm(), "should be in permspace"); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
466 guarantee(cp->operands()->is_typeArray(), "should be type array"); |
3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
1713
diff
changeset
|
467 } |
0 | 468 if (cp->pool_holder() != NULL) { |
469 // Note: pool_holder() can be NULL in temporary constant pools | |
470 // used during constant pool merging | |
471 guarantee(cp->pool_holder()->is_perm(), "should be in permspace"); | |
472 guarantee(cp->pool_holder()->is_klass(), "should be klass"); | |
473 } | |
474 } | |
475 } | |
476 | |
477 bool constantPoolKlass::oop_partially_loaded(oop obj) const { | |
478 assert(obj->is_constantPool(), "object must be constant pool"); | |
479 constantPoolOop cp = constantPoolOop(obj); | |
480 return cp->tags() == NULL || cp->pool_holder() == (klassOop) cp; // Check whether pool holder points to self | |
481 } | |
482 | |
483 | |
484 void constantPoolKlass::oop_set_partially_loaded(oop obj) { | |
485 assert(obj->is_constantPool(), "object must be constant pool"); | |
486 constantPoolOop cp = constantPoolOop(obj); | |
487 assert(cp->pool_holder() == NULL, "just checking"); | |
488 cp->set_pool_holder((klassOop) cp); // Temporarily set pool holder to point to self | |
489 } | |
490 | |
491 #ifndef PRODUCT | |
492 // CompileTheWorld support. Preload all classes loaded references in the passed in constantpool | |
493 void constantPoolKlass::preload_and_initialize_all_classes(oop obj, TRAPS) { | |
494 guarantee(obj->is_constantPool(), "object must be constant pool"); | |
495 constantPoolHandle cp(THREAD, (constantPoolOop)obj); | |
496 guarantee(!cp->partially_loaded(), "must be fully loaded"); | |
497 | |
498 for (int i = 0; i< cp->length(); i++) { | |
499 if (cp->tag_at(i).is_unresolved_klass()) { | |
500 // This will force loading of the class | |
501 klassOop klass = cp->klass_at(i, CHECK); | |
502 if (klass->is_instance()) { | |
503 // Force initialization of class | |
504 instanceKlass::cast(klass)->initialize(CHECK); | |
505 } | |
506 } | |
507 } | |
508 } | |
509 | |
510 #endif |