diff src/share/vm/code/nmethod.cpp @ 23463:5cece4584b8e

8058563: InstanceKlass::_dependencies list isn't cleared from empty nmethodBucket entries Reviewed-by: mgerdin, vlivanov
author stefank
date Thu, 12 Nov 2015 09:53:17 +0100
parents be740540f60c
children b5f3a471e646
line wrap: on
line diff
--- a/src/share/vm/code/nmethod.cpp	Wed Dec 02 17:48:20 2015 -0800
+++ b/src/share/vm/code/nmethod.cpp	Thu Nov 12 09:53:17 2015 +0100
@@ -1619,7 +1619,11 @@
       // During GC the is_alive closure is non-NULL, and is used to
       // determine liveness of dependees that need to be updated.
       if (is_alive == NULL || klass->is_loader_alive(is_alive)) {
-        InstanceKlass::cast(klass)->remove_dependent_nmethod(this);
+        // The GC defers deletion of this entry, since there might be multiple threads
+        // iterating over the _dependencies graph. Other call paths are single-threaded
+        // and may delete it immediately.
+        bool delete_immediately = is_alive == NULL;
+        InstanceKlass::cast(klass)->remove_dependent_nmethod(this, delete_immediately);
       }
     }
   }