< prev index next >

src/share/vm/code/nmethod.cpp

Print this page
rev 10577 : 8153267: nmethod's exception cache not multi-thread safe
Reviewed-by: aph, jcm

@@ -310,11 +310,12 @@
   return false;
 }
 
 
 address ExceptionCache::test_address(address addr) {
-  for (int i=0; i<count(); i++) {
+  int limit = count();
+  for (int i = 0; i < limit; i++) {
     if (pc_at(i) == addr) {
       return handler_at(i);
     }
   }
   return NULL;

@@ -326,11 +327,10 @@
 
   int index = count();
   if (index < cache_size) {
     set_pc_at(index, addr);
     set_handler_at(index, handler);
-    OrderAccess::storestore();
     increment_count();
     return true;
   }
   return false;
 }

@@ -439,14 +439,15 @@
 void nmethod::add_exception_cache_entry(ExceptionCache* new_entry) {
   assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock");
   assert(new_entry != NULL,"Must be non null");
   assert(new_entry->next() == NULL, "Must be null");
 
-  if (exception_cache() != NULL) {
-    new_entry->set_next(exception_cache());
+  ExceptionCache *ec = exception_cache();
+  if (ec != NULL) {
+    new_entry->set_next(ec);
   }
-  set_exception_cache(new_entry);
+  release_set_exception_cache(new_entry);
 }
 
 void nmethod::clean_exception_cache(BoolObjectClosure* is_alive) {
   ExceptionCache* prev = NULL;
   ExceptionCache* curr = exception_cache();
< prev index next >