Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8256830: misc tests failed with "assert(env->is_enabled(JVMTI_EVENT_O…
…BJECT_FREE)) failed: checking"

Reviewed-by: kbarrett, sspitsyn, dholmes
  • Loading branch information
coleenp committed Dec 1, 2020
1 parent c859fb0 commit 3a11009
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/hotspot/share/prims/jvmtiEventController.cpp
Expand Up @@ -307,6 +307,7 @@ class JvmtiEventControllerPrivate : public AllStatic {
static void trace_changed(jlong now_enabled, jlong changed);

static void flush_object_free_events(JvmtiEnvBase *env);
static void set_enabled_events_with_lock(JvmtiEnvBase *env, jlong now_enabled);
};

bool JvmtiEventControllerPrivate::_initialized = false;
Expand Down Expand Up @@ -409,6 +410,19 @@ JvmtiEventControllerPrivate::flush_object_free_events(JvmtiEnvBase* env) {
}
}

void
JvmtiEventControllerPrivate::set_enabled_events_with_lock(JvmtiEnvBase* env, jlong now_enabled) {
// The state for ObjectFree events must be enabled or disabled
// under the TagMap lock, to allow pending object posting events to complete.
JvmtiTagMap* tag_map = env->tag_map_acquire();
if (tag_map != NULL) {
MutexLocker ml(tag_map->lock(), Mutex::_no_safepoint_check_flag);
env->env_event_enable()->_event_enabled.set_bits(now_enabled);
} else {
env->env_event_enable()->_event_enabled.set_bits(now_enabled);
}
}

// For the specified env: compute the currently truly enabled events
// set external state accordingly.
// Return value and set value must include all events.
Expand Down Expand Up @@ -442,8 +456,8 @@ JvmtiEventControllerPrivate::recompute_env_enabled(JvmtiEnvBase* env) {
break;
}

// will we really send these events to this env
env->env_event_enable()->_event_enabled.set_bits(now_enabled);
// Set/reset the event enabled under the tagmap lock.
set_enabled_events_with_lock(env, now_enabled);

trace_changed(now_enabled, (now_enabled ^ was_enabled) & ~THREAD_FILTERED_EVENT_BITS);

Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/prims/jvmtiTagMap.cpp
Expand Up @@ -1158,6 +1158,8 @@ void JvmtiTagMap::iterate_through_heap(jint heap_filter,
void JvmtiTagMap::remove_dead_entries_locked(bool post_object_free) {
assert(is_locked(), "precondition");
if (_needs_cleaning) {
// Recheck whether to post object free events under the lock.
post_object_free = post_object_free && env()->is_enabled(JVMTI_EVENT_OBJECT_FREE);
log_info(jvmti, table)("TagMap table needs cleaning%s",
(post_object_free ? " and posting" : ""));
hashmap()->remove_dead_entries(env(), post_object_free);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/prims/jvmtiTagMap.hpp
Expand Up @@ -49,7 +49,6 @@ class JvmtiTagMap : public CHeapObj<mtInternal> {
JvmtiTagMap(JvmtiEnv* env);

// accessors
inline Mutex* lock() { return &_lock; }
inline JvmtiEnv* env() const { return _env; }

void check_hashmap(bool post_events);
Expand All @@ -60,6 +59,7 @@ class JvmtiTagMap : public CHeapObj<mtInternal> {
public:
// indicates if this tag map is locked
bool is_locked() { return lock()->is_locked(); }
inline Mutex* lock() { return &_lock; }

JvmtiTagMapTable* hashmap() { return _hashmap; }

Expand Down

1 comment on commit 3a11009

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.