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