diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.cpp b/src/hotspot/share/classfile/classLoaderDataGraph.cpp index db4d441..4e25325 100644 --- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp +++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp @@ -588,7 +588,6 @@ void ClassLoaderDataGraph::purge() { _unloading = NULL; ClassLoaderData* next = list; bool classes_unloaded = false; - DependencyContext::purge_dependency_contexts(); while (next != NULL) { ClassLoaderData* purge_me = next; next = purge_me->next(); @@ -599,6 +598,7 @@ void ClassLoaderDataGraph::purge() { Metaspace::purge(); set_metaspace_oom(false); } + DependencyContext::purge_dependency_contexts(); } int ClassLoaderDataGraph::resize_if_needed() { diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index f202522..7d943d2 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -946,12 +946,12 @@ CodeCache::UnloadingScope::UnloadingScope(BoolObjectClosure* is_alive) { IsUnloadingBehaviour::set_current(&_is_unloading_behaviour); increment_unloading_cycle(); - DependencyContext::gc_prologue(); + DependencyContext::cleaning_start(); } CodeCache::UnloadingScope::~UnloadingScope() { IsUnloadingBehaviour::set_current(NULL); - DependencyContext::gc_epilogue(); + DependencyContext::cleaning_end(); } void CodeCache::verify_oops() { diff --git a/src/hotspot/share/code/dependencyContext.cpp b/src/hotspot/share/code/dependencyContext.cpp index 2161e3b..ba2c45e 100644 --- a/src/hotspot/share/code/dependencyContext.cpp +++ b/src/hotspot/share/code/dependencyContext.cpp @@ -112,6 +112,7 @@ void DependencyContext::add_dependent_nmethod(nmethod* nm) { void DependencyContext::release(nmethodBucket* b) { bool expunge = Atomic::load(&_cleaning_epoch) == 0; if (expunge) { + assert_locked_or_safepoint(CodeCache_lock); delete b; if (UsePerfData) { _perf_total_buckets_deallocated_count->inc(); @@ -204,7 +205,6 @@ void DependencyContext::clean_unloading_dependents() { // // Invalidate all dependencies in the context int DependencyContext::remove_all_dependents() { - assert_locked_or_safepoint(CodeCache_lock); nmethodBucket* b = dependencies_not_unloading(); set_dependencies(NULL); int marked = 0; @@ -309,16 +309,16 @@ nmethodBucket* DependencyContext::dependencies() { // After the gc_prologue, the dependency contexts may be claimed by the GC // and releasing of nmethodBucket entries will be deferred and placed on // a purge list to be deleted later. -void DependencyContext::gc_prologue() { +void DependencyContext::cleaning_start() { assert(SafepointSynchronize::is_at_safepoint(), "must be"); - uint64_t epoch = SafepointSynchronize::_safepoint_counter; + uint64_t epoch = SafepointSynchronize::safepoint_counter(); Atomic::store(epoch, &_cleaning_epoch); } // The epilogue marks the end of dependency context cleanup by the GC, // and also makes subsequent releases of nmethodBuckets case immediate // deletion. It is admitted to end the cleanup in a concurrent phase. -void DependencyContext::gc_epilogue() { +void DependencyContext::cleaning_end() { uint64_t epoch = 0; Atomic::store(epoch, &_cleaning_epoch); } diff --git a/src/hotspot/share/code/dependencyContext.hpp b/src/hotspot/share/code/dependencyContext.hpp index d66bc48..f9c421a 100644 --- a/src/hotspot/share/code/dependencyContext.hpp +++ b/src/hotspot/share/code/dependencyContext.hpp @@ -123,8 +123,8 @@ class DependencyContext : public StackObj { void clean_unloading_dependents(); static void purge_dependency_contexts(); static void release(nmethodBucket* b); - static void gc_prologue(); - static void gc_epilogue(); + static void cleaning_start(); + static void cleaning_end(); #ifndef PRODUCT void print_dependent_nmethods(bool verbose); diff --git a/test/hotspot/gtest/code/test_dependencyContext.cpp b/test/hotspot/gtest/code/test_dependencyContext.cpp index d1d9db4..52f9b57 100644 --- a/test/hotspot/gtest/code/test_dependencyContext.cpp +++ b/test/hotspot/gtest/code/test_dependencyContext.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "code/dependencyContext.hpp" +#include "code/nmethod.hpp" #include "unittest.hpp" class TestDependencyContext {