Skip to content

Commit

Permalink
Merge pull request #9039 from DanHeidinga/djh/clarify
Browse files Browse the repository at this point in the history
Clarify contract of findROMClassFromPC() method
  • Loading branch information
gacholio committed Mar 31, 2020
2 parents b1acf75 + e881141 commit 03878bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 3 additions & 1 deletion runtime/oti/vm_api.h
Expand Up @@ -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.
Expand Down
18 changes: 7 additions & 11 deletions 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
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
3 changes: 2 additions & 1 deletion 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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 03878bd

Please sign in to comment.