annotate src/share/vm/oops/constantPoolKlass.cpp @ 518:0af8b0718fc9

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