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