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 bool purge_entry = ik->is_in_error_state();
231
232 if (purge_entry) {
233 *p = probe->next();
234 if (probe == _current_class_entry) {
235 _current_class_entry = NULL;
236 }
237 free_entry(probe);
238 ResourceMark rm;
239 tty->print_cr("Removed error class: %s", ik->external_name());
240 continue;
241 }
242
243 p = probe->next_addr();
244 }
245 }
246 }
247
248 void Dictionary::always_strong_oops_do(OopClosure* blk) {
249 // Follow all system classes and temporary placeholders in dictionary; only
250 // protection domain oops contain references into the heap. In a first
251 // pass over the system dictionary determine which need to be treated as
252 // strongly reachable and mark them as such.
253 for (int index = 0; index < table_size(); index++) {
254 for (DictionaryEntry *probe = bucket(index);
255 probe != NULL;
256 probe = probe->next()) {
257 Klass* e = probe->klass();
258 ClassLoaderData* loader_data = probe->loader_data();
259 if (is_strongly_reachable(loader_data, e)) {
260 probe->set_strongly_reachable();
261 }
262 }
263 }
264 // Then iterate over the protection domain cache to apply the closure on the
265 // previously marked ones.
266 _pd_cache_table->always_strong_oops_do(blk);
267 }
701 if (p->method_type() != NULL) {
702 f->do_oop(p->method_type_addr());
703 }
704 }
705 }
706 }
707
708 void SymbolPropertyTable::methods_do(void f(Method*)) {
709 for (int index = 0; index < table_size(); index++) {
710 for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
711 Method* prop = p->method();
712 if (prop != NULL) {
713 f((Method*)prop);
714 }
715 }
716 }
717 }
718
719
720 // ----------------------------------------------------------------------------
721
722 void Dictionary::print(bool details) {
723 ResourceMark rm;
724 HandleMark hm;
725
726 if (details) {
727 tty->print_cr("Java system dictionary (table_size=%d, classes=%d)",
728 table_size(), number_of_entries());
729 tty->print_cr("^ indicates that initiating loader is different from "
730 "defining loader");
731 }
732
733 for (int index = 0; index < table_size(); index++) {
734 for (DictionaryEntry* probe = bucket(index);
735 probe != NULL;
736 probe = probe->next()) {
737 if (Verbose) tty->print("%4d: ", index);
738 Klass* e = probe->klass();
739 ClassLoaderData* loader_data = probe->loader_data();
740 bool is_defining_class =
741 (loader_data == InstanceKlass::cast(e)->class_loader_data());
742 tty->print("%s%s", ((!details) || is_defining_class) ? " " : "^",
743 e->external_name());
744
745 if (details) {
746 tty->print(", loader ");
747 if (loader_data != NULL) {
748 loader_data->print_value();
749 } else {
750 tty->print("NULL");
751 }
752 }
753 tty->cr();
754 }
755 }
756
757 if (details) {
758 tty->cr();
759 _pd_cache_table->print();
760 }
761 tty->cr();
762 }
763
764 void Dictionary::verify() {
765 guarantee(number_of_entries() >= 0, "Verify of system dictionary failed");
766
767 int element_count = 0;
768 for (int index = 0; index < table_size(); index++) {
769 for (DictionaryEntry* probe = bucket(index);
770 probe != NULL;
771 probe = probe->next()) {
772 Klass* e = probe->klass();
773 ClassLoaderData* loader_data = probe->loader_data();
774 guarantee(e->oop_is_instance(),
775 "Verify of system dictionary failed");
776 // class loader must be present; a null class loader is the
777 // boostrap loader
778 guarantee(loader_data != NULL || DumpSharedSpaces ||
779 loader_data->class_loader() == NULL ||
780 loader_data->class_loader()->is_instance(),
781 "checking type of class_loader");
782 e->verify();
|