diff a/src/hotspot/share/gc/shared/oopStorage.hpp b/src/hotspot/share/gc/shared/oopStorage.hpp --- a/src/hotspot/share/gc/shared/oopStorage.hpp +++ b/src/hotspot/share/gc/shared/oopStorage.hpp @@ -72,11 +72,14 @@ // interactions for this protocol. Similarly, see the allocate() function for // a discussion of allocation. class OopStorage : public CHeapObj { public: - OopStorage(const char* name, Mutex* allocation_mutex, Mutex* active_mutex); + // GC notification support. + typedef void (*NotificationFunction)(size_t dead_count); + + OopStorage(const char* name, Mutex* allocation_mutex, Mutex* active_mutex, NotificationFunction f = NULL); ~OopStorage(); // These count and usage accessors are racy unless at a safepoint. // The number of allocated and not yet released entries. @@ -149,10 +152,16 @@ // Parallel iteration is for the exclusive use of the GC. // Other clients must use serial iteration. template class ParState; + // This function is called by the GC to notify the registered notification function. + void notify(size_t num_dead) const; + + // Checks if the given OopStorage has an associated notification function for the GC. + bool can_notify() const; + // Service thread cleanup support. // Called by the service thread to process any pending cleanups for this // storage object. Drains the _deferred_updates list, and deletes empty // blocks. Stops deleting if there is an in-progress concurrent @@ -232,10 +241,12 @@ // mutable because this gets set even for const iteration. mutable int _concurrent_iteration_count; volatile bool _needs_cleanup; + NotificationFunction _notification_function; + bool try_add_block(); Block* block_for_allocation(); Block* find_block_or_null(const oop* ptr) const; void delete_empty_block(const Block& block);