268 // If the tags array is null we are in the middle of allocating this constant 269 // pool. 270 if (cp->tags() != NULL) { 271 oop* base = (oop*)cp->base(); 272 for (int i = 0; i < cp->length(); ++i, ++base) { 273 if (cp->is_pointer_entry(i)) { 274 PSParallelCompact::adjust_pointer(base); 275 } 276 } 277 } 278 PSParallelCompact::adjust_pointer(cp->tags_addr()); 279 PSParallelCompact::adjust_pointer(cp->cache_addr()); 280 PSParallelCompact::adjust_pointer(cp->operands_addr()); 281 PSParallelCompact::adjust_pointer(cp->pool_holder_addr()); 282 return cp->object_size(); 283 } 284 285 void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { 286 assert(obj->is_constantPool(), "should be constant pool"); 287 constantPoolOop cp = (constantPoolOop) obj; 288 if (cp->tags() != NULL && 289 (!JavaObjectsInPerm || (EnableInvokeDynamic && cp->has_pseudo_string()))) { 290 for (int i = 1; i < cp->length(); ++i) { 291 if (cp->tag_at(i).is_string()) { 292 oop* base = cp->obj_at_addr_raw(i); 293 if (PSScavenge::should_scavenge(base)) { 294 pm->claim_or_forward_depth(base); 295 } 296 } 297 } 298 } 299 } 300 #endif // SERIALGC 301 302 // Printing 303 304 void constantPoolKlass::oop_print_on(oop obj, outputStream* st) { 305 EXCEPTION_MARK; 306 oop anObj; 307 assert(obj->is_constantPool(), "must be constantPool"); 308 Klass::oop_print_on(obj, st); 309 constantPoolOop cp = constantPoolOop(obj); 310 if (cp->flags() != 0) { 311 st->print(" - flags: 0x%x", cp->flags()); 325 anObj->print_value_on(st); 326 st->print(" {0x%lx}", (address)anObj); 327 } 328 break; 329 case JVM_CONSTANT_Fieldref : 330 case JVM_CONSTANT_Methodref : 331 case JVM_CONSTANT_InterfaceMethodref : 332 st->print("klass_index=%d", cp->uncached_klass_ref_index_at(index)); 333 st->print(" name_and_type_index=%d", cp->uncached_name_and_type_ref_index_at(index)); 334 break; 335 case JVM_CONSTANT_UnresolvedString : 336 case JVM_CONSTANT_String : 337 if (cp->is_pseudo_string_at(index)) { 338 anObj = cp->pseudo_string_at(index); 339 } else { 340 anObj = cp->string_at(index, CATCH); 341 } 342 anObj->print_value_on(st); 343 st->print(" {0x%lx}", (address)anObj); 344 break; 345 case JVM_CONSTANT_Integer : 346 st->print("%d", cp->int_at(index)); 347 break; 348 case JVM_CONSTANT_Float : 349 st->print("%f", cp->float_at(index)); 350 break; 351 case JVM_CONSTANT_Long : 352 st->print_jlong(cp->long_at(index)); 353 index++; // Skip entry following eigth-byte constant 354 break; 355 case JVM_CONSTANT_Double : 356 st->print("%lf", cp->double_at(index)); 357 index++; // Skip entry following eigth-byte constant 358 break; 359 case JVM_CONSTANT_NameAndType : 360 st->print("name_index=%d", cp->name_ref_index_at(index)); 361 st->print(" signature_index=%d", cp->signature_ref_index_at(index)); 362 break; 363 case JVM_CONSTANT_Utf8 : 364 cp->symbol_at(index)->print_value_on(st); 415 st->print(" for "); 416 cp->pool_holder()->print_value_on(st); 417 if (cp->cache() != NULL) { 418 st->print(" cache=" PTR_FORMAT, cp->cache()); 419 } 420 } 421 422 const char* constantPoolKlass::internal_name() const { 423 return "{constant pool}"; 424 } 425 426 // Verification 427 428 void constantPoolKlass::oop_verify_on(oop obj, outputStream* st) { 429 Klass::oop_verify_on(obj, st); 430 guarantee(obj->is_constantPool(), "object must be constant pool"); 431 constantPoolOop cp = constantPoolOop(obj); 432 guarantee(cp->is_perm(), "should be in permspace"); 433 if (!cp->partially_loaded()) { 434 for (int i = 0; i< cp->length(); i++) { 435 CPSlot entry = cp->slot_at(i); 436 if (cp->tag_at(i).is_klass()) { 437 if (entry.is_oop()) { 438 guarantee(entry.get_oop()->is_perm(), "should be in permspace"); 439 guarantee(entry.get_oop()->is_klass(), "should be klass"); 440 } 441 } 442 if (cp->tag_at(i).is_unresolved_klass()) { 443 if (entry.is_oop()) { 444 guarantee(entry.get_oop()->is_perm(), "should be in permspace"); 445 guarantee(entry.get_oop()->is_klass(), "should be klass"); 446 } 447 } 448 if (cp->tag_at(i).is_symbol()) { 449 guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count"); 450 } 451 if (cp->tag_at(i).is_unresolved_string()) { 452 if (entry.is_oop()) { 453 guarantee(entry.get_oop()->is_perm(), "should be in permspace"); 454 guarantee(entry.get_oop()->is_instance(), "should be instance"); 455 } 456 else { 457 guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count"); 458 } 459 } 460 if (cp->tag_at(i).is_string()) { 461 if (!cp->has_pseudo_string()) { 462 if (entry.is_oop()) { 463 guarantee(!JavaObjectsInPerm || entry.get_oop()->is_perm(), 464 "should be in permspace"); 465 guarantee(entry.get_oop()->is_instance(), "should be instance"); 466 } 467 } else { 468 // can be non-perm, can be non-instance (array) 469 } 470 } 471 // FIXME: verify JSR 292 tags JVM_CONSTANT_MethodHandle, etc. 472 } 473 guarantee(cp->tags()->is_perm(), "should be in permspace"); 474 guarantee(cp->tags()->is_typeArray(), "should be type array"); 475 if (cp->cache() != NULL) { 476 // Note: cache() can be NULL before a class is completely setup or 477 // in temporary constant pools used during constant pool merging 478 guarantee(cp->cache()->is_perm(), "should be in permspace"); 479 guarantee(cp->cache()->is_constantPoolCache(), "should be constant pool cache"); 480 } 481 if (cp->operands() != NULL) { 482 guarantee(cp->operands()->is_perm(), "should be in permspace"); 483 guarantee(cp->operands()->is_typeArray(), "should be type array"); 484 } 485 if (cp->pool_holder() != NULL) { 486 // Note: pool_holder() can be NULL in temporary constant pools 487 // used during constant pool merging 488 guarantee(cp->pool_holder()->is_perm(), "should be in permspace"); 489 guarantee(cp->pool_holder()->is_klass(), "should be klass"); 490 } 491 } | 268 // If the tags array is null we are in the middle of allocating this constant 269 // pool. 270 if (cp->tags() != NULL) { 271 oop* base = (oop*)cp->base(); 272 for (int i = 0; i < cp->length(); ++i, ++base) { 273 if (cp->is_pointer_entry(i)) { 274 PSParallelCompact::adjust_pointer(base); 275 } 276 } 277 } 278 PSParallelCompact::adjust_pointer(cp->tags_addr()); 279 PSParallelCompact::adjust_pointer(cp->cache_addr()); 280 PSParallelCompact::adjust_pointer(cp->operands_addr()); 281 PSParallelCompact::adjust_pointer(cp->pool_holder_addr()); 282 return cp->object_size(); 283 } 284 285 void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { 286 assert(obj->is_constantPool(), "should be constant pool"); 287 constantPoolOop cp = (constantPoolOop) obj; 288 if (cp->tags() != NULL) { 289 for (int i = 1; i < cp->length(); ++i) { 290 if (cp->is_pointer_entry(i)) { 291 oop* base = cp->obj_at_addr_raw(i); 292 if (PSScavenge::should_scavenge(base)) { 293 pm->claim_or_forward_depth(base); 294 } 295 } 296 } 297 } 298 } 299 #endif // SERIALGC 300 301 // Printing 302 303 void constantPoolKlass::oop_print_on(oop obj, outputStream* st) { 304 EXCEPTION_MARK; 305 oop anObj; 306 assert(obj->is_constantPool(), "must be constantPool"); 307 Klass::oop_print_on(obj, st); 308 constantPoolOop cp = constantPoolOop(obj); 309 if (cp->flags() != 0) { 310 st->print(" - flags: 0x%x", cp->flags()); 324 anObj->print_value_on(st); 325 st->print(" {0x%lx}", (address)anObj); 326 } 327 break; 328 case JVM_CONSTANT_Fieldref : 329 case JVM_CONSTANT_Methodref : 330 case JVM_CONSTANT_InterfaceMethodref : 331 st->print("klass_index=%d", cp->uncached_klass_ref_index_at(index)); 332 st->print(" name_and_type_index=%d", cp->uncached_name_and_type_ref_index_at(index)); 333 break; 334 case JVM_CONSTANT_UnresolvedString : 335 case JVM_CONSTANT_String : 336 if (cp->is_pseudo_string_at(index)) { 337 anObj = cp->pseudo_string_at(index); 338 } else { 339 anObj = cp->string_at(index, CATCH); 340 } 341 anObj->print_value_on(st); 342 st->print(" {0x%lx}", (address)anObj); 343 break; 344 case JVM_CONSTANT_Object : 345 anObj = cp->object_at(index); 346 anObj->print_value_on(st); 347 st->print(" {0x%lx}", (address)anObj); 348 break; 349 case JVM_CONSTANT_Integer : 350 st->print("%d", cp->int_at(index)); 351 break; 352 case JVM_CONSTANT_Float : 353 st->print("%f", cp->float_at(index)); 354 break; 355 case JVM_CONSTANT_Long : 356 st->print_jlong(cp->long_at(index)); 357 index++; // Skip entry following eigth-byte constant 358 break; 359 case JVM_CONSTANT_Double : 360 st->print("%lf", cp->double_at(index)); 361 index++; // Skip entry following eigth-byte constant 362 break; 363 case JVM_CONSTANT_NameAndType : 364 st->print("name_index=%d", cp->name_ref_index_at(index)); 365 st->print(" signature_index=%d", cp->signature_ref_index_at(index)); 366 break; 367 case JVM_CONSTANT_Utf8 : 368 cp->symbol_at(index)->print_value_on(st); 419 st->print(" for "); 420 cp->pool_holder()->print_value_on(st); 421 if (cp->cache() != NULL) { 422 st->print(" cache=" PTR_FORMAT, cp->cache()); 423 } 424 } 425 426 const char* constantPoolKlass::internal_name() const { 427 return "{constant pool}"; 428 } 429 430 // Verification 431 432 void constantPoolKlass::oop_verify_on(oop obj, outputStream* st) { 433 Klass::oop_verify_on(obj, st); 434 guarantee(obj->is_constantPool(), "object must be constant pool"); 435 constantPoolOop cp = constantPoolOop(obj); 436 guarantee(cp->is_perm(), "should be in permspace"); 437 if (!cp->partially_loaded()) { 438 for (int i = 0; i< cp->length(); i++) { 439 constantTag tag = cp->tag_at(i); 440 CPSlot entry = cp->slot_at(i); 441 if (tag.is_klass()) { 442 if (entry.is_oop()) { 443 guarantee(entry.get_oop()->is_perm(), "should be in permspace"); 444 guarantee(entry.get_oop()->is_klass(), "should be klass"); 445 } 446 } else if (tag.is_unresolved_klass()) { 447 if (entry.is_oop()) { 448 guarantee(entry.get_oop()->is_perm(), "should be in permspace"); 449 guarantee(entry.get_oop()->is_klass(), "should be klass"); 450 } 451 } else if (tag.is_symbol()) { 452 guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count"); 453 } else if (tag.is_unresolved_string()) { 454 if (entry.is_oop()) { 455 guarantee(entry.get_oop()->is_perm(), "should be in permspace"); 456 guarantee(entry.get_oop()->is_instance(), "should be instance"); 457 } 458 else { 459 guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count"); 460 } 461 } else if (tag.is_string()) { 462 if (!cp->has_pseudo_string()) { 463 if (entry.is_oop()) { 464 guarantee(!JavaObjectsInPerm || entry.get_oop()->is_perm(), 465 "should be in permspace"); 466 guarantee(entry.get_oop()->is_instance(), "should be instance"); 467 } 468 } else { 469 // can be non-perm, can be non-instance (array) 470 } 471 } else if (tag.is_object()) { 472 assert(entry.get_oop()->is_oop(), "should be some valid oop"); 473 } else { 474 assert(!cp->is_pointer_entry(i), "unhandled oop type in constantPoolKlass::verify_on"); 475 } 476 } 477 guarantee(cp->tags()->is_perm(), "should be in permspace"); 478 guarantee(cp->tags()->is_typeArray(), "should be type array"); 479 if (cp->cache() != NULL) { 480 // Note: cache() can be NULL before a class is completely setup or 481 // in temporary constant pools used during constant pool merging 482 guarantee(cp->cache()->is_perm(), "should be in permspace"); 483 guarantee(cp->cache()->is_constantPoolCache(), "should be constant pool cache"); 484 } 485 if (cp->operands() != NULL) { 486 guarantee(cp->operands()->is_perm(), "should be in permspace"); 487 guarantee(cp->operands()->is_typeArray(), "should be type array"); 488 } 489 if (cp->pool_holder() != NULL) { 490 // Note: pool_holder() can be NULL in temporary constant pools 491 // used during constant pool merging 492 guarantee(cp->pool_holder()->is_perm(), "should be in permspace"); 493 guarantee(cp->pool_holder()->is_klass(), "should be klass"); 494 } 495 } |