comparison src/share/vm/oops/klass.cpp @ 7212:291ffc492eb6

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Fri, 14 Dec 2012 14:35:13 +0100
parents 2cb439954abf 90273fc0a981
children 5fc51c1ecdeb
comparison
equal deleted inserted replaced
7163:2ed8d74e5984 7212:291ffc492eb6
371 // make ourselves the superklass' first subklass 371 // make ourselves the superklass' first subklass
372 super->set_subklass(this); 372 super->set_subklass(this);
373 debug_only(verify();) 373 debug_only(verify();)
374 } 374 }
375 375
376 void Klass::remove_from_sibling_list() {
377 // remove receiver from sibling list
378 InstanceKlass* super = superklass();
379 assert(super != NULL || this == SystemDictionary::Object_klass(), "should have super");
380 if (super == NULL) return; // special case: class Object
381 if (super->subklass() == this) {
382 // first subklass
383 super->set_subklass(_next_sibling);
384 } else {
385 Klass* sib = super->subklass();
386 while (sib->next_sibling() != this) {
387 sib = sib->next_sibling();
388 };
389 sib->set_next_sibling(_next_sibling);
390 }
391 }
392
393 bool Klass::is_loader_alive(BoolObjectClosure* is_alive) { 376 bool Klass::is_loader_alive(BoolObjectClosure* is_alive) {
394 assert(is_metadata(), "p is not meta-data"); 377 assert(is_metadata(), "p is not meta-data");
395 assert(ClassLoaderDataGraph::contains((address)this), "is in the metaspace"); 378 assert(ClassLoaderDataGraph::contains((address)this), "is in the metaspace");
379
380 #ifdef ASSERT
396 // The class is alive iff the class loader is alive. 381 // The class is alive iff the class loader is alive.
397 oop loader = class_loader(); 382 oop loader = class_loader();
398 return (loader == NULL) || is_alive->do_object_b(loader); 383 bool loader_alive = (loader == NULL) || is_alive->do_object_b(loader);
384 #endif // ASSERT
385
386 // The class is alive if it's mirror is alive (which should be marked if the
387 // loader is alive) unless it's an anoymous class.
388 bool mirror_alive = is_alive->do_object_b(java_mirror());
389 assert(!mirror_alive || loader_alive, "loader must be alive if the mirror is"
390 " but not the other way around with anonymous classes");
391 return mirror_alive;
399 } 392 }
400 393
401 void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) { 394 void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) {
402 if (!ClassUnloading) { 395 if (!ClassUnloading) {
403 return; 396 return;
414 407
415 // Find and set the first alive subklass 408 // Find and set the first alive subklass
416 Klass* sub = current->subklass_oop(); 409 Klass* sub = current->subklass_oop();
417 while (sub != NULL && !sub->is_loader_alive(is_alive)) { 410 while (sub != NULL && !sub->is_loader_alive(is_alive)) {
418 #ifndef PRODUCT 411 #ifndef PRODUCT
419 if (TraceClassUnloading && WizardMode) { 412 if (TraceClassUnloading && WizardMode) {
420 ResourceMark rm; 413 ResourceMark rm;
421 tty->print_cr("[Unlinking class (subclass) %s]", sub->external_name()); 414 tty->print_cr("[Unlinking class (subclass) %s]", sub->external_name());
422 } 415 }
423 #endif 416 #endif
424 sub = sub->next_sibling_oop(); 417 sub = sub->next_sibling_oop();
425 } 418 }
426 current->set_subklass(sub); 419 current->set_subklass(sub);
427 if (sub != NULL) { 420 if (sub != NULL) {
429 } 422 }
430 423
431 // Find and set the first alive sibling 424 // Find and set the first alive sibling
432 Klass* sibling = current->next_sibling_oop(); 425 Klass* sibling = current->next_sibling_oop();
433 while (sibling != NULL && !sibling->is_loader_alive(is_alive)) { 426 while (sibling != NULL && !sibling->is_loader_alive(is_alive)) {
434 if (TraceClassUnloading && WizardMode) { 427 if (TraceClassUnloading && WizardMode) {
435 ResourceMark rm; 428 ResourceMark rm;
436 tty->print_cr("[Unlinking class (sibling) %s]", sibling->external_name()); 429 tty->print_cr("[Unlinking class (sibling) %s]", sibling->external_name());
437 } 430 }
438 sibling = sibling->next_sibling_oop(); 431 sibling = sibling->next_sibling_oop();
439 } 432 }
440 current->set_next_sibling(sibling); 433 current->set_next_sibling(sibling);
441 if (sibling != NULL) { 434 if (sibling != NULL) {
442 stack.push(sibling); 435 stack.push(sibling);
443 } 436 }
444 437
445 // Clean the implementors list and method data. 438 // Clean the implementors list and method data.
446 if (current->oop_is_instance()) { 439 if (current->oop_is_instance()) {
447 InstanceKlass* ik = InstanceKlass::cast(current); 440 InstanceKlass* ik = InstanceKlass::cast(current);
448 ik->clean_implementors_list(is_alive); 441 ik->clean_implementors_list(is_alive);
552 const char* Klass::external_name() const { 545 const char* Klass::external_name() const {
553 if (oop_is_instance()) { 546 if (oop_is_instance()) {
554 InstanceKlass* ik = (InstanceKlass*) this; 547 InstanceKlass* ik = (InstanceKlass*) this;
555 if (ik->is_anonymous()) { 548 if (ik->is_anonymous()) {
556 assert(EnableInvokeDynamic, ""); 549 assert(EnableInvokeDynamic, "");
557 intptr_t hash = ik->java_mirror()->identity_hash(); 550 intptr_t hash = 0;
551 if (ik->java_mirror() != NULL) {
552 // java_mirror might not be created yet, return 0 as hash.
553 hash = ik->java_mirror()->identity_hash();
554 }
558 char hash_buf[40]; 555 char hash_buf[40];
559 sprintf(hash_buf, "/" UINTX_FORMAT, (uintx)hash); 556 sprintf(hash_buf, "/" UINTX_FORMAT, (uintx)hash);
560 size_t hash_len = strlen(hash_buf); 557 size_t hash_len = strlen(hash_buf);
561 558
562 size_t result_len = name()->utf8_length(); 559 size_t result_len = name()->utf8_length();