< prev index next >

src/hotspot/share/code/vtableStubs.cpp

Concurrent class unloading

131     // Notify JVMTI about this stub. The event will be recorded by the enclosing                                                     
132     // JvmtiDynamicCodeEventCollector and posted when this thread has released                                                       
133     // all locks.                                                                                                                    
134     if (JvmtiExport::should_post_dynamic_code_generated()) {                                                                         
135       JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub",                     
136                                                                    s->code_begin(), s->code_end());                                  
137     }                                                                                                                                
138   }                                                                                                                                  
139   return s->entry_point();                                                                                                           
140 }                                                                                                                                    
141 
142 
143 inline uint VtableStubs::hash(bool is_vtable_stub, int vtable_index){                                                                
144   // Assumption: receiver_location < 4 in most cases.                                                                                
145   int hash = ((vtable_index << 2) ^ VtableStub::receiver_location()->value()) + vtable_index;                                        
146   return (is_vtable_stub ? ~hash : hash)  & mask;                                                                                    
147 }                                                                                                                                    
148 
149 
150 VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {                                                             
151   MutexLocker ml(VtableStubs_lock);                                                                                                  
152   unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);                                                                   
153   VtableStub* s = _table[hash];                                                                                                      
154   while( s && !s->matches(is_vtable_stub, vtable_index)) s = s->next();                                                              
155   return s;                                                                                                                          
156 }                                                                                                                                    
157 
158 
159 void VtableStubs::enter(bool is_vtable_stub, int vtable_index, VtableStub* s) {                                                      
160   MutexLocker ml(VtableStubs_lock);                                                                                                  
161   assert(s->matches(is_vtable_stub, vtable_index), "bad vtable stub");                                                               
162   unsigned int h = VtableStubs::hash(is_vtable_stub, vtable_index);                                                                  
163   // enter s at the beginning of the corresponding list                                                                              
164   s->set_next(_table[h]);                                                                                                            
165   _table[h] = s;                                                                                                                     
166   _number_of_vtable_stubs++;                                                                                                         
167 }                                                                                                                                    
168 
169 VtableStub* VtableStubs::entry_point(address pc) {                                                                                   
170   MutexLocker ml(VtableStubs_lock);                                                                                                  
171   VtableStub* stub = (VtableStub*)(pc - VtableStub::entry_offset());                                                                 
172   uint hash = VtableStubs::hash(stub->is_vtable_stub(), stub->index());                                                              
173   VtableStub* s;                                                                                                                     
174   for (s = _table[hash]; s != NULL && s != stub; s = s->next()) {}                                                                   
175   if (s == stub) {                                                                                                                   
176     return s;                                                                                                                        
177   }                                                                                                                                  
178   return NULL;                                                                                                                       
179 }                                                                                                                                    
180 
181 bool VtableStubs::contains(address pc) {                                                                                             
182   // simple solution for now - we may want to use                                                                                    
183   // a faster way if this function is called often                                                                                   
184   return stub_containing(pc) != NULL;                                                                                                
185 }                                                                                                                                    
186 
187 
188 VtableStub* VtableStubs::stub_containing(address pc) {                                                                               
189   // Note: No locking needed since any change to the data structure                                                                  

131     // Notify JVMTI about this stub. The event will be recorded by the enclosing
132     // JvmtiDynamicCodeEventCollector and posted when this thread has released
133     // all locks.
134     if (JvmtiExport::should_post_dynamic_code_generated()) {
135       JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub",
136                                                                    s->code_begin(), s->code_end());
137     }
138   }
139   return s->entry_point();
140 }
141 
142 
143 inline uint VtableStubs::hash(bool is_vtable_stub, int vtable_index){
144   // Assumption: receiver_location < 4 in most cases.
145   int hash = ((vtable_index << 2) ^ VtableStub::receiver_location()->value()) + vtable_index;
146   return (is_vtable_stub ? ~hash : hash)  & mask;
147 }
148 
149 
150 VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
151   MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
152   unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);
153   VtableStub* s = _table[hash];
154   while( s && !s->matches(is_vtable_stub, vtable_index)) s = s->next();
155   return s;
156 }
157 
158 
159 void VtableStubs::enter(bool is_vtable_stub, int vtable_index, VtableStub* s) {
160   MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
161   assert(s->matches(is_vtable_stub, vtable_index), "bad vtable stub");
162   unsigned int h = VtableStubs::hash(is_vtable_stub, vtable_index);
163   // enter s at the beginning of the corresponding list
164   s->set_next(_table[h]);
165   _table[h] = s;
166   _number_of_vtable_stubs++;
167 }
168 
169 VtableStub* VtableStubs::entry_point(address pc) {
170   MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
171   VtableStub* stub = (VtableStub*)(pc - VtableStub::entry_offset());
172   uint hash = VtableStubs::hash(stub->is_vtable_stub(), stub->index());
173   VtableStub* s;
174   for (s = _table[hash]; s != NULL && s != stub; s = s->next()) {}
175   if (s == stub) {
176     return s;
177   }
178   return NULL;
179 }
180 
181 bool VtableStubs::contains(address pc) {
182   // simple solution for now - we may want to use
183   // a faster way if this function is called often
184   return stub_containing(pc) != NULL;
185 }
186 
187 
188 VtableStub* VtableStubs::stub_containing(address pc) {
189   // Note: No locking needed since any change to the data structure
< prev index next >