8253495: CDS generates non-deterministic output

Reviewed-by: erikj, kbarrett, ccheung, ihse
This commit is contained in:
Ioi Lam 2022-03-16 03:12:48 +00:00
parent 4df24c5df3
commit de4f04cb71
15 changed files with 91 additions and 31 deletions

View file

@ -2865,6 +2865,26 @@ static void thread_entry(JavaThread* thread, TRAPS) {
JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread))
#if INCLUDE_CDS
if (DumpSharedSpaces) {
// During java -Xshare:dump, if we allow multiple Java threads to
// execute in parallel, symbols and classes may be loaded in
// random orders which will make the resulting CDS archive
// non-deterministic.
//
// Lucikly, during java -Xshare:dump, it's important to run only
// the code in the main Java thread (which is NOT started here) that
// creates the module graph, etc. It's safe to not start the other
// threads which are launched by class static initializers
// (ReferenceHandler, FinalizerThread and CleanerImpl).
if (log_is_enabled(Info, cds)) {
ResourceMark rm;
oop t = JNIHandles::resolve_non_null(jthread);
log_info(cds)("JVM_StartThread() ignored: %s", t->klass()->external_name());
}
return;
}
#endif
JavaThread *native_thread = NULL;
// We cannot hold the Threads_lock when we throw an exception,