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