Skip to content
Closed
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
6 changes: 1 addition & 5 deletions src/hotspot/share/ci/ciMethodData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ ciMethodData::ciMethodData(MethodData* md)


static bool is_klass_loaded(Klass* k) {
if (TrainingData::have_data()) {
// If we're running in AOT mode some classes may not be loaded yet
return !k->is_instance_klass() || InstanceKlass::cast(k)->is_loaded();
}
return true;
return TrainingData::is_klass_loaded(k);
}

// Check for entries that reference an unloaded method
Expand Down
9 changes: 7 additions & 2 deletions src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "oops/instanceMirrorKlass.hpp"
#include "oops/method.inline.hpp"
#include "oops/objArrayKlass.inline.hpp"
#include "oops/trainingData.hpp"
#include "oops/typeArrayOop.inline.hpp"
#include "prims/jvmtiExport.hpp"
#include "prims/methodHandles.hpp"
Expand Down Expand Up @@ -505,11 +506,15 @@ C2V_VMENTRY_NULL(jobject, getResolvedJavaType0, (JNIEnv* env, jobject, jobject b
}
} else if (JVMCIENV->isa_HotSpotMethodData(base_object)) {
jlong base_address = (intptr_t) JVMCIENV->asMethodData(base_object);
klass = *((Klass**) (intptr_t) (base_address + offset));
if (klass == nullptr || !klass->is_loader_alive()) {
Klass* k = *((Klass**) (intptr_t) (base_address + offset));
if (k == nullptr || k->class_loader_data() == nullptr || !TrainingData::is_klass_loaded(k)) {
return nullptr;
}
if (!k->is_loader_alive()) {
// Klasses in methodData might be concurrently unloading so return null in that case.
return nullptr;
}
klass = k;
} else {
goto unexpected;
}
Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/share/oops/trainingData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ class TrainingData : public Metadata {
static bool need_data() { return AOTRecordTraining; } // Going to write
static bool assembling_data() { return have_data() && CDSConfig::is_dumping_final_static_archive() && CDSConfig::is_dumping_aot_linked_classes(); }

static bool is_klass_loaded(Klass* k) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was moved unmodified from ciMethodData.cpp.

if (have_data()) {
// If we're running in AOT mode some classes may not be loaded yet
return !k->is_instance_klass() || InstanceKlass::cast(k)->is_loaded();
}
return true;
}

template<typename Function>
static void iterate(const Function& fn) { iterate(const_cast<Function&>(fn)); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,19 +443,7 @@ public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos)
}
}

static class RawItemProfile<T> {
final int entries;
final T[] items;
final long[] counts;
final long totalCount;

RawItemProfile(int entries, T[] items, long[] counts, long totalCount) {
this.entries = entries;
this.items = items;
this.counts = counts;
this.totalCount = totalCount;
}
}
record RawItemProfile<T>(int entries, T[] items, long[] counts, long totalCount) {}

abstract static class AbstractTypeData extends CounterData {

Expand Down