changeset 54461:ba0d64652b86

8222086: CodeCache::UnloadingScope needs to preserve and restore previous IsUnloadingBehavior Reviewed-by: eosterlund
author zgu
date Mon, 08 Apr 2019 13:22:59 -0400
parents 6733a9176cce
children 2020eaa9ca9f
files src/hotspot/share/code/codeCache.cpp src/hotspot/share/code/codeCache.hpp
diffstat 2 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/code/codeCache.cpp	Mon Apr 08 17:09:02 2019 +0000
+++ b/src/hotspot/share/code/codeCache.cpp	Mon Apr 08 13:22:59 2019 -0400
@@ -780,13 +780,14 @@
 CodeCache::UnloadingScope::UnloadingScope(BoolObjectClosure* is_alive)
   : _is_unloading_behaviour(is_alive)
 {
+  _saved_behaviour = IsUnloadingBehaviour::current();
   IsUnloadingBehaviour::set_current(&_is_unloading_behaviour);
   increment_unloading_cycle();
   DependencyContext::cleaning_start();
 }
 
 CodeCache::UnloadingScope::~UnloadingScope() {
-  IsUnloadingBehaviour::set_current(NULL);
+  IsUnloadingBehaviour::set_current(_saved_behaviour);
   DependencyContext::cleaning_end();
 }
 
--- a/src/hotspot/share/code/codeCache.hpp	Mon Apr 08 17:09:02 2019 +0000
+++ b/src/hotspot/share/code/codeCache.hpp	Mon Apr 08 13:22:59 2019 -0400
@@ -170,6 +170,7 @@
   // "unloading_occurred" controls whether metadata should be cleaned because of class unloading.
   class UnloadingScope: StackObj {
     ClosureIsUnloadingBehaviour _is_unloading_behaviour;
+    IsUnloadingBehaviour*       _saved_behaviour;
 
   public:
     UnloadingScope(BoolObjectClosure* is_alive);