src/share/vm/classfile/dictionary.cpp

Print this page
rev 6853 : 8046070: Class Data Sharing clean up and refactoring
Summary: Cleaned up CDS to be more configurable, maintainable and extensible
Reviewed-by: dholmes, coleenp, acorn, mchung


 203   // Skip the strong roots probe marking if the closures are the same.
 204   if (strong == weak) {
 205     oops_do(strong);
 206     return;
 207   }
 208 
 209   for (int index = 0; index < table_size(); index++) {
 210     for (DictionaryEntry *probe = bucket(index);
 211                           probe != NULL;
 212                           probe = probe->next()) {
 213       Klass* e = probe->klass();
 214       ClassLoaderData* loader_data = probe->loader_data();
 215       if (is_strongly_reachable(loader_data, e)) {
 216         probe->set_strongly_reachable();
 217       }
 218     }
 219   }
 220   _pd_cache_table->roots_oops_do(strong, weak);
 221 }
 222 























 223 void Dictionary::always_strong_oops_do(OopClosure* blk) {
 224   // Follow all system classes and temporary placeholders in dictionary; only
 225   // protection domain oops contain references into the heap. In a first
 226   // pass over the system dictionary determine which need to be treated as
 227   // strongly reachable and mark them as such.
 228   for (int index = 0; index < table_size(); index++) {
 229     for (DictionaryEntry *probe = bucket(index);
 230                           probe != NULL;
 231                           probe = probe->next()) {
 232       Klass* e = probe->klass();
 233       ClassLoaderData* loader_data = probe->loader_data();
 234       if (is_strongly_reachable(loader_data, e)) {
 235         probe->set_strongly_reachable();
 236       }
 237     }
 238   }
 239   // Then iterate over the protection domain cache to apply the closure on the
 240   // previously marked ones.
 241   _pd_cache_table->always_strong_oops_do(blk);
 242 }


 676       if (p->method_type() != NULL) {
 677         f->do_oop(p->method_type_addr());
 678       }
 679     }
 680   }
 681 }
 682 
 683 void SymbolPropertyTable::methods_do(void f(Method*)) {
 684   for (int index = 0; index < table_size(); index++) {
 685     for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
 686       Method* prop = p->method();
 687       if (prop != NULL) {
 688         f((Method*)prop);
 689       }
 690     }
 691   }
 692 }
 693 
 694 
 695 // ----------------------------------------------------------------------------
 696 #ifndef PRODUCT
 697 
 698 void Dictionary::print() {
 699   ResourceMark rm;
 700   HandleMark   hm;
 701 

 702   tty->print_cr("Java system dictionary (table_size=%d, classes=%d)",
 703                  table_size(), number_of_entries());
 704   tty->print_cr("^ indicates that initiating loader is different from "
 705                 "defining loader");

 706 
 707   for (int index = 0; index < table_size(); index++) {
 708     for (DictionaryEntry* probe = bucket(index);
 709                           probe != NULL;
 710                           probe = probe->next()) {
 711       if (Verbose) tty->print("%4d: ", index);
 712       Klass* e = probe->klass();
 713       ClassLoaderData* loader_data =  probe->loader_data();
 714       bool is_defining_class =
 715          (loader_data == InstanceKlass::cast(e)->class_loader_data());
 716       tty->print("%s%s", is_defining_class ? " " : "^",
 717                    e->external_name());
 718 

 719         tty->print(", loader ");

 720       loader_data->print_value();




 721       tty->cr();
 722     }
 723   }


 724   tty->cr();
 725   _pd_cache_table->print();

 726   tty->cr();
 727 }
 728 
 729 #endif
 730 
 731 void Dictionary::verify() {
 732   guarantee(number_of_entries() >= 0, "Verify of system dictionary failed");
 733 
 734   int element_count = 0;
 735   for (int index = 0; index < table_size(); index++) {
 736     for (DictionaryEntry* probe = bucket(index);
 737                           probe != NULL;
 738                           probe = probe->next()) {
 739       Klass* e = probe->klass();
 740       ClassLoaderData* loader_data = probe->loader_data();
 741       guarantee(e->oop_is_instance(),
 742                               "Verify of system dictionary failed");
 743       // class loader must be present;  a null class loader is the
 744       // boostrap loader
 745       guarantee(loader_data != NULL || DumpSharedSpaces ||
 746                 loader_data->class_loader() == NULL ||
 747                 loader_data->class_loader()->is_instance(),
 748                 "checking type of class_loader");
 749       e->verify();


 203   // Skip the strong roots probe marking if the closures are the same.
 204   if (strong == weak) {
 205     oops_do(strong);
 206     return;
 207   }
 208 
 209   for (int index = 0; index < table_size(); index++) {
 210     for (DictionaryEntry *probe = bucket(index);
 211                           probe != NULL;
 212                           probe = probe->next()) {
 213       Klass* e = probe->klass();
 214       ClassLoaderData* loader_data = probe->loader_data();
 215       if (is_strongly_reachable(loader_data, e)) {
 216         probe->set_strongly_reachable();
 217       }
 218     }
 219   }
 220   _pd_cache_table->roots_oops_do(strong, weak);
 221 }
 222 
 223 void Dictionary::remove_classes_in_error_state() {
 224   assert(DumpSharedSpaces, "supported only when dumping");
 225   DictionaryEntry* probe = NULL;
 226   for (int index = 0; index < table_size(); index++) {
 227     for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
 228       probe = *p;
 229       InstanceKlass* ik = InstanceKlass::cast(probe->klass());
 230       if (ik->is_in_error_state()) { // purge this entry
 231         *p = probe->next();
 232         if (probe == _current_class_entry) {
 233           _current_class_entry = NULL;
 234         }
 235         free_entry(probe);
 236         ResourceMark rm;
 237         tty->print_cr("Removed error class: %s", ik->external_name());
 238         continue;
 239       }
 240 
 241       p = probe->next_addr();
 242     }
 243   }
 244 }
 245 
 246 void Dictionary::always_strong_oops_do(OopClosure* blk) {
 247   // Follow all system classes and temporary placeholders in dictionary; only
 248   // protection domain oops contain references into the heap. In a first
 249   // pass over the system dictionary determine which need to be treated as
 250   // strongly reachable and mark them as such.
 251   for (int index = 0; index < table_size(); index++) {
 252     for (DictionaryEntry *probe = bucket(index);
 253                           probe != NULL;
 254                           probe = probe->next()) {
 255       Klass* e = probe->klass();
 256       ClassLoaderData* loader_data = probe->loader_data();
 257       if (is_strongly_reachable(loader_data, e)) {
 258         probe->set_strongly_reachable();
 259       }
 260     }
 261   }
 262   // Then iterate over the protection domain cache to apply the closure on the
 263   // previously marked ones.
 264   _pd_cache_table->always_strong_oops_do(blk);
 265 }


 699       if (p->method_type() != NULL) {
 700         f->do_oop(p->method_type_addr());
 701       }
 702     }
 703   }
 704 }
 705 
 706 void SymbolPropertyTable::methods_do(void f(Method*)) {
 707   for (int index = 0; index < table_size(); index++) {
 708     for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
 709       Method* prop = p->method();
 710       if (prop != NULL) {
 711         f((Method*)prop);
 712       }
 713     }
 714   }
 715 }
 716 
 717 
 718 // ----------------------------------------------------------------------------

 719 
 720 void Dictionary::print(bool details) {
 721   ResourceMark rm;
 722   HandleMark   hm;
 723 
 724   if (details) {
 725     tty->print_cr("Java system dictionary (table_size=%d, classes=%d)",
 726                    table_size(), number_of_entries());
 727     tty->print_cr("^ indicates that initiating loader is different from "
 728                   "defining loader");
 729   }
 730 
 731   for (int index = 0; index < table_size(); index++) {
 732     for (DictionaryEntry* probe = bucket(index);
 733                           probe != NULL;
 734                           probe = probe->next()) {
 735       if (Verbose) tty->print("%4d: ", index);
 736       Klass* e = probe->klass();
 737       ClassLoaderData* loader_data =  probe->loader_data();
 738       bool is_defining_class =
 739          (loader_data == InstanceKlass::cast(e)->class_loader_data());
 740       tty->print("%s%s", ((!details) || is_defining_class) ? " " : "^",
 741                    e->external_name());
 742 
 743       if (details) {
 744         tty->print(", loader ");
 745         if (loader_data != NULL) {
 746           loader_data->print_value();
 747         } else {
 748           tty->print("NULL");
 749         }
 750       }
 751       tty->cr();
 752     }
 753   }
 754 
 755   if (details) {
 756     tty->cr();
 757     _pd_cache_table->print();
 758   }
 759   tty->cr();
 760 }


 761 
 762 void Dictionary::verify() {
 763   guarantee(number_of_entries() >= 0, "Verify of system dictionary failed");
 764 
 765   int element_count = 0;
 766   for (int index = 0; index < table_size(); index++) {
 767     for (DictionaryEntry* probe = bucket(index);
 768                           probe != NULL;
 769                           probe = probe->next()) {
 770       Klass* e = probe->klass();
 771       ClassLoaderData* loader_data = probe->loader_data();
 772       guarantee(e->oop_is_instance(),
 773                               "Verify of system dictionary failed");
 774       // class loader must be present;  a null class loader is the
 775       // boostrap loader
 776       guarantee(loader_data != NULL || DumpSharedSpaces ||
 777                 loader_data->class_loader() == NULL ||
 778                 loader_data->class_loader()->is_instance(),
 779                 "checking type of class_loader");
 780       e->verify();