295 assert(pc != NULL,"Must be non null");
296 assert(exception.not_null(),"Must be non null");
297 if (exception->klass() == exception_type()) {
298 return (test_address(pc));
299 }
300
301 return NULL;
302 }
303
304
305 bool ExceptionCache::match_exception_with_space(Handle exception) {
306 assert(exception.not_null(),"Must be non null");
307 if (exception->klass() == exception_type() && count() < cache_size) {
308 return true;
309 }
310 return false;
311 }
312
313
314 address ExceptionCache::test_address(address addr) {
315 for (int i=0; i<count(); i++) {
316 if (pc_at(i) == addr) {
317 return handler_at(i);
318 }
319 }
320 return NULL;
321 }
322
323
324 bool ExceptionCache::add_address_and_handler(address addr, address handler) {
325 if (test_address(addr) == handler) return true;
326
327 int index = count();
328 if (index < cache_size) {
329 set_pc_at(index, addr);
330 set_handler_at(index, handler);
331 OrderAccess::storestore();
332 increment_count();
333 return true;
334 }
335 return false;
424 // adjust pcs_size so that it is a multiple of both oopSize and
425 // sizeof(PcDesc) (assumes that if sizeof(PcDesc) is not a multiple
426 // of oopSize, then 2*sizeof(PcDesc) is)
427 static int adjust_pcs_size(int pcs_size) {
428 int nsize = round_to(pcs_size, oopSize);
429 if ((nsize % sizeof(PcDesc)) != 0) {
430 nsize = pcs_size + sizeof(PcDesc);
431 }
432 assert((nsize % oopSize) == 0, "correct alignment");
433 return nsize;
434 }
435
436 //-----------------------------------------------------------------------------
437
438
439 void nmethod::add_exception_cache_entry(ExceptionCache* new_entry) {
440 assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock");
441 assert(new_entry != NULL,"Must be non null");
442 assert(new_entry->next() == NULL, "Must be null");
443
444 if (exception_cache() != NULL) {
445 new_entry->set_next(exception_cache());
446 }
447 set_exception_cache(new_entry);
448 }
449
450 void nmethod::clean_exception_cache(BoolObjectClosure* is_alive) {
451 ExceptionCache* prev = NULL;
452 ExceptionCache* curr = exception_cache();
453
454 while (curr != NULL) {
455 ExceptionCache* next = curr->next();
456
457 Klass* ex_klass = curr->exception_type();
458 if (ex_klass != NULL && !ex_klass->is_loader_alive(is_alive)) {
459 if (prev == NULL) {
460 set_exception_cache(next);
461 } else {
462 prev->set_next(next);
463 }
464 delete curr;
465 // prev stays the same.
466 } else {
467 prev = curr;
|
295 assert(pc != NULL,"Must be non null");
296 assert(exception.not_null(),"Must be non null");
297 if (exception->klass() == exception_type()) {
298 return (test_address(pc));
299 }
300
301 return NULL;
302 }
303
304
305 bool ExceptionCache::match_exception_with_space(Handle exception) {
306 assert(exception.not_null(),"Must be non null");
307 if (exception->klass() == exception_type() && count() < cache_size) {
308 return true;
309 }
310 return false;
311 }
312
313
314 address ExceptionCache::test_address(address addr) {
315 int limit = count();
316 for (int i = 0; i < limit; i++) {
317 if (pc_at(i) == addr) {
318 return handler_at(i);
319 }
320 }
321 return NULL;
322 }
323
324
325 bool ExceptionCache::add_address_and_handler(address addr, address handler) {
326 if (test_address(addr) == handler) return true;
327
328 int index = count();
329 if (index < cache_size) {
330 set_pc_at(index, addr);
331 set_handler_at(index, handler);
332 OrderAccess::storestore();
333 increment_count();
334 return true;
335 }
336 return false;
425 // adjust pcs_size so that it is a multiple of both oopSize and
426 // sizeof(PcDesc) (assumes that if sizeof(PcDesc) is not a multiple
427 // of oopSize, then 2*sizeof(PcDesc) is)
428 static int adjust_pcs_size(int pcs_size) {
429 int nsize = round_to(pcs_size, oopSize);
430 if ((nsize % sizeof(PcDesc)) != 0) {
431 nsize = pcs_size + sizeof(PcDesc);
432 }
433 assert((nsize % oopSize) == 0, "correct alignment");
434 return nsize;
435 }
436
437 //-----------------------------------------------------------------------------
438
439
440 void nmethod::add_exception_cache_entry(ExceptionCache* new_entry) {
441 assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock");
442 assert(new_entry != NULL,"Must be non null");
443 assert(new_entry->next() == NULL, "Must be null");
444
445 ExceptionCache *ec = exception_cache();
446 if (ec != NULL) {
447 new_entry->set_next(ec);
448 }
449 release_set_exception_cache(new_entry);
450 }
451
452 void nmethod::clean_exception_cache(BoolObjectClosure* is_alive) {
453 ExceptionCache* prev = NULL;
454 ExceptionCache* curr = exception_cache();
455
456 while (curr != NULL) {
457 ExceptionCache* next = curr->next();
458
459 Klass* ex_klass = curr->exception_type();
460 if (ex_klass != NULL && !ex_klass->is_loader_alive(is_alive)) {
461 if (prev == NULL) {
462 set_exception_cache(next);
463 } else {
464 prev->set_next(next);
465 }
466 delete curr;
467 // prev stays the same.
468 } else {
469 prev = curr;
|