diff --git a/src/share/vm/prims/jvmtiEnvBase.hpp b/src/share/vm/prims/jvmtiEnvBase.hpp index e8c23b10f05a1fb78cf3c598e6190cff7d6f00a7..55ea70ab39e8056a2f177f34ccab50ee69cb9aeb 100644 --- a/src/share/vm/prims/jvmtiEnvBase.hpp +++ b/src/share/vm/prims/jvmtiEnvBase.hpp @@ -32,6 +32,7 @@ #include "runtime/fieldDescriptor.hpp" #include "runtime/frame.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/orderAccess.hpp" #include "runtime/thread.hpp" #include "runtime/vm_operations.hpp" #include "utilities/growableArray.hpp" @@ -97,7 +98,7 @@ class JvmtiEnvBase : public CHeapObj { const void *_env_local_storage; // per env agent allocated data. jvmtiEventCallbacks _event_callbacks; jvmtiExtEventCallbacks _ext_event_callbacks; - JvmtiTagMap* _tag_map; + JvmtiTagMap* volatile _tag_map; JvmtiEnvEventEnable _env_event_enable; jvmtiCapabilities _current_capabilities; jvmtiCapabilities _prohibited_capabilities; @@ -251,6 +252,13 @@ class JvmtiEnvBase : public CHeapObj { return _tag_map; } + JvmtiTagMap* acquire_tag_map() { + return (JvmtiTagMap*)OrderAccess::load_ptr_acquire(&_tag_map); + } + + void release_set_tag_map(JvmtiTagMap* tag_map) { + OrderAccess::release_store_ptr(&_tag_map, tag_map); + } // return true if event is enabled globally or for any thread // True only if there is a callback for it. diff --git a/src/share/vm/prims/jvmtiTagMap.cpp b/src/share/vm/prims/jvmtiTagMap.cpp index c45181dc79edc827832e7c5ab845b75e5947d2be..6902f95a80cc208b67d70853b74a64547b7c7e2e 100644 --- a/src/share/vm/prims/jvmtiTagMap.cpp +++ b/src/share/vm/prims/jvmtiTagMap.cpp @@ -430,7 +430,7 @@ JvmtiTagMap::JvmtiTagMap(JvmtiEnv* env) : _hashmap = new JvmtiTagHashmap(); // finally add us to the environment - ((JvmtiEnvBase *)env)->set_tag_map(this); + ((JvmtiEnvBase *)env)->release_set_tag_map(this); } @@ -499,7 +499,7 @@ void JvmtiTagMap::destroy_entry(JvmtiTagHashmapEntry* entry) { // returns the tag map for the given environments. If the tag map // doesn't exist then it is created. JvmtiTagMap* JvmtiTagMap::tag_map_for(JvmtiEnv* env) { - JvmtiTagMap* tag_map = ((JvmtiEnvBase*)env)->tag_map(); + JvmtiTagMap* tag_map = ((JvmtiEnvBase*)env)->acquire_tag_map(); if (tag_map == NULL) { MutexLocker mu(JvmtiThreadState_lock); tag_map = ((JvmtiEnvBase*)env)->tag_map(); @@ -3282,7 +3282,7 @@ void JvmtiTagMap::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) { if (JvmtiEnv::environments_might_exist()) { JvmtiEnvIterator it; for (JvmtiEnvBase* env = it.first(); env != NULL; env = it.next(env)) { - JvmtiTagMap* tag_map = env->tag_map(); + JvmtiTagMap* tag_map = env->acquire_tag_map(); if (tag_map != NULL && !tag_map->is_empty()) { tag_map->do_weak_oops(is_alive, f); }