author | ysr |
Thu, 10 Feb 2011 14:48:07 -0800 | |
changeset 8299 | 70d329dddda3 |
parent 8297 | f05d10c1c4b8 |
child 8728 | 3f1bcd33068e |
permissions | -rw-r--r-- |
1 | 1 |
/* |
8297 | 2 |
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4584
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4584
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4584
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 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" |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
36 |
#include "oops/symbol.hpp" |
7397 | 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 |
|
1 | 54 |
|
1894
5c343868d071
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
1550
diff
changeset
|
55 |
constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS) { |
1 | 56 |
int size = constantPoolOopDesc::object_size(length); |
57 |
KlassHandle klass (THREAD, as_klassOop()); |
|
8299
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
58 |
assert(klass()->is_oop(), "Can't be null, else handlizing of c below won't work"); |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
59 |
constantPoolHandle pool; |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
60 |
{ |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
61 |
constantPoolOop c = |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
62 |
(constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
63 |
assert(c->klass_or_null() != NULL, "Handlizing below won't work"); |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
64 |
pool = constantPoolHandle(THREAD, c); |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
65 |
} |
1 | 66 |
|
8299
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
67 |
pool->set_length(length); |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
68 |
pool->set_tags(NULL); |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
69 |
pool->set_cache(NULL); |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
70 |
pool->set_operands(NULL); |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
71 |
pool->set_pool_holder(NULL); |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
72 |
pool->set_flags(0); |
1 | 73 |
// only set to non-zero if constant pool is merged by RedefineClasses |
8299
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
74 |
pool->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
|
75 |
// 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
|
76 |
// unsafe for GC concurrent processing. |
8299
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
77 |
pool->set_is_conc_safe(is_conc_safe); |
1 | 78 |
// all fields are initialized; needed for GC |
79 |
||
8296
b1c2163e4e59
6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?")
ysr
parents:
8076
diff
changeset
|
80 |
// Note: because we may be in this "conc_unsafe" state when allocating |
b1c2163e4e59
6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?")
ysr
parents:
8076
diff
changeset
|
81 |
// t_oop below, which may in turn cause a GC, it is imperative that our |
b1c2163e4e59
6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?")
ysr
parents:
8076
diff
changeset
|
82 |
// size be correct, consistent and henceforth stable, at this stage. |
8299
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
83 |
assert(pool->is_oop() && pool->is_parsable(), "Else size() below is unreliable"); |
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
84 |
assert(size == pool->size(), "size() is wrong"); |
8296
b1c2163e4e59
6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?")
ysr
parents:
8076
diff
changeset
|
85 |
|
1 | 86 |
// initialize tag array |
87 |
typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL); |
|
88 |
typeArrayHandle tags (THREAD, t_oop); |
|
89 |
for (int index = 0; index < length; index++) { |
|
90 |
tags()->byte_at_put(index, JVM_CONSTANT_Invalid); |
|
91 |
} |
|
92 |
pool->set_tags(tags()); |
|
93 |
||
8296
b1c2163e4e59
6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?")
ysr
parents:
8076
diff
changeset
|
94 |
// Check that our size was stable at its old value. |
8299
70d329dddda3
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
ysr
parents:
8297
diff
changeset
|
95 |
assert(size == pool->size(), "size() changed"); |
1 | 96 |
return pool(); |
97 |
} |
|
98 |
||
99 |
klassOop constantPoolKlass::create_klass(TRAPS) { |
|
100 |
constantPoolKlass o; |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
101 |
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
|
102 |
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
|
103 |
// 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
|
104 |
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
|
105 |
java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror |
1 | 106 |
return k(); |
107 |
} |
|
108 |
||
109 |
int constantPoolKlass::oop_size(oop obj) const { |
|
110 |
assert(obj->is_constantPool(), "must be constantPool"); |
|
111 |
return constantPoolOop(obj)->object_size(); |
|
112 |
} |
|
113 |
||
114 |
||
115 |
void constantPoolKlass::oop_follow_contents(oop obj) { |
|
116 |
assert (obj->is_constantPool(), "obj must be constant pool"); |
|
117 |
constantPoolOop cp = (constantPoolOop) obj; |
|
118 |
// Performance tweak: We skip iterating over the klass pointer since we |
|
119 |
// know that Universe::constantPoolKlassObj never moves. |
|
120 |
||
121 |
// If the tags array is null we are in the middle of allocating this constant pool |
|
122 |
if (cp->tags() != NULL) { |
|
123 |
// gc of constant pool contents |
|
124 |
oop* base = (oop*)cp->base(); |
|
125 |
for (int i = 0; i < cp->length(); i++) { |
|
126 |
if (cp->is_pointer_entry(i)) { |
|
127 |
if (*base != NULL) MarkSweep::mark_and_push(base); |
|
128 |
} |
|
129 |
base++; |
|
130 |
} |
|
131 |
// gc of constant pool instance variables |
|
132 |
MarkSweep::mark_and_push(cp->tags_addr()); |
|
133 |
MarkSweep::mark_and_push(cp->cache_addr()); |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
134 |
MarkSweep::mark_and_push(cp->operands_addr()); |
1 | 135 |
MarkSweep::mark_and_push(cp->pool_holder_addr()); |
136 |
} |
|
137 |
} |
|
138 |
||
139 |
#ifndef SERIALGC |
|
140 |
void constantPoolKlass::oop_follow_contents(ParCompactionManager* cm, |
|
141 |
oop obj) { |
|
142 |
assert (obj->is_constantPool(), "obj must be constant pool"); |
|
143 |
constantPoolOop cp = (constantPoolOop) obj; |
|
144 |
// Performance tweak: We skip iterating over the klass pointer since we |
|
145 |
// know that Universe::constantPoolKlassObj never moves. |
|
146 |
||
147 |
// If the tags array is null we are in the middle of allocating this constant |
|
148 |
// pool. |
|
149 |
if (cp->tags() != NULL) { |
|
150 |
// gc of constant pool contents |
|
151 |
oop* base = (oop*)cp->base(); |
|
152 |
for (int i = 0; i < cp->length(); i++) { |
|
153 |
if (cp->is_pointer_entry(i)) { |
|
154 |
if (*base != NULL) PSParallelCompact::mark_and_push(cm, base); |
|
155 |
} |
|
156 |
base++; |
|
157 |
} |
|
158 |
// gc of constant pool instance variables |
|
159 |
PSParallelCompact::mark_and_push(cm, cp->tags_addr()); |
|
160 |
PSParallelCompact::mark_and_push(cm, cp->cache_addr()); |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
161 |
PSParallelCompact::mark_and_push(cm, cp->operands_addr()); |
1 | 162 |
PSParallelCompact::mark_and_push(cm, cp->pool_holder_addr()); |
163 |
} |
|
164 |
} |
|
165 |
#endif // SERIALGC |
|
166 |
||
167 |
||
168 |
int constantPoolKlass::oop_adjust_pointers(oop obj) { |
|
169 |
assert (obj->is_constantPool(), "obj must be constant pool"); |
|
170 |
constantPoolOop cp = (constantPoolOop) obj; |
|
171 |
// Get size before changing pointers. |
|
172 |
// Don't call size() or oop_size() since that is a virtual call. |
|
173 |
int size = cp->object_size(); |
|
174 |
// Performance tweak: We skip iterating over the klass pointer since we |
|
175 |
// know that Universe::constantPoolKlassObj never moves. |
|
176 |
||
177 |
// If the tags array is null we are in the middle of allocating this constant |
|
178 |
// pool. |
|
179 |
if (cp->tags() != NULL) { |
|
180 |
oop* base = (oop*)cp->base(); |
|
181 |
for (int i = 0; i< cp->length(); i++) { |
|
182 |
if (cp->is_pointer_entry(i)) { |
|
183 |
MarkSweep::adjust_pointer(base); |
|
184 |
} |
|
185 |
base++; |
|
186 |
} |
|
187 |
} |
|
188 |
MarkSweep::adjust_pointer(cp->tags_addr()); |
|
189 |
MarkSweep::adjust_pointer(cp->cache_addr()); |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
190 |
MarkSweep::adjust_pointer(cp->operands_addr()); |
1 | 191 |
MarkSweep::adjust_pointer(cp->pool_holder_addr()); |
192 |
return size; |
|
193 |
} |
|
194 |
||
195 |
||
196 |
int constantPoolKlass::oop_oop_iterate(oop obj, OopClosure* blk) { |
|
197 |
assert (obj->is_constantPool(), "obj must be constant pool"); |
|
198 |
// Performance tweak: We skip iterating over the klass pointer since we |
|
199 |
// know that Universe::constantPoolKlassObj never moves. |
|
200 |
constantPoolOop cp = (constantPoolOop) obj; |
|
201 |
// Get size before changing pointers. |
|
202 |
// Don't call size() or oop_size() since that is a virtual call. |
|
203 |
int size = cp->object_size(); |
|
204 |
||
205 |
// If the tags array is null we are in the middle of allocating this constant |
|
206 |
// pool. |
|
207 |
if (cp->tags() != NULL) { |
|
208 |
oop* base = (oop*)cp->base(); |
|
209 |
for (int i = 0; i < cp->length(); i++) { |
|
210 |
if (cp->is_pointer_entry(i)) { |
|
211 |
blk->do_oop(base); |
|
212 |
} |
|
213 |
base++; |
|
214 |
} |
|
215 |
} |
|
216 |
blk->do_oop(cp->tags_addr()); |
|
217 |
blk->do_oop(cp->cache_addr()); |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
218 |
blk->do_oop(cp->operands_addr()); |
1 | 219 |
blk->do_oop(cp->pool_holder_addr()); |
220 |
return size; |
|
221 |
} |
|
222 |
||
223 |
||
224 |
int constantPoolKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { |
|
225 |
assert (obj->is_constantPool(), "obj must be constant pool"); |
|
226 |
// Performance tweak: We skip iterating over the klass pointer since we |
|
227 |
// know that Universe::constantPoolKlassObj never moves. |
|
228 |
constantPoolOop cp = (constantPoolOop) obj; |
|
229 |
// Get size before changing pointers. |
|
230 |
// Don't call size() or oop_size() since that is a virtual call. |
|
231 |
int size = cp->object_size(); |
|
232 |
||
233 |
// If the tags array is null we are in the middle of allocating this constant |
|
234 |
// pool. |
|
235 |
if (cp->tags() != NULL) { |
|
236 |
oop* base = (oop*)cp->base(); |
|
237 |
for (int i = 0; i < cp->length(); i++) { |
|
238 |
if (mr.contains(base)) { |
|
239 |
if (cp->is_pointer_entry(i)) { |
|
240 |
blk->do_oop(base); |
|
241 |
} |
|
242 |
} |
|
243 |
base++; |
|
244 |
} |
|
245 |
} |
|
246 |
oop* addr; |
|
247 |
addr = cp->tags_addr(); |
|
248 |
blk->do_oop(addr); |
|
249 |
addr = cp->cache_addr(); |
|
250 |
blk->do_oop(addr); |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
251 |
addr = cp->operands_addr(); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
252 |
blk->do_oop(addr); |
1 | 253 |
addr = cp->pool_holder_addr(); |
254 |
blk->do_oop(addr); |
|
255 |
return size; |
|
256 |
} |
|
257 |
||
1894
5c343868d071
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
1550
diff
changeset
|
258 |
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
|
259 |
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
|
260 |
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
|
261 |
} |
5c343868d071
6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents:
1550
diff
changeset
|
262 |
|
1 | 263 |
#ifndef SERIALGC |
264 |
int constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { |
|
265 |
assert (obj->is_constantPool(), "obj must be constant pool"); |
|
266 |
constantPoolOop cp = (constantPoolOop) obj; |
|
267 |
||
268 |
// If the tags array is null we are in the middle of allocating this constant |
|
269 |
// pool. |
|
270 |
if (cp->tags() != NULL) { |
|
271 |
oop* base = (oop*)cp->base(); |
|
272 |
for (int i = 0; i < cp->length(); ++i, ++base) { |
|
273 |
if (cp->is_pointer_entry(i)) { |
|
274 |
PSParallelCompact::adjust_pointer(base); |
|
275 |
} |
|
276 |
} |
|
277 |
} |
|
278 |
PSParallelCompact::adjust_pointer(cp->tags_addr()); |
|
279 |
PSParallelCompact::adjust_pointer(cp->cache_addr()); |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
280 |
PSParallelCompact::adjust_pointer(cp->operands_addr()); |
1 | 281 |
PSParallelCompact::adjust_pointer(cp->pool_holder_addr()); |
282 |
return cp->object_size(); |
|
283 |
} |
|
284 |
||
285 |
void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { |
|
286 |
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
|
287 |
constantPoolOop cp = (constantPoolOop) obj; |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
288 |
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
|
289 |
oop* base = (oop*)cp->base(); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
290 |
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
|
291 |
if (cp->tag_at(i).is_string()) { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
292 |
if (PSScavenge::should_scavenge(base)) { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
293 |
pm->claim_or_forward_depth(base); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
294 |
} |
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 |
} |
1 | 298 |
} |
299 |
#endif // SERIALGC |
|
300 |
||
301 |
// Printing |
|
302 |
||
303 |
void constantPoolKlass::oop_print_on(oop obj, outputStream* st) { |
|
304 |
EXCEPTION_MARK; |
|
305 |
oop anObj; |
|
306 |
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
|
307 |
Klass::oop_print_on(obj, st); |
1 | 308 |
constantPoolOop cp = constantPoolOop(obj); |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
309 |
if (cp->flags() != 0) { |
5696
93e15b419ad4
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
4584
diff
changeset
|
310 |
st->print(" - flags: 0x%x", cp->flags()); |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
311 |
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
|
312 |
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
|
313 |
st->cr(); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
314 |
} |
5696
93e15b419ad4
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
4584
diff
changeset
|
315 |
st->print_cr(" - cache: " INTPTR_FORMAT, cp->cache()); |
1 | 316 |
|
317 |
for (int index = 1; index < cp->length(); index++) { // Index 0 is unused |
|
318 |
st->print(" - %3d : ", index); |
|
319 |
cp->tag_at(index).print_on(st); |
|
320 |
st->print(" : "); |
|
321 |
switch (cp->tag_at(index).value()) { |
|
322 |
case JVM_CONSTANT_Class : |
|
323 |
{ anObj = cp->klass_at(index, CATCH); |
|
324 |
anObj->print_value_on(st); |
|
325 |
st->print(" {0x%lx}", (address)anObj); |
|
326 |
} |
|
327 |
break; |
|
328 |
case JVM_CONSTANT_Fieldref : |
|
329 |
case JVM_CONSTANT_Methodref : |
|
330 |
case JVM_CONSTANT_InterfaceMethodref : |
|
5696
93e15b419ad4
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
4584
diff
changeset
|
331 |
st->print("klass_index=%d", cp->uncached_klass_ref_index_at(index)); |
93e15b419ad4
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
4584
diff
changeset
|
332 |
st->print(" name_and_type_index=%d", cp->uncached_name_and_type_ref_index_at(index)); |
1 | 333 |
break; |
334 |
case JVM_CONSTANT_UnresolvedString : |
|
335 |
case JVM_CONSTANT_String : |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
336 |
if (cp->is_pseudo_string_at(index)) { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
337 |
anObj = cp->pseudo_string_at(index); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
338 |
} else { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
339 |
anObj = cp->string_at(index, CATCH); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
340 |
} |
1 | 341 |
anObj->print_value_on(st); |
342 |
st->print(" {0x%lx}", (address)anObj); |
|
343 |
break; |
|
344 |
case JVM_CONSTANT_Integer : |
|
345 |
st->print("%d", cp->int_at(index)); |
|
346 |
break; |
|
347 |
case JVM_CONSTANT_Float : |
|
348 |
st->print("%f", cp->float_at(index)); |
|
349 |
break; |
|
350 |
case JVM_CONSTANT_Long : |
|
351 |
st->print_jlong(cp->long_at(index)); |
|
352 |
index++; // Skip entry following eigth-byte constant |
|
353 |
break; |
|
354 |
case JVM_CONSTANT_Double : |
|
355 |
st->print("%lf", cp->double_at(index)); |
|
356 |
index++; // Skip entry following eigth-byte constant |
|
357 |
break; |
|
358 |
case JVM_CONSTANT_NameAndType : |
|
359 |
st->print("name_index=%d", cp->name_ref_index_at(index)); |
|
360 |
st->print(" signature_index=%d", cp->signature_ref_index_at(index)); |
|
361 |
break; |
|
362 |
case JVM_CONSTANT_Utf8 : |
|
363 |
cp->symbol_at(index)->print_value_on(st); |
|
364 |
break; |
|
365 |
case JVM_CONSTANT_UnresolvedClass : // fall-through |
|
366 |
case JVM_CONSTANT_UnresolvedClassInError: { |
|
367 |
// unresolved_klass_at requires lock or safe world. |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
368 |
CPSlot entry = cp->slot_at(index); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
369 |
if (entry.is_oop()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
370 |
entry.get_oop()->print_value_on(st); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
371 |
} else { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
372 |
entry.get_symbol()->print_value_on(st); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
373 |
} |
1 | 374 |
} |
375 |
break; |
|
5882 | 376 |
case JVM_CONSTANT_MethodHandle : |
377 |
st->print("ref_kind=%d", cp->method_handle_ref_kind_at(index)); |
|
378 |
st->print(" ref_index=%d", cp->method_handle_index_at(index)); |
|
379 |
break; |
|
380 |
case JVM_CONSTANT_MethodType : |
|
381 |
st->print("signature_index=%d", cp->method_type_index_at(index)); |
|
382 |
break; |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
383 |
case JVM_CONSTANT_InvokeDynamicTrans : |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
384 |
case JVM_CONSTANT_InvokeDynamic : |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
385 |
{ |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
386 |
st->print("bootstrap_method_index=%d", cp->invoke_dynamic_bootstrap_method_ref_index_at(index)); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
387 |
st->print(" name_and_type_index=%d", cp->invoke_dynamic_name_and_type_ref_index_at(index)); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
388 |
int argc = cp->invoke_dynamic_argument_count_at(index); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
389 |
if (argc > 0) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
390 |
for (int arg_i = 0; arg_i < argc; arg_i++) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
391 |
int arg = cp->invoke_dynamic_argument_index_at(index, arg_i); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
392 |
st->print((arg_i == 0 ? " arguments={%d" : ", %d"), arg); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
393 |
} |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
394 |
st->print("}"); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
395 |
} |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
396 |
} |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
397 |
break; |
1 | 398 |
default: |
399 |
ShouldNotReachHere(); |
|
400 |
break; |
|
401 |
} |
|
402 |
st->cr(); |
|
403 |
} |
|
404 |
st->cr(); |
|
405 |
} |
|
406 |
||
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
2570
diff
changeset
|
407 |
void constantPoolKlass::oop_print_value_on(oop obj, outputStream* st) { |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
2570
diff
changeset
|
408 |
assert(obj->is_constantPool(), "must be constantPool"); |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
2570
diff
changeset
|
409 |
constantPoolOop cp = constantPoolOop(obj); |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
2570
diff
changeset
|
410 |
st->print("constant pool [%d]", cp->length()); |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
2570
diff
changeset
|
411 |
if (cp->has_pseudo_string()) st->print("/pseudo_string"); |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
2570
diff
changeset
|
412 |
if (cp->has_invokedynamic()) st->print("/invokedynamic"); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
413 |
if (cp->operands() != NULL) st->print("/operands[%d]", cp->operands()->length()); |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
2570
diff
changeset
|
414 |
cp->print_address_on(st); |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
2570
diff
changeset
|
415 |
st->print(" for "); |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
2570
diff
changeset
|
416 |
cp->pool_holder()->print_value_on(st); |
5696
93e15b419ad4
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
4584
diff
changeset
|
417 |
if (cp->cache() != NULL) { |
93e15b419ad4
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
4584
diff
changeset
|
418 |
st->print(" cache=" PTR_FORMAT, cp->cache()); |
93e15b419ad4
6957004: MethodComparator uses the wrong CP index accessor
jrose
parents:
4584
diff
changeset
|
419 |
} |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
2570
diff
changeset
|
420 |
} |
1 | 421 |
|
422 |
const char* constantPoolKlass::internal_name() const { |
|
423 |
return "{constant pool}"; |
|
424 |
} |
|
425 |
||
426 |
// Verification |
|
427 |
||
428 |
void constantPoolKlass::oop_verify_on(oop obj, outputStream* st) { |
|
429 |
Klass::oop_verify_on(obj, st); |
|
430 |
guarantee(obj->is_constantPool(), "object must be constant pool"); |
|
431 |
constantPoolOop cp = constantPoolOop(obj); |
|
432 |
guarantee(cp->is_perm(), "should be in permspace"); |
|
433 |
if (!cp->partially_loaded()) { |
|
434 |
for (int i = 0; i< cp->length(); i++) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
435 |
CPSlot entry = cp->slot_at(i); |
1 | 436 |
if (cp->tag_at(i).is_klass()) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
437 |
if (entry.is_oop()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
438 |
guarantee(entry.get_oop()->is_perm(), "should be in permspace"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
439 |
guarantee(entry.get_oop()->is_klass(), "should be klass"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
440 |
} |
1 | 441 |
} |
442 |
if (cp->tag_at(i).is_unresolved_klass()) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
443 |
if (entry.is_oop()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
444 |
guarantee(entry.get_oop()->is_perm(), "should be in permspace"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
445 |
guarantee(entry.get_oop()->is_klass(), "should be klass"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
446 |
} |
1 | 447 |
} |
448 |
if (cp->tag_at(i).is_symbol()) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
449 |
guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count"); |
1 | 450 |
} |
451 |
if (cp->tag_at(i).is_unresolved_string()) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
452 |
if (entry.is_oop()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
453 |
guarantee(entry.get_oop()->is_perm(), "should be in permspace"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
454 |
guarantee(entry.get_oop()->is_instance(), "should be instance"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
455 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
456 |
else { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
457 |
guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
458 |
} |
1 | 459 |
} |
460 |
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
|
461 |
if (!cp->has_pseudo_string()) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
462 |
if (entry.is_oop()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
463 |
guarantee(entry.get_oop()->is_perm(), "should be in permspace"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
464 |
guarantee(entry.get_oop()->is_instance(), "should be instance"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
465 |
} |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
466 |
} else { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
467 |
// 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
|
468 |
} |
1 | 469 |
} |
5882 | 470 |
// FIXME: verify JSR 292 tags JVM_CONSTANT_MethodHandle, etc. |
1 | 471 |
} |
472 |
guarantee(cp->tags()->is_perm(), "should be in permspace"); |
|
473 |
guarantee(cp->tags()->is_typeArray(), "should be type array"); |
|
474 |
if (cp->cache() != NULL) { |
|
475 |
// Note: cache() can be NULL before a class is completely setup or |
|
476 |
// in temporary constant pools used during constant pool merging |
|
477 |
guarantee(cp->cache()->is_perm(), "should be in permspace"); |
|
478 |
guarantee(cp->cache()->is_constantPoolCache(), "should be constant pool cache"); |
|
479 |
} |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
480 |
if (cp->operands() != NULL) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
481 |
guarantee(cp->operands()->is_perm(), "should be in permspace"); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
482 |
guarantee(cp->operands()->is_typeArray(), "should be type array"); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
6255
diff
changeset
|
483 |
} |
1 | 484 |
if (cp->pool_holder() != NULL) { |
485 |
// Note: pool_holder() can be NULL in temporary constant pools |
|
486 |
// used during constant pool merging |
|
487 |
guarantee(cp->pool_holder()->is_perm(), "should be in permspace"); |
|
488 |
guarantee(cp->pool_holder()->is_klass(), "should be klass"); |
|
489 |
} |
|
490 |
} |
|
491 |
} |
|
492 |
||
493 |
bool constantPoolKlass::oop_partially_loaded(oop obj) const { |
|
494 |
assert(obj->is_constantPool(), "object must be constant pool"); |
|
495 |
constantPoolOop cp = constantPoolOop(obj); |
|
496 |
return cp->tags() == NULL || cp->pool_holder() == (klassOop) cp; // Check whether pool holder points to self |
|
497 |
} |
|
498 |
||
499 |
||
500 |
void constantPoolKlass::oop_set_partially_loaded(oop obj) { |
|
501 |
assert(obj->is_constantPool(), "object must be constant pool"); |
|
502 |
constantPoolOop cp = constantPoolOop(obj); |
|
503 |
assert(cp->pool_holder() == NULL, "just checking"); |
|
504 |
cp->set_pool_holder((klassOop) cp); // Temporarily set pool holder to point to self |
|
505 |
} |
|
506 |
||
507 |
#ifndef PRODUCT |
|
508 |
// CompileTheWorld support. Preload all classes loaded references in the passed in constantpool |
|
509 |
void constantPoolKlass::preload_and_initialize_all_classes(oop obj, TRAPS) { |
|
510 |
guarantee(obj->is_constantPool(), "object must be constant pool"); |
|
511 |
constantPoolHandle cp(THREAD, (constantPoolOop)obj); |
|
512 |
guarantee(!cp->partially_loaded(), "must be fully loaded"); |
|
513 |
||
514 |
for (int i = 0; i< cp->length(); i++) { |
|
515 |
if (cp->tag_at(i).is_unresolved_klass()) { |
|
516 |
// This will force loading of the class |
|
517 |
klassOop klass = cp->klass_at(i, CHECK); |
|
518 |
if (klass->is_instance()) { |
|
519 |
// Force initialization of class |
|
520 |
instanceKlass::cast(klass)->initialize(CHECK); |
|
521 |
} |
|
522 |
} |
|
523 |
} |
|
524 |
} |
|
525 |
||
526 |
#endif |