Skip to content

Commit bdc9592

Browse files
committed
Fix stackwalker calculation of object displacement for Offheap
In walkJITFrameSlotsForInternalPointers(), a displacement of data is calculated between an array object before and after it is moved. Currently, when offheap is enabled, this displacement is calculated as the difference between the dataAddr pointers of the new and old locations. However, because the src object may be overwritten during sliding object movement, it is not safe to read its contents, such as the dataAddr pointer. Thus, this contribution modifies how the stackwalker calculates displacement when offheap allocation is enabled such that: - if the array data is adjacent to the array header (i.e.: dataAddr == pinningArrayAddr + sizeofHeader), calculate the displacement as dst - src - otherwise, set displacement to 0 Signed-off-by: midronij <[email protected]>
1 parent 3d719d4 commit bdc9592

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

runtime/compiler/runtime/MethodMetaData.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,24 +1403,19 @@ void walkJITFrameSlotsForInternalPointers(J9StackWalkState * walkState, U_8 **
14031403
J9Object ** currPinningArrayCursor = (J9Object **) (((U_8 *) walkState->bp) + (offsetOfFirstInternalPtr + (((U_16) currPinningArrayIndex * sizeof(UDATA)))));
14041404
J9Object *oldPinningArrayAddress = *((J9Object **) currPinningArrayCursor);
14051405
J9Object * newPinningArrayAddress;
1406-
void *oldDataAddr = 0, *newDataAddr = 0;
1407-
if (offHeapAllocationEnabled && oldPinningArrayAddress)
1408-
oldDataAddr = walkState->walkThread->javaVM->memoryManagerFunctions->j9gc_objaccess_getArrayObjectDataAddress(walkState->walkThread, (J9IndexableObject*)oldPinningArrayAddress);
1409-
IDATA displacement = 0;
14101406

14111407

14121408
#ifdef J9VM_INTERP_STACKWALK_TRACING
14131409
swPrintf(walkState, 6, "Before object slot walk &address : %p address : %p bp %p offset of first internal ptr %d\n", currPinningArrayCursor, oldPinningArrayAddress, walkState->bp, offsetOfFirstInternalPtr);
14141410
#endif
14151411
walkState->objectSlotWalkFunction(walkState->walkThread, walkState, currPinningArrayCursor, currPinningArrayCursor);
14161412
newPinningArrayAddress = *((J9Object **) currPinningArrayCursor);
1417-
if (offHeapAllocationEnabled && newPinningArrayAddress)
1418-
{
1419-
newDataAddr = walkState->walkThread->javaVM->memoryManagerFunctions->j9gc_objaccess_getArrayObjectDataAddress(walkState->walkThread, (J9IndexableObject*)newPinningArrayAddress);
1420-
displacement = (IDATA) (((UDATA)newDataAddr) - ((UDATA)oldDataAddr));
1421-
}
1422-
else
1423-
displacement = (IDATA) (((UDATA)newPinningArrayAddress) - ((UDATA)oldPinningArrayAddress));
1413+
1414+
IDATA displacement = 0;
1415+
1416+
if (newPinningArrayAddress)
1417+
displacement = walkState->walkThread->javaVM->memoryManagerFunctions->j9gc_objaccess_indexableDataDisplacement(walkState->walkThread, (J9IndexableObject*)oldPinningArrayAddress, (J9IndexableObject*)newPinningArrayAddress);
1418+
14241419
++(walkState->slotIndex);
14251420

14261421
#ifdef J9VM_INTERP_STACKWALK_TRACING

0 commit comments

Comments
 (0)