diff --git a/src/hotspot/share/prims/jvmtiExport.cpp b/src/hotspot/share/prims/jvmtiExport.cpp index 32ca314d577..5cff81db816 100644 --- a/src/hotspot/share/prims/jvmtiExport.cpp +++ b/src/hotspot/share/prims/jvmtiExport.cpp @@ -2592,8 +2592,6 @@ void JvmtiExport::post_dynamic_code_generated_while_holding_locks(const char* na address code_begin, address code_end) { JavaThread* thread = JavaThread::current(); - assert(!thread->is_in_any_VTMS_transition(), "dynamic code generated events are not allowed in any VTMS transition"); - // register the stub with the current dynamic code event collector // Cannot take safepoint here so do not use state_for to get // jvmti thread state. diff --git a/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGeneratedTest.java b/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGeneratedTest.java index bfb9da8e552..1880ab0bbbe 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGeneratedTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/DynamicCodeGeneratedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.lang.ref.Reference; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.locks.LockSupport; public class DynamicCodeGeneratedTest { static { @@ -49,14 +50,21 @@ public class DynamicCodeGeneratedTest { threadChangeENM.setDaemon(true); threadChangeENM.start(); + Runnable task = () -> { + String result = "string" + System.currentTimeMillis(); + // Park to provoke re-mounting of virtual thread. + LockSupport.parkNanos(1); + Reference.reachabilityFence(result); + }; + for (int i = 0; i < 10; i++) { List threads = new ArrayList(); for (int j = 0; j < 200; j++) { - Thread t = new Thread(() -> { - String result = "string" + System.currentTimeMillis(); - Reference.reachabilityFence(result); - }); - threads.add(t); + threads.add(Thread.ofVirtual().unstarted(task)); + threads.add(Thread.ofPlatform().unstarted(task)); + } + + for (Thread t: threads) { t.start(); } for (Thread t: threads) { diff --git a/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp b/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp index 5e809cbf9de..6ede1fe2eb9 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ #include #include +#include "jvmti_common.h" static jvmtiEnv* jvmti = NULL; @@ -43,7 +44,7 @@ void JNICALL Java_DynamicCodeGeneratedTest_changeEventNotificationMode(JNIEnv* j #endif void JNICALL DynamicCodeGenerated(jvmtiEnv* jvmti, const char* name, const void* address, jint length) { - + LOG("Event: %s\n", name); } JNIEXPORT jint JNICALL