743 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
743 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
744 for (int i = 0; i < the_table()->table_size(); ++i) { |
744 for (int i = 0; i < the_table()->table_size(); ++i) { |
745 HashtableEntry<oop, mtSymbol>** p = the_table()->bucket_addr(i); |
745 HashtableEntry<oop, mtSymbol>** p = the_table()->bucket_addr(i); |
746 HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i); |
746 HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i); |
747 while (entry != NULL) { |
747 while (entry != NULL) { |
748 // Shared entries are normally at the end of the bucket and if we run into |
748 assert(!entry->is_shared(), "CDS not used for the StringTable"); |
749 // a shared entry, then there is nothing more to remove. However, if we |
749 |
750 // have rehashed the table, then the shared entries are no longer at the |
750 if (is_alive->do_object_b(entry->literal())) { |
751 // end of the bucket. |
|
752 if (entry->is_shared() && !use_alternate_hashcode()) { |
|
753 break; |
|
754 } |
|
755 assert(entry->literal() != NULL, "just checking"); |
|
756 if (entry->is_shared() || is_alive->do_object_b(entry->literal())) { |
|
757 p = entry->next_addr(); |
751 p = entry->next_addr(); |
758 } else { |
752 } else { |
759 *p = entry->next(); |
753 *p = entry->next(); |
760 the_table()->free_entry(entry); |
754 the_table()->free_entry(entry); |
761 } |
755 } |
762 entry = (HashtableEntry<oop, mtSymbol>*)HashtableEntry<oop, mtSymbol>::make_ptr(*p); |
756 entry = *p; |
763 } |
757 } |
764 } |
758 } |
765 } |
759 } |
766 |
760 |
767 void StringTable::oops_do(OopClosure* f) { |
761 void StringTable::oops_do(OopClosure* f) { |
768 for (int i = 0; i < the_table()->table_size(); ++i) { |
762 for (int i = 0; i < the_table()->table_size(); ++i) { |
769 HashtableEntry<oop, mtSymbol>** p = the_table()->bucket_addr(i); |
|
770 HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i); |
763 HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i); |
771 while (entry != NULL) { |
764 while (entry != NULL) { |
|
765 assert(!entry->is_shared(), "CDS not used for the StringTable"); |
|
766 |
772 f->do_oop((oop*)entry->literal_addr()); |
767 f->do_oop((oop*)entry->literal_addr()); |
773 |
768 |
774 // Did the closure remove the literal from the table? |
769 entry = entry->next(); |
775 if (entry->literal() == NULL) { |
|
776 assert(!entry->is_shared(), "immutable hashtable entry?"); |
|
777 *p = entry->next(); |
|
778 the_table()->free_entry(entry); |
|
779 } else { |
|
780 p = entry->next_addr(); |
|
781 } |
|
782 entry = (HashtableEntry<oop, mtSymbol>*)HashtableEntry<oop, mtSymbol>::make_ptr(*p); |
|
783 } |
770 } |
784 } |
771 } |
785 } |
772 } |
786 |
773 |
787 void StringTable::verify() { |
774 void StringTable::verify() { |