diff --git a/src/hotspot/share/gc/shared/oopStorageSet.hpp b/src/hotspot/share/gc/shared/oopStorageSet.hpp index 867172c41ad..139921ff51a 100644 --- a/src/hotspot/share/gc/shared/oopStorageSet.hpp +++ b/src/hotspot/share/gc/shared/oopStorageSet.hpp @@ -38,7 +38,7 @@ class OopStorageSet : public AllStatic { friend class OopStorageSetTest; // Must be updated when new OopStorages are introduced - static const uint strong_count = 4 JVMTI_ONLY(+ 1); + static const uint strong_count = 4 JVMTI_ONLY(+ 1) CDS_ONLY(+ 1); static const uint weak_count = 8 JVMTI_ONLY(+ 1) JFR_ONLY(+ 1); static const uint all_count = strong_count + weak_count; diff --git a/src/hotspot/share/oops/trainingData.cpp b/src/hotspot/share/oops/trainingData.cpp index 057abb12723..9db930d1942 100644 --- a/src/hotspot/share/oops/trainingData.cpp +++ b/src/hotspot/share/oops/trainingData.cpp @@ -73,9 +73,8 @@ void TrainingData::initialize() { guarantee(have_data() != need_data(), "Iterative training is not supported"); TrainingDataLocker::initialize(); } - if (need_data()) { - training_data_set()->initialize(); - } + // This has to be done because OopStorageSet expects it. + training_data_set()->initialize_oopstorage(); } static void verify_archived_entry(TrainingData* td, const TrainingData::Key* k) { diff --git a/src/hotspot/share/oops/trainingData.hpp b/src/hotspot/share/oops/trainingData.hpp index ff484cce7ec..174bf06db49 100644 --- a/src/hotspot/share/oops/trainingData.hpp +++ b/src/hotspot/share/oops/trainingData.hpp @@ -197,9 +197,9 @@ class TrainingData : public Metadata { TrainingDataSet(Arg... arg) : _table(arg...), _mirror_refs(nullptr) { } - void initialize() { + void initialize_oopstorage() { assert(_mirror_refs == nullptr, "Already initialized"); - _mirror_refs = OopStorageSet::create_strong("Training data mirror references", mtInternal); + _mirror_refs = OopStorageSet::create_strong("Training OopStorage", mtInternal); } TrainingData* find(const Key* key) const { TrainingDataLocker::assert_locked(); diff --git a/src/hotspot/share/runtime/init.cpp b/src/hotspot/share/runtime/init.cpp index 22a2e302600..0fb36afffe4 100644 --- a/src/hotspot/share/runtime/init.cpp +++ b/src/hotspot/share/runtime/init.cpp @@ -189,10 +189,7 @@ jint init_globals2() { } #endif - // Initialize TrainingData only we're recording/replaying - if (TrainingData::have_data() || TrainingData::need_data()) { - TrainingData::initialize(); - } + TrainingData::initialize(); if (!universe_post_init()) { return JNI_ERR; diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java b/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java index 568104a7b50..daee4c335e8 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestG1ParallelPhases.java @@ -96,6 +96,7 @@ public static void main(String[] args) throws IOException { "Thread OopStorage", "ThreadService OopStorage", "JVMTI OopStorage", + "Training OopStorage", "CLDGRoots", "CMRefRoots", "MergeER",