Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/hotspot/share/cds/archiveBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,18 @@ ArchiveBuilder::FollowMode ArchiveBuilder::get_follow_mode(MetaspaceClosure::Ref
ref->msotype() == MetaspaceObj::KlassTrainingDataType ||
ref->msotype() == MetaspaceObj::MethodTrainingDataType ||
ref->msotype() == MetaspaceObj::CompileTrainingDataType) {
return (TrainingData::need_data() || TrainingData::assembling_data()) ? make_a_copy : set_to_null;
if (TrainingData::need_data() || TrainingData::assembling_data()) {
// Only add MethodCounters that are reachable via MethodTrainingData,
// i.e. MethodCounters associated with a valid MethodTrainingData.
if (ref->msotype() == MetaspaceObj::MethodCountersType) {
MethodCounters* mcs = (MethodCounters*)obj;
return mcs->has_valid_method_training_data() ? make_a_copy : set_to_null;
} else {
return make_a_copy;
}
} else {
return set_to_null;
}
} else if (ref->msotype() == MetaspaceObj::AdapterHandlerEntryType) {
return CDSConfig::is_dumping_adapters() ? make_a_copy : set_to_null;
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/oops/methodCounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ void MethodCounters::restore_unshareable_info(TRAPS) {
}
#endif // INCLUDE_CDS

bool MethodCounters::has_valid_method_training_data() {
Metadata* mtd = method_training_data();
Metadata* mts = method_training_data_sentinel();
return mtd != mts;
}

void MethodCounters::print_on(outputStream* st) const {
assert(is_methodCounters(), "should be method counters");
st->print("method counters");
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/oops/methodCounters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ class MethodCounters : public Metadata {
return false;
}

bool has_valid_method_training_data();

#if INCLUDE_CDS
void remove_unshareable_info();
void restore_unshareable_info(TRAPS);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/trainingData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void TrainingData::verify() {

MethodTrainingData* MethodTrainingData::make(const methodHandle& method, bool null_if_not_found, bool use_cache) {
MethodTrainingData* mtd = nullptr;
if (!have_data() && !need_data()) {
if ((!have_data() && !need_data()) || (assembling_data() && !CDSConfig::is_at_aot_safepoint())) {
return mtd;
}
// Try grabbing the cached value first.
Expand Down