< prev index next >

src/hotspot/share/code/dependencyContext.hpp


68 
69 //                                                                                                                                   
70 // Utility class to manipulate nmethod dependency context.                                                                           
71 // Dependency context can be attached either to an InstanceKlass (_dep_context field)                                                
72 // or CallSiteContext oop for call_site_target dependencies (see javaClasses.hpp).                                                   
73 // DependencyContext class operates on some location which holds a nmethodBucket* value                                              
74 // and uint64_t integer recording the safepoint counter at the last cleanup.                                                         
75 //                                                                                                                                   
76 class DependencyContext : public StackObj {                                                                                          
77   friend class VMStructs;                                                                                                            
78   friend class TestDependencyContext;                                                                                                
79  private:                                                                                                                            
80   nmethodBucket* volatile* _dependency_context_addr;                                                                                 
81   volatile uint64_t*       _last_cleanup_addr;                                                                                       
82 
83   bool claim_cleanup();                                                                                                              
84   void set_dependencies(nmethodBucket* b);                                                                                           
85   nmethodBucket* dependencies();                                                                                                     
86   nmethodBucket* dependencies_not_unloading();                                                                                       
87 
88   static PerfCounter* _perf_total_buckets_allocated_count;                                                                           
89   static PerfCounter* _perf_total_buckets_deallocated_count;                                                                         
90   static PerfCounter* _perf_total_buckets_stale_count;                                                                               
91   static PerfCounter* _perf_total_buckets_stale_acc_count;                                                                           
92   static nmethodBucket* volatile _purge_list;                                                                                        
                                                                                                                                     
93   static volatile uint64_t       _cleaning_epoch;                                                                                    
94 
95  public:                                                                                                                             
96 #ifdef ASSERT                                                                                                                        
97   // Safepoints are forbidden during DC lifetime. GC can invalidate                                                                  
98   // _dependency_context_addr if it relocates the holder                                                                             
99   // (e.g. CallSiteContext Java object).                                                                                             
100   uint64_t _safepoint_counter;                                                                                                       
101 
102   DependencyContext(nmethodBucket* volatile* bucket_addr, volatile uint64_t* last_cleanup_addr)                                      
103     : _dependency_context_addr(bucket_addr),                                                                                         
104       _last_cleanup_addr(last_cleanup_addr),                                                                                         
105       _safepoint_counter(SafepointSynchronize::safepoint_counter()) {}                                                               
106 
107   ~DependencyContext() {                                                                                                             
108     assert(_safepoint_counter == SafepointSynchronize::safepoint_counter(), "safepoint happened");                                   
109   }                                                                                                                                  
110 #else                                                                                                                                
111   DependencyContext(nmethodBucket* volatile* bucket_addr, volatile uint64_t* last_cleanup_addr)                                      

68 
69 //
70 // Utility class to manipulate nmethod dependency context.
71 // Dependency context can be attached either to an InstanceKlass (_dep_context field)
72 // or CallSiteContext oop for call_site_target dependencies (see javaClasses.hpp).
73 // DependencyContext class operates on some location which holds a nmethodBucket* value
74 // and uint64_t integer recording the safepoint counter at the last cleanup.
75 //
76 class DependencyContext : public StackObj {
77   friend class VMStructs;
78   friend class TestDependencyContext;
79  private:
80   nmethodBucket* volatile* _dependency_context_addr;
81   volatile uint64_t*       _last_cleanup_addr;
82 
83   bool claim_cleanup();
84   void set_dependencies(nmethodBucket* b);
85   nmethodBucket* dependencies();
86   nmethodBucket* dependencies_not_unloading();
87 
88   static PerfCounter*            _perf_total_buckets_allocated_count;
89   static PerfCounter*            _perf_total_buckets_deallocated_count;
90   static PerfCounter*            _perf_total_buckets_stale_count;
91   static PerfCounter*            _perf_total_buckets_stale_acc_count;
92   static nmethodBucket* volatile _purge_list;
93   static uint64_t                _cleaning_epoch_monotonic;
94   static volatile uint64_t       _cleaning_epoch;
95 
96  public:
97 #ifdef ASSERT
98   // Safepoints are forbidden during DC lifetime. GC can invalidate
99   // _dependency_context_addr if it relocates the holder
100   // (e.g. CallSiteContext Java object).
101   uint64_t _safepoint_counter;
102 
103   DependencyContext(nmethodBucket* volatile* bucket_addr, volatile uint64_t* last_cleanup_addr)
104     : _dependency_context_addr(bucket_addr),
105       _last_cleanup_addr(last_cleanup_addr),
106       _safepoint_counter(SafepointSynchronize::safepoint_counter()) {}
107 
108   ~DependencyContext() {
109     assert(_safepoint_counter == SafepointSynchronize::safepoint_counter(), "safepoint happened");
110   }
111 #else
112   DependencyContext(nmethodBucket* volatile* bucket_addr, volatile uint64_t* last_cleanup_addr)
< prev index next >