Skip to content
Merged
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
26 changes: 15 additions & 11 deletions ddprof-lib/src/main/cpp/vmEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,22 @@ void *VM::getLibraryHandle(const char *name) {
}

void VM::loadMethodIDs(jvmtiEnv *jvmti, JNIEnv *jni, jclass klass) {
if (VMStructs::hasClassLoaderData()) {
VMKlass *vmklass = VMKlass::fromJavaClass(jni, klass);
int method_count = vmklass->methodCount();
if (method_count > 0) {
ClassLoaderData *cld = vmklass->classLoaderData();
cld->lock();
// Workaround for JVM bug: preallocate space for jmethodIDs
// at the beginning of the list (rather than at the end)
for (int i = 0; i < method_count; i += MethodList::SIZE) {
*cld->methodList() = new MethodList(*cld->methodList());
bool needs_patch = VM::hotspot_version() == 8;
if (needs_patch) {
// Workaround for JVM bug https://bugs.openjdk.org/browse/JDK-8062116
// Preallocate space for jmethodIDs at the beginning of the list (rather than at the end)
// This is relevant only for JDK 8 - later versions do not have this bug
if (VMStructs::hasClassLoaderData()) {
VMKlass *vmklass = VMKlass::fromJavaClass(jni, klass);
int method_count = vmklass->methodCount();
if (method_count > 0) {
ClassLoaderData *cld = vmklass->classLoaderData();
cld->lock();
for (int i = 0; i < method_count; i += MethodList::SIZE) {
*cld->methodList() = new MethodList(*cld->methodList());
}
cld->unlock();
}
cld->unlock();
}
}

Expand Down