src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp
changeset 59296 9186be5c78ba
parent 55316 218f5a414379
equal deleted inserted replaced
59295:8b6cc0bb93d0 59296:9186be5c78ba
    25 #define SHARE_GC_SHENANDOAH_SHENANDOAHCODEROOTS_HPP
    25 #define SHARE_GC_SHENANDOAH_SHENANDOAHCODEROOTS_HPP
    26 
    26 
    27 #include "code/codeCache.hpp"
    27 #include "code/codeCache.hpp"
    28 #include "gc/shenandoah/shenandoahSharedVariables.hpp"
    28 #include "gc/shenandoah/shenandoahSharedVariables.hpp"
    29 #include "gc/shenandoah/shenandoahLock.hpp"
    29 #include "gc/shenandoah/shenandoahLock.hpp"
       
    30 #include "gc/shenandoah/shenandoahNMethod.hpp"
    30 #include "memory/allocation.hpp"
    31 #include "memory/allocation.hpp"
    31 #include "memory/iterator.hpp"
    32 #include "memory/iterator.hpp"
    32 
    33 
    33 class ShenandoahHeap;
    34 class ShenandoahHeap;
    34 class ShenandoahHeapRegion;
    35 class ShenandoahHeapRegion;
    60   ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps);
    61   ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps);
    61   ~ShenandoahParallelCodeCacheIterator();
    62   ~ShenandoahParallelCodeCacheIterator();
    62   void parallel_blobs_do(CodeBlobClosure* f);
    63   void parallel_blobs_do(CodeBlobClosure* f);
    63 };
    64 };
    64 
    65 
    65 // ShenandoahNMethod tuple records the internal locations of oop slots within the nmethod.
       
    66 // This allows us to quickly scan the oops without doing the nmethod-internal scans, that
       
    67 // sometimes involves parsing the machine code. Note it does not record the oops themselves,
       
    68 // because it would then require handling these tuples as the new class of roots.
       
    69 class ShenandoahNMethod : public CHeapObj<mtGC> {
       
    70 private:
       
    71   nmethod* _nm;
       
    72   oop**    _oops;
       
    73   int      _oops_count;
       
    74 
       
    75 public:
       
    76   ShenandoahNMethod(nmethod *nm, GrowableArray<oop*>* oops);
       
    77   ~ShenandoahNMethod();
       
    78 
       
    79   nmethod* nm() {
       
    80     return _nm;
       
    81   }
       
    82 
       
    83   bool has_cset_oops(ShenandoahHeap* heap);
       
    84 
       
    85   void assert_alive_and_correct() NOT_DEBUG_RETURN;
       
    86   void assert_same_oops(GrowableArray<oop*>* oops) NOT_DEBUG_RETURN;
       
    87 
       
    88   static bool find_with_nmethod(void* nm, ShenandoahNMethod* other) {
       
    89     return other->_nm == nm;
       
    90   }
       
    91 };
       
    92 
       
    93 class ShenandoahCodeRootsIterator {
    66 class ShenandoahCodeRootsIterator {
    94   friend class ShenandoahCodeRoots;
    67   friend class ShenandoahCodeRoots;
    95 protected:
    68 protected:
    96   ShenandoahHeap* _heap;
       
    97   ShenandoahParallelCodeCacheIterator _par_iterator;
    69   ShenandoahParallelCodeCacheIterator _par_iterator;
    98   ShenandoahSharedFlag _seq_claimed;
    70   ShenandoahSharedFlag _seq_claimed;
    99   DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile size_t));
    71   ShenandoahNMethodTableSnapshot* _table_snapshot;
   100   volatile size_t _claimed;
    72 
   101   DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0);
       
   102 protected:
    73 protected:
   103   ShenandoahCodeRootsIterator();
    74   ShenandoahCodeRootsIterator();
   104   ~ShenandoahCodeRootsIterator();
    75   ~ShenandoahCodeRootsIterator();
   105 
    76 
   106   template<bool CSET_FILTER>
    77   template<bool CSET_FILTER>
   126   friend class ShenandoahHeap;
    97   friend class ShenandoahHeap;
   127   friend class ShenandoahCodeRootsIterator;
    98   friend class ShenandoahCodeRootsIterator;
   128 
    99 
   129 public:
   100 public:
   130   static void initialize();
   101   static void initialize();
   131   static void add_nmethod(nmethod* nm);
   102   static void register_nmethod(nmethod* nm);
   132   static void remove_nmethod(nmethod* nm);
   103   static void unregister_nmethod(nmethod* nm);
       
   104   static void flush_nmethod(nmethod* nm);
       
   105 
       
   106   static ShenandoahNMethodTable* table() {
       
   107     return _nmethod_table;
       
   108   }
       
   109 
       
   110   // Concurrent nmethod unloading support
       
   111   static void unlink(WorkGang* workers, bool unloading_occurred);
       
   112   static void purge(WorkGang* workers);
       
   113   static void prepare_concurrent_unloading();
       
   114   static int  disarmed_value()         { return _disarmed_value; }
       
   115   static int* disarmed_value_address() { return &_disarmed_value; }
   133 
   116 
   134 private:
   117 private:
   135   static GrowableArray<ShenandoahNMethod*>* _recorded_nms;
   118   static ShenandoahNMethodTable* _nmethod_table;
   136   static ShenandoahLock                     _recorded_nms_lock;
   119   static int                     _disarmed_value;
   137 };
   120 };
   138 
   121 
   139 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCODEROOTS_HPP
   122 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCODEROOTS_HPP