< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahNMethod.hpp

Print this page

 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHNMETHOD_HPP
 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHNMETHOD_HPP
 27 
 28 #include "code/nmethod.hpp"
 29 #include "gc/shenandoah/shenandoahHeap.hpp"
 30 #include "gc/shenandoah/shenandoahLock.hpp"
 31 #include "gc/shenandoah/shenandoahPadding.hpp"
 32 #include "memory/allocation.hpp"
 33 #include "runtime/atomic.hpp"
 34 #include "utilities/growableArray.hpp"
 35 
 36 // Use ShenandoahReentrantLock as ShenandoahNMethodLock
 37 typedef ShenandoahReentrantLock<ShenandoahSimpleLock> ShenandoahNMethodLock;
 38 typedef ShenandoahLocker<ShenandoahNMethodLock>       ShenandoahNMethodLocker;
 39 






 40 // ShenandoahNMethod tuple records the internal locations of oop slots within reclocation stream in
 41 // the nmethod. This allows us to quickly scan the oops without doing the nmethod-internal scans,
 42 // that sometimes involves parsing the machine code. Note it does not record the oops themselves,
 43 // because it would then require handling these tuples as the new class of roots.
 44 class ShenandoahNMethod : public CHeapObj<mtGC> {
 45 private:
 46   nmethod* const          _nm;
 47   oop**                   _oops;
 48   int                     _oops_count;


 49   bool                    _has_non_immed_oops;
 50   bool                    _unregistered;
 51   ShenandoahNMethodLock   _lock;
 52   ShenandoahNMethodLock   _ic_lock;
 53 
 54 public:
 55   ShenandoahNMethod(nmethod *nm, GrowableArray<oop*>& oops, bool has_non_immed_oops);
 56   ~ShenandoahNMethod();
 57 















 58   inline nmethod* nm() const;
 59   inline ShenandoahNMethodLock* lock();
 60   inline ShenandoahNMethodLock* ic_lock();
 61   inline void oops_do(OopClosure* oops, bool fix_relocations = false);
 62   // Update oops when the nmethod is re-registered
 63   void update();
 64 
 65   inline bool is_unregistered() const;
 66 
 67   static ShenandoahNMethod* for_nmethod(nmethod* nm);
 68   static inline ShenandoahNMethodLock* lock_for_nmethod(nmethod* nm);
 69   static inline ShenandoahNMethodLock* ic_lock_for_nmethod(nmethod* nm);
 70 
 71   static void heal_nmethod(nmethod* nm);

 72   static inline void heal_nmethod_metadata(ShenandoahNMethod* nmethod_data);
 73   static inline void disarm_nmethod(nmethod* nm);
 74 
 75   static inline ShenandoahNMethod* gc_data(nmethod* nm);
 76   static inline void attach_gc_data(nmethod* nm, ShenandoahNMethod* gc_data);
 77 
 78   void assert_correct() NOT_DEBUG_RETURN;
 79   void assert_same_oops() NOT_DEBUG_RETURN;
 80 
 81 private:
 82   static void detect_reloc_oops(nmethod* nm, GrowableArray<oop*>& oops, bool& _has_non_immed_oops);

 83 };
 84 
 85 class ShenandoahNMethodTable;
 86 
 87 // ShenandoahNMethodList holds registered nmethod data. The list is reference counted.
 88 class ShenandoahNMethodList : public CHeapObj<mtGC> {
 89 private:
 90   ShenandoahNMethod** _list;
 91   const int           _size;
 92   uint                _ref_count;
 93 
 94 private:
 95   ~ShenandoahNMethodList();
 96 
 97 public:
 98   ShenandoahNMethodList(int size);
 99 
100   // Reference counting with CoceCache_lock held
101   ShenandoahNMethodList* acquire();
102   void release();

 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHNMETHOD_HPP
 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHNMETHOD_HPP
 27 
 28 #include "code/nmethod.hpp"
 29 #include "gc/shenandoah/shenandoahHeap.hpp"
 30 #include "gc/shenandoah/shenandoahLock.hpp"
 31 #include "gc/shenandoah/shenandoahPadding.hpp"
 32 #include "memory/allocation.hpp"
 33 #include "runtime/atomic.hpp"
 34 #include "utilities/growableArray.hpp"
 35 
 36 // Use ShenandoahReentrantLock as ShenandoahNMethodLock
 37 typedef ShenandoahReentrantLock<ShenandoahSimpleLock> ShenandoahNMethodLock;
 38 typedef ShenandoahLocker<ShenandoahNMethodLock>       ShenandoahNMethodLocker;
 39 
 40 struct ShenandoahNMethodBarrier {
 41   int _rel_pc;
 42   int _rel_target;
 43   int _metadata;
 44 };
 45 
 46 // ShenandoahNMethod tuple records the internal locations of oop slots within reclocation stream in
 47 // the nmethod. This allows us to quickly scan the oops without doing the nmethod-internal scans,
 48 // that sometimes involves parsing the machine code. Note it does not record the oops themselves,
 49 // because it would then require handling these tuples as the new class of roots.
 50 class ShenandoahNMethod : public CHeapObj<mtGC> {
 51 private:
 52   nmethod* const          _nm;
 53   oop**                   _oops;
 54   int                     _oops_count;
 55   ShenandoahNMethodBarrier* _barriers;
 56   int                     _barriers_count;
 57   bool                    _has_non_immed_oops;
 58   bool                    _unregistered;
 59   ShenandoahNMethodLock   _lock;
 60   ShenandoahNMethodLock   _ic_lock;
 61 
 62 public:
 63   ShenandoahNMethod(nmethod *nm);
 64   ~ShenandoahNMethod();
 65 
 66   static bool decode_reloc_inverted(int reloc) {
 67     return (reloc & (1 << 8)) != 0;
 68   }
 69 
 70   static char decode_reloc_gc_state(int reloc) {
 71     return (reloc & 0xFF);
 72   }
 73 
 74   static int encode_to_reloc(char gc_state, bool inverted) {
 75     int res = (gc_state & 0xFF) | (inverted ? (1 << 8) : 0);
 76     assert(decode_reloc_inverted(res) == inverted, "Round-trip");
 77     assert(decode_reloc_gc_state(res) == gc_state, "Round-trip");
 78     return res;
 79   }
 80 
 81   inline nmethod* nm() const;
 82   inline ShenandoahNMethodLock* lock();
 83   inline ShenandoahNMethodLock* ic_lock();
 84   inline void oops_do(OopClosure* oops, bool fix_relocations = false);
 85   // Update oops when the nmethod is re-registered
 86   void update();
 87 
 88   inline bool is_unregistered() const;
 89 
 90   static ShenandoahNMethod* for_nmethod(nmethod* nm);
 91   static inline ShenandoahNMethodLock* lock_for_nmethod(nmethod* nm);
 92   static inline ShenandoahNMethodLock* ic_lock_for_nmethod(nmethod* nm);
 93 
 94   static void heal_nmethod(nmethod* nm);
 95   static bool update_barriers(nmethod* nm);
 96   static inline void heal_nmethod_metadata(ShenandoahNMethod* nmethod_data);
 97   static inline void disarm_nmethod(nmethod* nm);
 98 
 99   static inline ShenandoahNMethod* gc_data(nmethod* nm);
100   static inline void attach_gc_data(nmethod* nm, ShenandoahNMethod* gc_data);
101 
102   void assert_correct() NOT_DEBUG_RETURN;
103   void assert_same_oops() NOT_DEBUG_RETURN;
104 
105 private:
106   void init_from(nmethod* nm);
107   static void parse(nmethod* nm, GrowableArray<oop*>& oops, bool& _has_non_immed_oops, GrowableArray<ShenandoahNMethodBarrier>& barriers);
108 };
109 
110 class ShenandoahNMethodTable;
111 
112 // ShenandoahNMethodList holds registered nmethod data. The list is reference counted.
113 class ShenandoahNMethodList : public CHeapObj<mtGC> {
114 private:
115   ShenandoahNMethod** _list;
116   const int           _size;
117   uint                _ref_count;
118 
119 private:
120   ~ShenandoahNMethodList();
121 
122 public:
123   ShenandoahNMethodList(int size);
124 
125   // Reference counting with CoceCache_lock held
126   ShenandoahNMethodList* acquire();
127   void release();
< prev index next >