< prev index next >

src/hotspot/share/gc/z/zUnload.cpp


47       _is_alive(),                                                                                                                   
48       _is_unloading(false) {}                                                                                                        
49 
50   virtual void do_oop(oop* p) {                                                                                                      
51     const oop o = RawAccess<>::oop_load(p);                                                                                          
52     if (o != NULL && !_is_alive.do_object_b(o)) {                                                                                    
53       _is_unloading = true;                                                                                                          
54     }                                                                                                                                
55   }                                                                                                                                  
56 
57   virtual void do_oop(narrowOop* p) {                                                                                                
58     ShouldNotReachHere();                                                                                                            
59   }                                                                                                                                  
60 
61   bool is_unloading() const {                                                                                                        
62     return _is_unloading;                                                                                                            
63   }                                                                                                                                  
64 };                                                                                                                                   
65 
66 class ZIsUnloadingBehaviour : public IsUnloadingBehaviour {                                                                          
67 private:                                                                                                                             
68   bool is_unloading(nmethod* nm) const {                                                                                             
69     ZIsUnloadingOopClosure cl;                                                                                                       
70     nm->oops_do(&cl, true /* allow_zombie */);                                                                                       
71     return cl.is_unloading();                                                                                                        
72   }                                                                                                                                  
73                                                                                                                                      
74 public:                                                                                                                              
75   virtual bool is_unloading(CompiledMethod* method) const {                                                                          
76     nmethod* const nm = method->as_nmethod();                                                                                        
77     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);                                                                     
78     if (lock == NULL) {                                                                                                              
79       return is_unloading(nm);                                                                                                       
80     } else {                                                                                                                         
81       ZLocker<ZReentrantLock> locker(lock);                                                                                          
82       return is_unloading(nm);                                                                                                       
83     }                                                                                                                                
84   }                                                                                                                                  
85 };                                                                                                                                   
86 
87 class ZCompiledICProtectionBehaviour : public CompiledICProtectionBehaviour {                                                        
88 public:                                                                                                                              
89   virtual bool lock(CompiledMethod* method) {                                                                                        
90     nmethod* const nm = method->as_nmethod();                                                                                        
91     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);                                                                     
92     if (lock != NULL) {                                                                                                              
93       lock->lock();                                                                                                                  
94     }                                                                                                                                
95     return true;                                                                                                                     
96   }                                                                                                                                  
97 
98   virtual void unlock(CompiledMethod* method) {                                                                                      
99     nmethod* const nm = method->as_nmethod();                                                                                        
100     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);                                                                     
101     if (lock != NULL) {                                                                                                              
102       lock->unlock();                                                                                                                
103     }                                                                                                                                
104   }                                                                                                                                  
105 
106   virtual bool is_safe(CompiledMethod* method) {                                                                                     
107     if (SafepointSynchronize::is_at_safepoint()) {                                                                                   
108       return true;                                                                                                                   
109     }                                                                                                                                
110 
111     nmethod* const nm = method->as_nmethod();                                                                                        
112     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);                                                                     
113     return lock == NULL || lock->is_owned();                                                                                         
114   }                                                                                                                                  
115 };                                                                                                                                   
116 
117 ZUnload::ZUnload(ZWorkers* workers) :                                                                                                
118     _workers(workers) {                                                                                                              
119 
120   if (!ClassUnloading) {                                                                                                             
121     return;                                                                                                                          
122   }                                                                                                                                  
123 
124   static ZIsUnloadingBehaviour is_unloading_behaviour;                                                                               
125   IsUnloadingBehaviour::set_current(&is_unloading_behaviour);                                                                        
126 
127   static ZCompiledICProtectionBehaviour ic_protection_behaviour;                                                                     
128   CompiledICProtectionBehaviour::set_current(&ic_protection_behaviour);                                                              
129 }                                                                                                                                    
130 
131 void ZUnload::prepare() {                                                                                                            
132   if (!ClassUnloading) {                                                                                                             

47       _is_alive(),
48       _is_unloading(false) {}
49 
50   virtual void do_oop(oop* p) {
51     const oop o = RawAccess<>::oop_load(p);
52     if (o != NULL && !_is_alive.do_object_b(o)) {
53       _is_unloading = true;
54     }
55   }
56 
57   virtual void do_oop(narrowOop* p) {
58     ShouldNotReachHere();
59   }
60 
61   bool is_unloading() const {
62     return _is_unloading;
63   }
64 };
65 
66 class ZIsUnloadingBehaviour : public IsUnloadingBehaviour {







67 public:
68   virtual bool is_unloading(CompiledMethod* method) const {
69     nmethod* const nm = method->as_nmethod();
70     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
71     ZLocker<ZReentrantLock> locker(lock);
72     ZIsUnloadingOopClosure cl;
73     nm->oops_do(&cl, true /* allow_zombie */);
74     return cl.is_unloading();


75   }
76 };
77 
78 class ZCompiledICProtectionBehaviour : public CompiledICProtectionBehaviour {
79 public:
80   virtual bool lock(CompiledMethod* method) {
81     nmethod* const nm = method->as_nmethod();
82     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
83     lock->lock();


84     return true;
85   }
86 
87   virtual void unlock(CompiledMethod* method) {
88     nmethod* const nm = method->as_nmethod();
89     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
90     lock->unlock();


91   }
92 
93   virtual bool is_safe(CompiledMethod* method) {
94     if (SafepointSynchronize::is_at_safepoint()) {
95       return true;
96     }
97 
98     nmethod* const nm = method->as_nmethod();
99     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
100     return lock->is_owned();
101   }
102 };
103 
104 ZUnload::ZUnload(ZWorkers* workers) :
105     _workers(workers) {
106 
107   if (!ClassUnloading) {
108     return;
109   }
110 
111   static ZIsUnloadingBehaviour is_unloading_behaviour;
112   IsUnloadingBehaviour::set_current(&is_unloading_behaviour);
113 
114   static ZCompiledICProtectionBehaviour ic_protection_behaviour;
115   CompiledICProtectionBehaviour::set_current(&ic_protection_behaviour);
116 }
117 
118 void ZUnload::prepare() {
119   if (!ClassUnloading) {
< prev index next >