--- old/src/share/vm/prims/jvm.cpp 2021-02-04 10:28:01.683228647 +0800 +++ new/src/share/vm/prims/jvm.cpp 2021-02-04 10:28:01.565224048 +0800 @@ -96,6 +96,7 @@ #endif // INCLUDE_ALL_GCS #include +#include #ifndef USDT2 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__begin, long long); @@ -3162,6 +3163,15 @@ "unable to create new native thread"); } +#if INCLUDE_JFR + if (JfrRecorder::is_recording() && EventThreadStart::is_enabled() && + EventThreadStart::is_stacktrace_enabled()) { + JfrThreadLocal* tl = native_thread->jfr_thread_local(); + // skip Thread.start() and Thread.start0() + tl->set_cached_stack_trace_id(JfrStackTraceRepository::record(thread, 2)); + } +#endif + Thread::start(native_thread); JVM_END