annotate src/share/vm/oops/constantPoolKlass.cpp @ 1580:083fde3b838e

6964498: JSR 292 invokedynamic sites need local bootstrap methods Summary: Add JVM_CONSTANT_InvokeDynamic records to constant pool to determine per-instruction BSMs. Reviewed-by: twisti
author jrose
date Thu, 15 Jul 2010 18:40:45 -0700
parents 136b78722a08
children 126ea7725993 9d7a8ab3736b
rev   line source
duke@0 1 /*
trims@1472 2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. 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 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * 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@1493 313 st->print(" - flags: 0x%x", cp->flags());
jrose@431 314 if (cp->has_pseudo_string()) st->print(" has_pseudo_string");
jrose@726 315 if (cp->has_invokedynamic()) st->print(" has_invokedynamic");
jrose@431 316 st->cr();
jrose@431 317 }
jrose@1493 318 st->print_cr(" - cache: " INTPTR_FORMAT, cp->cache());
duke@0 319
duke@0 320 for (int index = 1; index < cp->length(); index++) { // Index 0 is unused
duke@0 321 st->print(" - %3d : ", index);
duke@0 322 cp->tag_at(index).print_on(st);
duke@0 323 st->print(" : ");
duke@0 324 switch (cp->tag_at(index).value()) {
duke@0 325 case JVM_CONSTANT_Class :
duke@0 326 { anObj = cp->klass_at(index, CATCH);
duke@0 327 anObj->print_value_on(st);
duke@0 328 st->print(" {0x%lx}", (address)anObj);
duke@0 329 }
duke@0 330 break;
duke@0 331 case JVM_CONSTANT_Fieldref :
duke@0 332 case JVM_CONSTANT_Methodref :
duke@0 333 case JVM_CONSTANT_InterfaceMethodref :
jrose@1493 334 st->print("klass_index=%d", cp->uncached_klass_ref_index_at(index));
jrose@1493 335 st->print(" name_and_type_index=%d", cp->uncached_name_and_type_ref_index_at(index));
duke@0 336 break;
duke@0 337 case JVM_CONSTANT_UnresolvedString :
duke@0 338 case JVM_CONSTANT_String :
jrose@431 339 if (cp->is_pseudo_string_at(index)) {
jrose@431 340 anObj = cp->pseudo_string_at(index);
jrose@431 341 } else {
jrose@431 342 anObj = cp->string_at(index, CATCH);
jrose@431 343 }
duke@0 344 anObj->print_value_on(st);
duke@0 345 st->print(" {0x%lx}", (address)anObj);
duke@0 346 break;
duke@0 347 case JVM_CONSTANT_Integer :
duke@0 348 st->print("%d", cp->int_at(index));
duke@0 349 break;
duke@0 350 case JVM_CONSTANT_Float :
duke@0 351 st->print("%f", cp->float_at(index));
duke@0 352 break;
duke@0 353 case JVM_CONSTANT_Long :
duke@0 354 st->print_jlong(cp->long_at(index));
duke@0 355 index++; // Skip entry following eigth-byte constant
duke@0 356 break;
duke@0 357 case JVM_CONSTANT_Double :
duke@0 358 st->print("%lf", cp->double_at(index));
duke@0 359 index++; // Skip entry following eigth-byte constant
duke@0 360 break;
duke@0 361 case JVM_CONSTANT_NameAndType :
duke@0 362 st->print("name_index=%d", cp->name_ref_index_at(index));
duke@0 363 st->print(" signature_index=%d", cp->signature_ref_index_at(index));
duke@0 364 break;
duke@0 365 case JVM_CONSTANT_Utf8 :
duke@0 366 cp->symbol_at(index)->print_value_on(st);
duke@0 367 break;
duke@0 368 case JVM_CONSTANT_UnresolvedClass : // fall-through
duke@0 369 case JVM_CONSTANT_UnresolvedClassInError: {
duke@0 370 // unresolved_klass_at requires lock or safe world.
duke@0 371 oop entry = *cp->obj_at_addr(index);
duke@0 372 entry->print_value_on(st);
duke@0 373 }
duke@0 374 break;
jrose@1522 375 case JVM_CONSTANT_MethodHandle :
jrose@1522 376 st->print("ref_kind=%d", cp->method_handle_ref_kind_at(index));
jrose@1522 377 st->print(" ref_index=%d", cp->method_handle_index_at(index));
jrose@1522 378 break;
jrose@1522 379 case JVM_CONSTANT_MethodType :
jrose@1522 380 st->print("signature_index=%d", cp->method_type_index_at(index));
jrose@1522 381 break;
jrose@1580 382 case JVM_CONSTANT_InvokeDynamic :
jrose@1580 383 st->print("bootstrap_method_index=%d", cp->invoke_dynamic_bootstrap_method_ref_index_at(index));
jrose@1580 384 st->print(" name_and_type_index=%d", cp->invoke_dynamic_name_and_type_ref_index_at(index));
jrose@1580 385 break;
duke@0 386 default:
duke@0 387 ShouldNotReachHere();
duke@0 388 break;
duke@0 389 }
duke@0 390 st->cr();
duke@0 391 }
duke@0 392 st->cr();
duke@0 393 }
duke@0 394
jrose@1155 395 #endif
duke@0 396
jrose@1155 397 void constantPoolKlass::oop_print_value_on(oop obj, outputStream* st) {
jrose@1155 398 assert(obj->is_constantPool(), "must be constantPool");
jrose@1155 399 constantPoolOop cp = constantPoolOop(obj);
jrose@1155 400 st->print("constant pool [%d]", cp->length());
jrose@1155 401 if (cp->has_pseudo_string()) st->print("/pseudo_string");
jrose@1155 402 if (cp->has_invokedynamic()) st->print("/invokedynamic");
jrose@1155 403 cp->print_address_on(st);
jrose@1155 404 st->print(" for ");
jrose@1155 405 cp->pool_holder()->print_value_on(st);
jrose@1493 406 if (cp->cache() != NULL) {
jrose@1493 407 st->print(" cache=" PTR_FORMAT, cp->cache());
jrose@1493 408 }
jrose@1155 409 }
duke@0 410
duke@0 411 const char* constantPoolKlass::internal_name() const {
duke@0 412 return "{constant pool}";
duke@0 413 }
duke@0 414
duke@0 415 // Verification
duke@0 416
duke@0 417 void constantPoolKlass::oop_verify_on(oop obj, outputStream* st) {
duke@0 418 Klass::oop_verify_on(obj, st);
duke@0 419 guarantee(obj->is_constantPool(), "object must be constant pool");
duke@0 420 constantPoolOop cp = constantPoolOop(obj);
duke@0 421 guarantee(cp->is_perm(), "should be in permspace");
duke@0 422 if (!cp->partially_loaded()) {
duke@0 423 oop* base = (oop*)cp->base();
duke@0 424 for (int i = 0; i< cp->length(); i++) {
duke@0 425 if (cp->tag_at(i).is_klass()) {
duke@0 426 guarantee((*base)->is_perm(), "should be in permspace");
duke@0 427 guarantee((*base)->is_klass(), "should be klass");
duke@0 428 }
duke@0 429 if (cp->tag_at(i).is_unresolved_klass()) {
duke@0 430 guarantee((*base)->is_perm(), "should be in permspace");
duke@0 431 guarantee((*base)->is_symbol() || (*base)->is_klass(),
duke@0 432 "should be symbol or klass");
duke@0 433 }
duke@0 434 if (cp->tag_at(i).is_symbol()) {
duke@0 435 guarantee((*base)->is_perm(), "should be in permspace");
duke@0 436 guarantee((*base)->is_symbol(), "should be symbol");
duke@0 437 }
duke@0 438 if (cp->tag_at(i).is_unresolved_string()) {
duke@0 439 guarantee((*base)->is_perm(), "should be in permspace");
duke@0 440 guarantee((*base)->is_symbol() || (*base)->is_instance(),
duke@0 441 "should be symbol or instance");
duke@0 442 }
duke@0 443 if (cp->tag_at(i).is_string()) {
jrose@431 444 if (!cp->has_pseudo_string()) {
jrose@431 445 guarantee((*base)->is_perm(), "should be in permspace");
jrose@431 446 guarantee((*base)->is_instance(), "should be instance");
jrose@431 447 } else {
jrose@431 448 // can be non-perm, can be non-instance (array)
jrose@431 449 }
duke@0 450 }
jrose@1522 451 // FIXME: verify JSR 292 tags JVM_CONSTANT_MethodHandle, etc.
duke@0 452 base++;
duke@0 453 }
duke@0 454 guarantee(cp->tags()->is_perm(), "should be in permspace");
duke@0 455 guarantee(cp->tags()->is_typeArray(), "should be type array");
duke@0 456 if (cp->cache() != NULL) {
duke@0 457 // Note: cache() can be NULL before a class is completely setup or
duke@0 458 // in temporary constant pools used during constant pool merging
duke@0 459 guarantee(cp->cache()->is_perm(), "should be in permspace");
duke@0 460 guarantee(cp->cache()->is_constantPoolCache(), "should be constant pool cache");
duke@0 461 }
duke@0 462 if (cp->pool_holder() != NULL) {
duke@0 463 // Note: pool_holder() can be NULL in temporary constant pools
duke@0 464 // used during constant pool merging
duke@0 465 guarantee(cp->pool_holder()->is_perm(), "should be in permspace");
duke@0 466 guarantee(cp->pool_holder()->is_klass(), "should be klass");
duke@0 467 }
duke@0 468 }
duke@0 469 }
duke@0 470
duke@0 471 bool constantPoolKlass::oop_partially_loaded(oop obj) const {
duke@0 472 assert(obj->is_constantPool(), "object must be constant pool");
duke@0 473 constantPoolOop cp = constantPoolOop(obj);
duke@0 474 return cp->tags() == NULL || cp->pool_holder() == (klassOop) cp; // Check whether pool holder points to self
duke@0 475 }
duke@0 476
duke@0 477
duke@0 478 void constantPoolKlass::oop_set_partially_loaded(oop obj) {
duke@0 479 assert(obj->is_constantPool(), "object must be constant pool");
duke@0 480 constantPoolOop cp = constantPoolOop(obj);
duke@0 481 assert(cp->pool_holder() == NULL, "just checking");
duke@0 482 cp->set_pool_holder((klassOop) cp); // Temporarily set pool holder to point to self
duke@0 483 }
duke@0 484
duke@0 485 #ifndef PRODUCT
duke@0 486 // CompileTheWorld support. Preload all classes loaded references in the passed in constantpool
duke@0 487 void constantPoolKlass::preload_and_initialize_all_classes(oop obj, TRAPS) {
duke@0 488 guarantee(obj->is_constantPool(), "object must be constant pool");
duke@0 489 constantPoolHandle cp(THREAD, (constantPoolOop)obj);
duke@0 490 guarantee(!cp->partially_loaded(), "must be fully loaded");
duke@0 491
duke@0 492 for (int i = 0; i< cp->length(); i++) {
duke@0 493 if (cp->tag_at(i).is_unresolved_klass()) {
duke@0 494 // This will force loading of the class
duke@0 495 klassOop klass = cp->klass_at(i, CHECK);
duke@0 496 if (klass->is_instance()) {
duke@0 497 // Force initialization of class
duke@0 498 instanceKlass::cast(klass)->initialize(CHECK);
duke@0 499 }
duke@0 500 }
duke@0 501 }
duke@0 502 }
duke@0 503
duke@0 504 #endif