diff --git a/runtime/oti/vm_api.h b/runtime/oti/vm_api.h index 054e711ab9d..30e94fe5608 100644 --- a/runtime/oti/vm_api.h +++ b/runtime/oti/vm_api.h @@ -3953,7 +3953,9 @@ J9ROMMethod * * @brief Finds the rom class given a PC. Also returns the classloader it belongs to. * @param vmThread * @param methodPC -* @param resultClassLoader +* @param resultClassLoader This is the classLoader that owns the memory segment that the ROMClass was found in. +* For classes from the SharedClasses cache, this will always be the vm->systemClassLoader regardless of which +* J9ClassLoader actually loaded the class. * @return IDATA * * Returns the rom class, or NULL on failure. resultClassLoader is filled in if non-null with the classloader associated. diff --git a/runtime/vm/classseg.c b/runtime/vm/classseg.c index fe83d919a13..e492f57ea04 100644 --- a/runtime/vm/classseg.c +++ b/runtime/vm/classseg.c @@ -1,6 +1,5 @@ - /******************************************************************************* - * Copyright (c) 1991, 2014 IBM Corp. and others + * Copyright (c) 1991, 2020 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -108,12 +107,11 @@ allocateClassMemorySegment(J9JavaVM *javaVM, UDATA requiredSize, UDATA segmentTy { UDATA appropriateSize = 0; J9MemorySegment *memorySegment = NULL; - -#if defined(J9VM_THR_PREEMPTIVE) - if (javaVM->classMemorySegments->segmentMutex) { - omrthread_monitor_enter(javaVM->classMemorySegments->segmentMutex); + omrthread_monitor_t segmentMutex = javaVM->classMemorySegments->segmentMutex; + + if (NULL != segmentMutex) { + omrthread_monitor_enter(segmentMutex); } -#endif appropriateSize = calculateAppropriateSegmentSize(javaVM, requiredSize, segmentType, classLoader, allocationIncrement); memorySegment = allocateMemorySegmentInList(javaVM, javaVM->classMemorySegments, appropriateSize, segmentType, J9MEM_CATEGORY_CLASSES); @@ -124,11 +122,9 @@ allocateClassMemorySegment(J9JavaVM *javaVM, UDATA requiredSize, UDATA segmentTy classLoader->classSegments = memorySegment; } -#if defined(J9VM_THR_PREEMPTIVE) - if (javaVM->classMemorySegments->segmentMutex) { - omrthread_monitor_exit(javaVM->classMemorySegments->segmentMutex); + if (NULL != segmentMutex) { + omrthread_monitor_exit(segmentMutex); } -#endif return memorySegment; } diff --git a/runtime/vm/findmethod.c b/runtime/vm/findmethod.c index 6f1ebea62e4..2aa786759b8 100644 --- a/runtime/vm/findmethod.c +++ b/runtime/vm/findmethod.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 1991, 2019 IBM Corp. and others + * Copyright (c) 1991, 2020 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -80,6 +80,7 @@ findROMClassFromPC(J9VMThread *vmThread, UDATA methodPC, J9ClassLoader **resultC segmentForClass = findMemorySegment(javaVM, javaVM->classMemorySegments, methodPC); if (segmentForClass != NULL && (segmentForClass->type & MEMORY_TYPE_ROM_CLASS) != 0) { romClass = findROMClassInSegment(vmThread, segmentForClass, methodPC); + /* Note, for classes from the SharedClasses cache, this will *always* be the vm->systemLoader */ *resultClassLoader = segmentForClass->classLoader; }