8286490: JvmtiEventControllerPrivate::set_event_callbacks CLEARING_MASK computation is incorrect
Reviewed-by: jbachorik, lmesnik, amenkov
This commit is contained in:
parent
742644e291
commit
a0cccb5479
src/hotspot/share/prims
test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadTest
@ -771,15 +771,15 @@ void JvmtiEventControllerPrivate::set_event_callbacks(JvmtiEnvBase *env,
|
||||
flush_object_free_events(env);
|
||||
|
||||
env->set_event_callbacks(callbacks, size_of_callbacks);
|
||||
// Mask to clear normal event bits.
|
||||
const jlong CLEARING_MASK = (1L >> (TOTAL_MIN_EVENT_TYPE_VAL - TOTAL_MIN_EVENT_TYPE_VAL)) - 1L;
|
||||
// Avoid cleaning extension event bits.
|
||||
jlong enabled_bits = CLEARING_MASK & env->env_event_enable()->_event_callback_enabled.get_bits();
|
||||
|
||||
jlong enabled_bits = env->env_event_enable()->_event_callback_enabled.get_bits();
|
||||
for (int ei = JVMTI_MIN_EVENT_TYPE_VAL; ei <= JVMTI_MAX_EVENT_TYPE_VAL; ++ei) {
|
||||
jvmtiEvent evt_t = (jvmtiEvent)ei;
|
||||
jlong bit_for = JvmtiEventEnabled::bit_for(evt_t);
|
||||
if (env->has_callback(evt_t)) {
|
||||
enabled_bits |= JvmtiEventEnabled::bit_for(evt_t);
|
||||
enabled_bits |= bit_for;
|
||||
} else {
|
||||
enabled_bits &= ~bit_for;
|
||||
}
|
||||
}
|
||||
env->env_event_enable()->_event_callback_enabled.set_bits(enabled_bits);
|
||||
|
@ -36,6 +36,8 @@ public class VThreadTest {
|
||||
static final int MSG_COUNT = 10*1000;
|
||||
static final SynchronousQueue<String> QUEUE = new SynchronousQueue<>();
|
||||
|
||||
static native boolean check();
|
||||
|
||||
static void producer(String msg) throws InterruptedException {
|
||||
int ii = 1;
|
||||
long ll = 2*(long)ii;
|
||||
@ -66,6 +68,9 @@ public class VThreadTest {
|
||||
Thread consumer = Thread.ofVirtual().name("VThread-Consumer").start(CONSUMER);
|
||||
producer.join();
|
||||
consumer.join();
|
||||
if (!check()) {
|
||||
throw new RuntimeException("VThreadTest failed!");
|
||||
}
|
||||
}
|
||||
|
||||
void runTest() throws Exception {
|
||||
|
@ -40,6 +40,9 @@ static jvmtiEnv *jvmti = NULL;
|
||||
static jrawMonitorID events_monitor = NULL;
|
||||
static Tinfo tinfo[MAX_WORKER_THREADS];
|
||||
|
||||
static int vthread_mount_count = 0;
|
||||
static int vthread_unmount_count = 0;
|
||||
static jboolean passed = JNI_TRUE;
|
||||
|
||||
static Tinfo*
|
||||
find_tinfo(JNIEnv* jni, const char* tname) {
|
||||
@ -535,6 +538,7 @@ VirtualThreadMount(jvmtiEnv *jvmti, ...) {
|
||||
va_end(ap);
|
||||
|
||||
RawMonitorLocker rml(jvmti, jni, events_monitor);
|
||||
vthread_mount_count++;
|
||||
processVThreadEvent(jvmti, jni, thread, "VirtualThreadMount");
|
||||
}
|
||||
|
||||
@ -551,6 +555,7 @@ VirtualThreadUnmount(jvmtiEnv *jvmti, ...) {
|
||||
va_end(ap);
|
||||
|
||||
RawMonitorLocker rml(jvmti, jni, events_monitor);
|
||||
vthread_unmount_count++;
|
||||
processVThreadEvent(jvmti, jni, thread, "VirtualThreadUnmount");
|
||||
}
|
||||
|
||||
@ -628,4 +633,25 @@ Agent_OnLoad(JavaVM *jvm, char *options,
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_VThreadTest_check(JNIEnv *jni, jclass cls) {
|
||||
LOG("\n");
|
||||
LOG("check: started\n");
|
||||
|
||||
LOG("check: vthread_mount_count: %d\n", vthread_mount_count);
|
||||
LOG("check: vthread_unmount_count: %d\n", vthread_unmount_count);
|
||||
|
||||
if (vthread_mount_count == 0) {
|
||||
passed = JNI_FALSE;
|
||||
LOG("FAILED: vthread_mount_count == 0\n");
|
||||
}
|
||||
if (vthread_unmount_count == 0) {
|
||||
passed = JNI_FALSE;
|
||||
LOG("FAILED: vthread_unmount_count == 0\n");
|
||||
}
|
||||
LOG("check: finished\n");
|
||||
LOG("\n");
|
||||
return passed;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
Loading…
x
Reference in New Issue
Block a user