Skip to content

Commit

Permalink
Merge pull request #18283 from eclipse-openj9/revert-18268-master
Browse files Browse the repository at this point in the history
Revert "Add numberOfElements parameter to getArrayletLayout()"
  • Loading branch information
amicic committed Oct 13, 2023
2 parents e0018c0 + 072b0bc commit 6df98f6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 32 deletions.
2 changes: 1 addition & 1 deletion runtime/gc_base/IndexableObjectAllocationModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MM_IndexableObjectAllocationModel : public MM_JavaObjectAllocationModel
0, allocateObjectFlags | OMR_GC_ALLOCATE_OBJECT_INDEXABLE)
, _numberOfIndexedFields(numberOfIndexedFields)
, _dataSize(env->getExtensions()->indexableObjectModel.getDataSizeInBytes(_class, _numberOfIndexedFields))
, _layout(env->getExtensions()->indexableObjectModel.getArrayletLayout(_class, _numberOfIndexedFields,
, _layout(env->getExtensions()->indexableObjectModel.getArrayletLayout(_class, _dataSize,
_allocateDescription.getMemorySpace()->getDefaultMemorySubSpace()->largestDesirableArraySpine()))
, _alignSpineDataSection(env->getExtensions()->indexableObjectModel.shouldAlignSpineDataSection(_class))
, _numberOfArraylets(env->getExtensions()->indexableObjectModel.numArraylets(_dataSize))
Expand Down
5 changes: 2 additions & 3 deletions runtime/gc_glue_java/ArrayletObjectModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ GC_ArrayletObjectModel::AssertDiscontiguousArrayletLayout(J9IndexableObject *obj
}

GC_ArrayletObjectModel::ArrayLayout
GC_ArrayletObjectModel::getArrayletLayout(J9Class* clazz, UDATA numberOfElements, UDATA largestDesirableSpine)
GC_ArrayletObjectModel::getArrayletLayout(J9Class* clazz, UDATA dataSizeInBytes, UDATA largestDesirableSpine)
{
ArrayLayout layout = Illegal;
MM_GCExtensionsBase* extensions = MM_GCExtensionsBase::getExtensions(_omrVM);
UDATA objectAlignmentInBytes = extensions->getObjectAlignmentInBytes();
uintptr_t dataSizeInBytes = getDataSizeInBytes(clazz, numberOfElements);

/* the spine need not contain a pointer to the data */
const UDATA minimumSpineSize = 0;
Expand All @@ -95,7 +94,7 @@ GC_ArrayletObjectModel::getArrayletLayout(J9Class* clazz, UDATA numberOfElements
/* CMVC 135307 : when checking for InlineContiguous layout, perform subtraction as adding to dataSizeInBytes could trigger overflow. */
if ((largestDesirableSpine == UDATA_MAX) || (dataSizeInBytes <= (largestDesirableSpine - minimumSpineSizeAfterGrowing - contiguousIndexableHeaderSize()))) {
layout = InlineContiguous;
if (0 == numberOfElements) {
if ((0 == dataSizeInBytes) && (0 < J9ARRAYCLASS_GET_STRIDE(clazz))) {
/* Zero sized NUA uses the discontiguous shape */
layout = Discontiguous;
}
Expand Down
45 changes: 18 additions & 27 deletions runtime/gc_glue_java/ArrayletObjectModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,33 +376,18 @@ class GC_ArrayletObjectModel : public GC_ArrayletObjectModelBase
}

/**
* Get the size from the header for the given indexable object,
* assuming it is Contiguous
* Get the size from the header for the given indexable object
* @param objPtr Pointer to an array object
* @return the size
*/
MMINLINE uintptr_t
getContiguousArraySize(J9IndexableObject *objPtr)
getArraySize(J9IndexableObject *objPtr)
{
return compressObjectReferences()
? ((J9IndexableObjectContiguousCompressed*)objPtr)->size
: ((J9IndexableObjectContiguousFull*)objPtr)->size;
}

/**
* Get the size from the header for the given indexable object,
* assuming it is Discontiguous
* @param objPtr Pointer to an array object
* @return the size
*/
MMINLINE uintptr_t
getDiscontiguousArraySize(J9IndexableObject *objPtr)
{
return compressObjectReferences()
? ((J9IndexableObjectDiscontiguousCompressed*)objPtr)->size
: ((J9IndexableObjectDiscontiguousFull*)objPtr)->size;
}

/**
* Get the layout for the given indexable object
* @param objPtr Pointer to an array object
Expand All @@ -413,31 +398,32 @@ class GC_ArrayletObjectModel : public GC_ArrayletObjectModelBase
{
GC_ArrayletObjectModel::ArrayLayout layout = GC_ArrayletObjectModel::InlineContiguous;
/* Trivial check for InlineContiguous. */
if (0 != getContiguousArraySize(objPtr)) {
if (0 != getArraySize(objPtr)) {
return GC_ArrayletObjectModel::InlineContiguous;
}

/* Check if the objPtr is in the allowed arraylet range. */
if (((uintptr_t)objPtr >= (uintptr_t)_arrayletRangeBase) && ((uintptr_t)objPtr < (uintptr_t)_arrayletRangeTop)) {
uintptr_t dataSizeInBytes = getDataSizeInBytes(objPtr);
J9Class* clazz = J9GC_J9OBJECT_CLAZZ(objPtr, this);
layout = getArrayletLayout(clazz, getDiscontiguousArraySize(objPtr));
layout = getArrayletLayout(clazz, dataSizeInBytes);
}
return layout;
}

MMINLINE ArrayLayout
getArrayletLayout(J9Class* clazz, uintptr_t numberOfElements)
getArrayletLayout(J9Class* clazz, uintptr_t dataSizeInBytes)
{
return getArrayletLayout(clazz, numberOfElements, _largestDesirableArraySpineSize);
return getArrayletLayout(clazz, dataSizeInBytes, _largestDesirableArraySpineSize);
}

/**
* Get the layout of an indexable object given it's class, data size in bytes and the subspace's largestDesirableSpine.
* @param clazz The class of the object stored in the array.
* @param numberOfElements number of indexed fields
* @param dataSizeInBytes the size in bytes of the data of the array.
* @param largestDesirableSpine The largest desirable spine of the arraylet.
*/
ArrayLayout getArrayletLayout(J9Class* clazz, uintptr_t numberOfElements, uintptr_t largestDesirableSpine);
ArrayLayout getArrayletLayout(J9Class* clazz, uintptr_t dataSizeInBytes, uintptr_t largestDesirableSpine);

/**
* Perform a safe memcpy of one array to another.
Expand Down Expand Up @@ -1149,7 +1135,11 @@ class GC_ArrayletObjectModel : public GC_ArrayletObjectModelBase

if (0 == size) {
/* Discontiguous */
size = getDiscontiguousArraySize((J9IndexableObject *)forwardedHeader->getObject());
if (compressObjectReferences()) {
size = ((J9IndexableObjectDiscontiguousCompressed *)forwardedHeader->getObject())->size;
} else {
size = ((J9IndexableObjectDiscontiguousFull *)forwardedHeader->getObject())->size;
}
}

return size;
Expand Down Expand Up @@ -1182,8 +1172,8 @@ class GC_ArrayletObjectModel : public GC_ArrayletObjectModelBase

if (0 == size) {
/* we know we are dealing with heap object, so we don't need to check against _arrayletRangeBase/Top, like getArrayLayout does */
uintptr_t numberOfElements = (uintptr_t)getPreservedIndexableSize(forwardedHeader);
layout = getArrayletLayout(clazz, numberOfElements);
uintptr_t dataSizeInBytes = getDataSizeInBytes(clazz, getPreservedIndexableSize(forwardedHeader));
layout = getArrayletLayout(clazz, dataSizeInBytes);
}

return layout;
Expand All @@ -1202,7 +1192,8 @@ class GC_ArrayletObjectModel : public GC_ArrayletObjectModelBase
{
J9Class* clazz = getPreservedClass(forwardedHeader);
uintptr_t numberOfElements = (uintptr_t)getPreservedIndexableSize(forwardedHeader);
ArrayLayout layout = getArrayletLayout(clazz, numberOfElements);
uintptr_t dataSizeInBytes = getDataSizeInBytes(clazz, numberOfElements);
ArrayLayout layout = getArrayletLayout(clazz, dataSizeInBytes);
*hashcodeOffset = getHashcodeOffset(clazz, layout, numberOfElements);
return getSizeInBytesWithHeader(clazz, layout, numberOfElements);
}
Expand Down
3 changes: 2 additions & 1 deletion runtime/gc_glue_java/ObjectModelDelegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ class GC_ObjectModelDelegate
}
}

GC_ArrayletObjectModel::ArrayLayout layout = _arrayObjectModel->getArrayletLayout(clazz, elements);
uintptr_t dataSize = _arrayObjectModel->getDataSizeInBytes(clazz, elements);
GC_ArrayletObjectModel::ArrayLayout layout = _arrayObjectModel->getArrayletLayout(clazz, dataSize);
size = _arrayObjectModel->getSizeInBytesWithHeader(clazz, layout, elements);
} else {
size = _mixedObjectModel->getSizeInBytesWithoutHeader(clazz) + J9GC_OBJECT_HEADER_SIZE(this);
Expand Down

0 comments on commit 6df98f6

Please sign in to comment.