diff -r 8b6cc0bb93d0 -r 9186be5c78ba src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp --- a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp Wed Nov 27 06:36:41 2019 -0800 +++ b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp Wed Nov 27 11:52:57 2019 -0500 @@ -27,6 +27,7 @@ #include "code/codeCache.hpp" #include "gc/shenandoah/shenandoahSharedVariables.hpp" #include "gc/shenandoah/shenandoahLock.hpp" +#include "gc/shenandoah/shenandoahNMethod.hpp" #include "memory/allocation.hpp" #include "memory/iterator.hpp" @@ -62,43 +63,13 @@ void parallel_blobs_do(CodeBlobClosure* f); }; -// ShenandoahNMethod tuple records the internal locations of oop slots within the nmethod. -// This allows us to quickly scan the oops without doing the nmethod-internal scans, that -// sometimes involves parsing the machine code. Note it does not record the oops themselves, -// because it would then require handling these tuples as the new class of roots. -class ShenandoahNMethod : public CHeapObj { -private: - nmethod* _nm; - oop** _oops; - int _oops_count; - -public: - ShenandoahNMethod(nmethod *nm, GrowableArray* oops); - ~ShenandoahNMethod(); - - nmethod* nm() { - return _nm; - } - - bool has_cset_oops(ShenandoahHeap* heap); - - void assert_alive_and_correct() NOT_DEBUG_RETURN; - void assert_same_oops(GrowableArray* oops) NOT_DEBUG_RETURN; - - static bool find_with_nmethod(void* nm, ShenandoahNMethod* other) { - return other->_nm == nm; - } -}; - class ShenandoahCodeRootsIterator { friend class ShenandoahCodeRoots; protected: - ShenandoahHeap* _heap; ShenandoahParallelCodeCacheIterator _par_iterator; ShenandoahSharedFlag _seq_claimed; - DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile size_t)); - volatile size_t _claimed; - DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0); + ShenandoahNMethodTableSnapshot* _table_snapshot; + protected: ShenandoahCodeRootsIterator(); ~ShenandoahCodeRootsIterator(); @@ -128,12 +99,24 @@ public: static void initialize(); - static void add_nmethod(nmethod* nm); - static void remove_nmethod(nmethod* nm); + static void register_nmethod(nmethod* nm); + static void unregister_nmethod(nmethod* nm); + static void flush_nmethod(nmethod* nm); + + static ShenandoahNMethodTable* table() { + return _nmethod_table; + } + + // Concurrent nmethod unloading support + static void unlink(WorkGang* workers, bool unloading_occurred); + static void purge(WorkGang* workers); + static void prepare_concurrent_unloading(); + static int disarmed_value() { return _disarmed_value; } + static int* disarmed_value_address() { return &_disarmed_value; } private: - static GrowableArray* _recorded_nms; - static ShenandoahLock _recorded_nms_lock; + static ShenandoahNMethodTable* _nmethod_table; + static int _disarmed_value; }; #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCODEROOTS_HPP