annotate src/share/vm/oops/constantPoolKlass.cpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_constantPoolKlass.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 constantPoolOop constantPoolKlass::allocate(int length, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
29 int size = constantPoolOopDesc::object_size(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
30 KlassHandle klass (THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
31 constantPoolOop c =
a61af66fc99e Initial load
duke
parents:
diff changeset
32 (constantPoolOop)CollectedHeap::permanent_array_allocate(klass, size, length, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 c->set_tags(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
35 c->set_cache(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
36 c->set_pool_holder(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // only set to non-zero if constant pool is merged by RedefineClasses
a61af66fc99e Initial load
duke
parents:
diff changeset
38 c->set_orig_length(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // all fields are initialized; needed for GC
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // initialize tag array
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // Note: cannot introduce constant pool handle before since it is not
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // completely initialized (no class) -> would cause assertion failure
a61af66fc99e Initial load
duke
parents:
diff changeset
44 constantPoolHandle pool (THREAD, c);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 typeArrayHandle tags (THREAD, t_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 for (int index = 0; index < length; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 tags()->byte_at_put(index, JVM_CONSTANT_Invalid);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50 pool->set_tags(tags());
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 return pool();
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 klassOop constantPoolKlass::create_klass(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 constantPoolKlass o;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 KlassHandle klassklass(THREAD, Universe::arrayKlassKlassObj());
a61af66fc99e Initial load
duke
parents:
diff changeset
58 arrayKlassHandle k = base_create_array_klass(o.vtbl_value(), header_size(), klassklass, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 arrayKlassHandle super (THREAD, k->super());
a61af66fc99e Initial load
duke
parents:
diff changeset
60 complete_create_array_klass(k, super, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 return k();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 int constantPoolKlass::oop_size(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 assert(obj->is_constantPool(), "must be constantPool");
a61af66fc99e Initial load
duke
parents:
diff changeset
67 return constantPoolOop(obj)->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 void constantPoolKlass::oop_follow_contents(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 assert (obj->is_constantPool(), "obj must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
73 constantPoolOop cp = (constantPoolOop) obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // know that Universe::constantPoolKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // If the tags array is null we are in the middle of allocating this constant pool
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if (cp->tags() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // gc of constant pool contents
a61af66fc99e Initial load
duke
parents:
diff changeset
80 oop* base = (oop*)cp->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 for (int i = 0; i < cp->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 if (cp->is_pointer_entry(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 if (*base != NULL) MarkSweep::mark_and_push(base);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 base++;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // gc of constant pool instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
88 MarkSweep::mark_and_push(cp->tags_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
89 MarkSweep::mark_and_push(cp->cache_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
90 MarkSweep::mark_and_push(cp->pool_holder_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
95 void constantPoolKlass::oop_follow_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 assert (obj->is_constantPool(), "obj must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
98 constantPoolOop cp = (constantPoolOop) obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // know that Universe::constantPoolKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // If the tags array is null we are in the middle of allocating this constant
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // pool.
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (cp->tags() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // gc of constant pool contents
a61af66fc99e Initial load
duke
parents:
diff changeset
106 oop* base = (oop*)cp->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 for (int i = 0; i < cp->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (cp->is_pointer_entry(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 if (*base != NULL) PSParallelCompact::mark_and_push(cm, base);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 base++;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // gc of constant pool instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
114 PSParallelCompact::mark_and_push(cm, cp->tags_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
115 PSParallelCompact::mark_and_push(cm, cp->cache_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
116 PSParallelCompact::mark_and_push(cm, cp->pool_holder_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 int constantPoolKlass::oop_adjust_pointers(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 assert (obj->is_constantPool(), "obj must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 constantPoolOop cp = (constantPoolOop) obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 int size = cp->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // know that Universe::constantPoolKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // If the tags array is null we are in the middle of allocating this constant
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // pool.
a61af66fc99e Initial load
duke
parents:
diff changeset
133 if (cp->tags() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 oop* base = (oop*)cp->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
135 for (int i = 0; i< cp->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 if (cp->is_pointer_entry(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 MarkSweep::adjust_pointer(base);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 base++;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 MarkSweep::adjust_pointer(cp->tags_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
143 MarkSweep::adjust_pointer(cp->cache_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
144 MarkSweep::adjust_pointer(cp->pool_holder_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 int constantPoolKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 assert (obj->is_constantPool(), "obj must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // know that Universe::constantPoolKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
153 constantPoolOop cp = (constantPoolOop) obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
156 int size = cp->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // If the tags array is null we are in the middle of allocating this constant
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // pool.
a61af66fc99e Initial load
duke
parents:
diff changeset
160 if (cp->tags() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 oop* base = (oop*)cp->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
162 for (int i = 0; i < cp->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 if (cp->is_pointer_entry(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 blk->do_oop(base);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 base++;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 blk->do_oop(cp->tags_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
170 blk->do_oop(cp->cache_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
171 blk->do_oop(cp->pool_holder_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
172 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 int constantPoolKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 assert (obj->is_constantPool(), "obj must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // know that Universe::constantPoolKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
180 constantPoolOop cp = (constantPoolOop) obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
183 int size = cp->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // If the tags array is null we are in the middle of allocating this constant
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // pool.
a61af66fc99e Initial load
duke
parents:
diff changeset
187 if (cp->tags() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 oop* base = (oop*)cp->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 for (int i = 0; i < cp->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 if (mr.contains(base)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 if (cp->is_pointer_entry(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 blk->do_oop(base);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 base++;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 oop* addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 addr = cp->tags_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
200 blk->do_oop(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 addr = cp->cache_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
202 blk->do_oop(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 addr = cp->pool_holder_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
204 blk->do_oop(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
209 int constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 assert (obj->is_constantPool(), "obj must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
211 constantPoolOop cp = (constantPoolOop) obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // If the tags array is null we are in the middle of allocating this constant
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // pool.
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (cp->tags() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 oop* base = (oop*)cp->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
217 for (int i = 0; i < cp->length(); ++i, ++base) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 if (cp->is_pointer_entry(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 PSParallelCompact::adjust_pointer(base);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 PSParallelCompact::adjust_pointer(cp->tags_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
224 PSParallelCompact::adjust_pointer(cp->cache_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
225 PSParallelCompact::adjust_pointer(cp->pool_holder_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
226 return cp->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 int
a61af66fc99e Initial load
duke
parents:
diff changeset
230 constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
231 HeapWord* beg_addr, HeapWord* end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 assert (obj->is_constantPool(), "obj must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
233 constantPoolOop cp = (constantPoolOop) obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // If the tags array is null we are in the middle of allocating this constant
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // pool.
a61af66fc99e Initial load
duke
parents:
diff changeset
237 if (cp->tags() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 oop* base = (oop*)cp->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
239 oop* const beg_oop = MAX2((oop*)beg_addr, base);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 oop* const end_oop = MIN2((oop*)end_addr, base + cp->length());
a61af66fc99e Initial load
duke
parents:
diff changeset
241 const size_t beg_idx = pointer_delta(beg_oop, base, sizeof(oop*));
a61af66fc99e Initial load
duke
parents:
diff changeset
242 const size_t end_idx = pointer_delta(end_oop, base, sizeof(oop*));
a61af66fc99e Initial load
duke
parents:
diff changeset
243 for (size_t cur_idx = beg_idx; cur_idx < end_idx; ++cur_idx, ++base) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 if (cp->is_pointer_entry(int(cur_idx))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 PSParallelCompact::adjust_pointer(base);
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 oop* p;
a61af66fc99e Initial load
duke
parents:
diff changeset
251 p = cp->tags_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
252 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 p = cp->cache_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
254 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 p = cp->pool_holder_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
256 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return cp->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 void constantPoolKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 assert(obj->is_constantPool(), "should be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 assert(obj->is_constantPool(), "should be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 void constantPoolKlass::oop_print_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
276 oop anObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 assert(obj->is_constantPool(), "must be constantPool");
a61af66fc99e Initial load
duke
parents:
diff changeset
278 arrayKlass::oop_print_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
279 constantPoolOop cp = constantPoolOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // Temp. remove cache so we can do lookups with original indicies.
a61af66fc99e Initial load
duke
parents:
diff changeset
282 constantPoolCacheHandle cache (THREAD, cp->cache());
a61af66fc99e Initial load
duke
parents:
diff changeset
283 cp->set_cache(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 for (int index = 1; index < cp->length(); index++) { // Index 0 is unused
a61af66fc99e Initial load
duke
parents:
diff changeset
286 st->print(" - %3d : ", index);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 cp->tag_at(index).print_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
288 st->print(" : ");
a61af66fc99e Initial load
duke
parents:
diff changeset
289 switch (cp->tag_at(index).value()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 case JVM_CONSTANT_Class :
a61af66fc99e Initial load
duke
parents:
diff changeset
291 { anObj = cp->klass_at(index, CATCH);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 anObj->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 st->print(" {0x%lx}", (address)anObj);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 case JVM_CONSTANT_Fieldref :
a61af66fc99e Initial load
duke
parents:
diff changeset
297 case JVM_CONSTANT_Methodref :
a61af66fc99e Initial load
duke
parents:
diff changeset
298 case JVM_CONSTANT_InterfaceMethodref :
a61af66fc99e Initial load
duke
parents:
diff changeset
299 st->print("klass_index=%d", cp->klass_ref_index_at(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
300 st->print(" name_and_type_index=%d", cp->name_and_type_ref_index_at(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
301 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
302 case JVM_CONSTANT_UnresolvedString :
a61af66fc99e Initial load
duke
parents:
diff changeset
303 case JVM_CONSTANT_String :
a61af66fc99e Initial load
duke
parents:
diff changeset
304 anObj = cp->string_at(index, CATCH);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 anObj->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 st->print(" {0x%lx}", (address)anObj);
a61af66fc99e Initial load
duke
parents:
diff changeset
307 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
308 case JVM_CONSTANT_Integer :
a61af66fc99e Initial load
duke
parents:
diff changeset
309 st->print("%d", cp->int_at(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
310 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
311 case JVM_CONSTANT_Float :
a61af66fc99e Initial load
duke
parents:
diff changeset
312 st->print("%f", cp->float_at(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
313 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
314 case JVM_CONSTANT_Long :
a61af66fc99e Initial load
duke
parents:
diff changeset
315 st->print_jlong(cp->long_at(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
316 index++; // Skip entry following eigth-byte constant
a61af66fc99e Initial load
duke
parents:
diff changeset
317 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
318 case JVM_CONSTANT_Double :
a61af66fc99e Initial load
duke
parents:
diff changeset
319 st->print("%lf", cp->double_at(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
320 index++; // Skip entry following eigth-byte constant
a61af66fc99e Initial load
duke
parents:
diff changeset
321 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
322 case JVM_CONSTANT_NameAndType :
a61af66fc99e Initial load
duke
parents:
diff changeset
323 st->print("name_index=%d", cp->name_ref_index_at(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
324 st->print(" signature_index=%d", cp->signature_ref_index_at(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
325 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
326 case JVM_CONSTANT_Utf8 :
a61af66fc99e Initial load
duke
parents:
diff changeset
327 cp->symbol_at(index)->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
328 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
329 case JVM_CONSTANT_UnresolvedClass : // fall-through
a61af66fc99e Initial load
duke
parents:
diff changeset
330 case JVM_CONSTANT_UnresolvedClassInError: {
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // unresolved_klass_at requires lock or safe world.
a61af66fc99e Initial load
duke
parents:
diff changeset
332 oop entry = *cp->obj_at_addr(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
333 entry->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
335 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
336 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
337 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
338 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
342 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
343
a61af66fc99e Initial load
duke
parents:
diff changeset
344 // Restore cache
a61af66fc99e Initial load
duke
parents:
diff changeset
345 cp->set_cache(cache());
a61af66fc99e Initial load
duke
parents:
diff changeset
346 }
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 const char* constantPoolKlass::internal_name() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
352 return "{constant pool}";
a61af66fc99e Initial load
duke
parents:
diff changeset
353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 // Verification
a61af66fc99e Initial load
duke
parents:
diff changeset
356
a61af66fc99e Initial load
duke
parents:
diff changeset
357 void constantPoolKlass::oop_verify_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
358 Klass::oop_verify_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
359 guarantee(obj->is_constantPool(), "object must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 constantPoolOop cp = constantPoolOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 guarantee(cp->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
362 if (!cp->partially_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
363 oop* base = (oop*)cp->base();
a61af66fc99e Initial load
duke
parents:
diff changeset
364 for (int i = 0; i< cp->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 if (cp->tag_at(i).is_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
366 guarantee((*base)->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
367 guarantee((*base)->is_klass(), "should be klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
368 }
a61af66fc99e Initial load
duke
parents:
diff changeset
369 if (cp->tag_at(i).is_unresolved_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 guarantee((*base)->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
371 guarantee((*base)->is_symbol() || (*base)->is_klass(),
a61af66fc99e Initial load
duke
parents:
diff changeset
372 "should be symbol or klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374 if (cp->tag_at(i).is_symbol()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
375 guarantee((*base)->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
376 guarantee((*base)->is_symbol(), "should be symbol");
a61af66fc99e Initial load
duke
parents:
diff changeset
377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
378 if (cp->tag_at(i).is_unresolved_string()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
379 guarantee((*base)->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
380 guarantee((*base)->is_symbol() || (*base)->is_instance(),
a61af66fc99e Initial load
duke
parents:
diff changeset
381 "should be symbol or instance");
a61af66fc99e Initial load
duke
parents:
diff changeset
382 }
a61af66fc99e Initial load
duke
parents:
diff changeset
383 if (cp->tag_at(i).is_string()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
384 guarantee((*base)->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
385 guarantee((*base)->is_instance(), "should be instance");
a61af66fc99e Initial load
duke
parents:
diff changeset
386 }
a61af66fc99e Initial load
duke
parents:
diff changeset
387 base++;
a61af66fc99e Initial load
duke
parents:
diff changeset
388 }
a61af66fc99e Initial load
duke
parents:
diff changeset
389 guarantee(cp->tags()->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
390 guarantee(cp->tags()->is_typeArray(), "should be type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
391 if (cp->cache() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
392 // Note: cache() can be NULL before a class is completely setup or
a61af66fc99e Initial load
duke
parents:
diff changeset
393 // in temporary constant pools used during constant pool merging
a61af66fc99e Initial load
duke
parents:
diff changeset
394 guarantee(cp->cache()->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
395 guarantee(cp->cache()->is_constantPoolCache(), "should be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
396 }
a61af66fc99e Initial load
duke
parents:
diff changeset
397 if (cp->pool_holder() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 // Note: pool_holder() can be NULL in temporary constant pools
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // used during constant pool merging
a61af66fc99e Initial load
duke
parents:
diff changeset
400 guarantee(cp->pool_holder()->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
401 guarantee(cp->pool_holder()->is_klass(), "should be klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406 bool constantPoolKlass::oop_partially_loaded(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 assert(obj->is_constantPool(), "object must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
408 constantPoolOop cp = constantPoolOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
409 return cp->tags() == NULL || cp->pool_holder() == (klassOop) cp; // Check whether pool holder points to self
a61af66fc99e Initial load
duke
parents:
diff changeset
410 }
a61af66fc99e Initial load
duke
parents:
diff changeset
411
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 void constantPoolKlass::oop_set_partially_loaded(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
414 assert(obj->is_constantPool(), "object must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
415 constantPoolOop cp = constantPoolOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
416 assert(cp->pool_holder() == NULL, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
417 cp->set_pool_holder((klassOop) cp); // Temporarily set pool holder to point to self
a61af66fc99e Initial load
duke
parents:
diff changeset
418 }
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
421 // CompileTheWorld support. Preload all classes loaded references in the passed in constantpool
a61af66fc99e Initial load
duke
parents:
diff changeset
422 void constantPoolKlass::preload_and_initialize_all_classes(oop obj, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
423 guarantee(obj->is_constantPool(), "object must be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
424 constantPoolHandle cp(THREAD, (constantPoolOop)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
425 guarantee(!cp->partially_loaded(), "must be fully loaded");
a61af66fc99e Initial load
duke
parents:
diff changeset
426
a61af66fc99e Initial load
duke
parents:
diff changeset
427 for (int i = 0; i< cp->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
428 if (cp->tag_at(i).is_unresolved_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
429 // This will force loading of the class
a61af66fc99e Initial load
duke
parents:
diff changeset
430 klassOop klass = cp->klass_at(i, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
431 if (klass->is_instance()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
432 // Force initialization of class
a61af66fc99e Initial load
duke
parents:
diff changeset
433 instanceKlass::cast(klass)->initialize(CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438
a61af66fc99e Initial load
duke
parents:
diff changeset
439 #endif