< prev index next >

src/hotspot/share/code/nmethod.cpp


226     jvmci_java_nmethod_stats.note_nmethod(nm);                                                                                       
227   } else                                                                                                                             
228 #endif                                                                                                                               
229   {                                                                                                                                  
230     unknown_java_nmethod_stats.note_nmethod(nm);                                                                                     
231   }                                                                                                                                  
232 }                                                                                                                                    
233 #endif // !PRODUCT                                                                                                                   
234 
235 //---------------------------------------------------------------------------------                                                  
236 
237 
238 ExceptionCache::ExceptionCache(Handle exception, address pc, address handler) {                                                      
239   assert(pc != NULL, "Must be non null");                                                                                            
240   assert(exception.not_null(), "Must be non null");                                                                                  
241   assert(handler != NULL, "Must be non null");                                                                                       
242 
243   _count = 0;                                                                                                                        
244   _exception_type = exception->klass();                                                                                              
245   _next = NULL;                                                                                                                      
                                                                                                                                     
246 
247   add_address_and_handler(pc,handler);                                                                                               
248 }                                                                                                                                    
249 
250 
251 address ExceptionCache::match(Handle exception, address pc) {                                                                        
252   assert(pc != NULL,"Must be non null");                                                                                             
253   assert(exception.not_null(),"Must be non null");                                                                                   
254   if (exception->klass() == exception_type()) {                                                                                      
255     return (test_address(pc));                                                                                                       
256   }                                                                                                                                  
257 
258   return NULL;                                                                                                                       
259 }                                                                                                                                    
260 
261 
262 bool ExceptionCache::match_exception_with_space(Handle exception) {                                                                  
263   assert(exception.not_null(),"Must be non null");                                                                                   
264   if (exception->klass() == exception_type() && count() < cache_size) {                                                              

226     jvmci_java_nmethod_stats.note_nmethod(nm);
227   } else
228 #endif
229   {
230     unknown_java_nmethod_stats.note_nmethod(nm);
231   }
232 }
233 #endif // !PRODUCT
234 
235 //---------------------------------------------------------------------------------
236 
237 
238 ExceptionCache::ExceptionCache(Handle exception, address pc, address handler) {
239   assert(pc != NULL, "Must be non null");
240   assert(exception.not_null(), "Must be non null");
241   assert(handler != NULL, "Must be non null");
242 
243   _count = 0;
244   _exception_type = exception->klass();
245   _next = NULL;
246   _purge_list_next = NULL;
247 
248   add_address_and_handler(pc,handler);
249 }
250 
251 
252 address ExceptionCache::match(Handle exception, address pc) {
253   assert(pc != NULL,"Must be non null");
254   assert(exception.not_null(),"Must be non null");
255   if (exception->klass() == exception_type()) {
256     return (test_address(pc));
257   }
258 
259   return NULL;
260 }
261 
262 
263 bool ExceptionCache::match_exception_with_space(Handle exception) {
264   assert(exception.not_null(),"Must be non null");
265   if (exception->klass() == exception_type() && count() < cache_size) {

273   for (int i = 0; i < limit; i++) {                                                                                                  
274     if (pc_at(i) == addr) {                                                                                                          
275       return handler_at(i);                                                                                                          
276     }                                                                                                                                
277   }                                                                                                                                  
278   return NULL;                                                                                                                       
279 }                                                                                                                                    
280 
281 
282 bool ExceptionCache::add_address_and_handler(address addr, address handler) {                                                        
283   if (test_address(addr) == handler) return true;                                                                                    
284 
285   int index = count();                                                                                                               
286   if (index < cache_size) {                                                                                                          
287     set_pc_at(index, addr);                                                                                                          
288     set_handler_at(index, handler);                                                                                                  
289     increment_count();                                                                                                               
290     return true;                                                                                                                     
291   }                                                                                                                                  
292   return false;                                                                                                                      
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
293 }                                                                                                                                    
294 
295 //-----------------------------------------------------------------------------                                                      
296 
297 
298 // Helper used by both find_pc_desc methods.                                                                                         
299 static inline bool match_desc(PcDesc* pc, int pc_offset, bool approximate) {                                                         
300   NOT_PRODUCT(++pc_nmethod_stats.pc_desc_tests);                                                                                     
301   if (!approximate)                                                                                                                  
302     return pc->pc_offset() == pc_offset;                                                                                             
303   else                                                                                                                               
304     return (pc-1)->pc_offset() < pc_offset && pc_offset <= pc->pc_offset();                                                          
305 }                                                                                                                                    
306 
307 void PcDescCache::reset_to(PcDesc* initial_pc_desc) {                                                                                
308   if (initial_pc_desc == NULL) {                                                                                                     
309     _pc_descs[0] = NULL; // native method; no PcDescs at all                                                                         
310     return;                                                                                                                          
311   }                                                                                                                                  

274   for (int i = 0; i < limit; i++) {
275     if (pc_at(i) == addr) {
276       return handler_at(i);
277     }
278   }
279   return NULL;
280 }
281 
282 
283 bool ExceptionCache::add_address_and_handler(address addr, address handler) {
284   if (test_address(addr) == handler) return true;
285 
286   int index = count();
287   if (index < cache_size) {
288     set_pc_at(index, addr);
289     set_handler_at(index, handler);
290     increment_count();
291     return true;
292   }
293   return false;
294 }
295 
296 ExceptionCache* ExceptionCache::next() {
297   return Atomic::load(&_next);
298 }
299 
300 void ExceptionCache::set_next(ExceptionCache *ec) {
301   Atomic::store(ec, &_next);
302 }
303 
304 //-----------------------------------------------------------------------------
305 
306 
307 // Helper used by both find_pc_desc methods.
308 static inline bool match_desc(PcDesc* pc, int pc_offset, bool approximate) {
309   NOT_PRODUCT(++pc_nmethod_stats.pc_desc_tests);
310   if (!approximate)
311     return pc->pc_offset() == pc_offset;
312   else
313     return (pc-1)->pc_offset() < pc_offset && pc_offset <= pc->pc_offset();
314 }
315 
316 void PcDescCache::reset_to(PcDesc* initial_pc_desc) {
317   if (initial_pc_desc == NULL) {
318     _pc_descs[0] = NULL; // native method; no PcDescs at all
319     return;
320   }
< prev index next >