Skip to content

Commit

Permalink
Replace #ifdef with #if define for flattenable value type tags
Browse files Browse the repository at this point in the history
Improves consistentency so J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES is easy to search for.

Signed-off-by: Theresa Mammarella <[email protected]>
  • Loading branch information
theresa-m committed Sep 26, 2023
1 parent 5756d90 commit b37c95a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions runtime/oti/j9nonbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ typedef struct J9ROMFieldOffsetWalkResult {
UDATA superTotalInstanceSize;
UDATA index;
IDATA backfillOffset;
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
struct J9Class* flattenedClass;
#endif /* J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES */
} J9ROMFieldOffsetWalkResult;
Expand Down Expand Up @@ -1632,7 +1632,7 @@ typedef struct J9ROMFieldOffsetWalkState {
struct J9HiddenInstanceField* hiddenInstanceFields[J9VM_MAX_HIDDEN_FIELDS_PER_CLASS];
UDATA hiddenInstanceFieldCount;
UDATA hiddenInstanceFieldWalkIndex;
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
struct J9FlattenedClassCache *flattenedClassCache;
UDATA firstFlatSingleOffset;
UDATA firstFlatObjectOffset;
Expand Down Expand Up @@ -4832,7 +4832,7 @@ typedef struct J9InternalVMFunctions {
UDATA ( *structuredSignalHandlerVM)(struct J9PortLibrary* portLibrary, U_32 gpType, void* gpInfo, void* userData) ;
UDATA ( *addHiddenInstanceField)(struct J9JavaVM *vm, const char *className, const char *fieldName, const char *fieldSignature, UDATA *offsetReturn) ;
void ( *reportHotField)(struct J9JavaVM *javaVM, int32_t reducedCpuUtil, J9Class* clazz, uint8_t fieldOffset, uint32_t reducedFrequency) ;
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
struct J9ROMFieldOffsetWalkResult* ( *fieldOffsetsStartDo)(struct J9JavaVM *vm, struct J9ROMClass *romClass, struct J9Class *superClazz, struct J9ROMFieldOffsetWalkState *state, U_32 flags, J9FlattenedClassCache *flattenedClassCache) ;
#else /* J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES */
struct J9ROMFieldOffsetWalkResult* ( *fieldOffsetsStartDo)(struct J9JavaVM *vm, struct J9ROMClass *romClass, struct J9Class *superClazz, struct J9ROMFieldOffsetWalkState *state, U_32 flags) ;
Expand Down Expand Up @@ -5900,7 +5900,7 @@ typedef struct J9JavaVM {
#endif /* WIN32 */
#endif /* J9VM_INTERP_ATOMIC_FREE_JNI_USES_FLUSH */
omrthread_monitor_t constantDynamicMutex;
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
UDATA valueFlatteningThreshold;
omrthread_monitor_t valueTypeVerificationMutex;
struct J9Pool* valueTypeVerificationStackPool;
Expand Down
4 changes: 2 additions & 2 deletions runtime/oti/vm_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2516,7 +2516,7 @@ instanceFieldOffsetWithSourceClass(J9VMThread *vmStruct, J9Class *clazz, U_8 *fi
* @return J9ROMFieldOffsetWalkResult *
*/
J9ROMFieldOffsetWalkResult *
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
fieldOffsetsStartDo(J9JavaVM *vm, J9ROMClass *romClass, J9Class *superClazz, J9ROMFieldOffsetWalkState *state, U_32 flags, J9FlattenedClassCache *flattenedClassCache);
#else /* J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES */
fieldOffsetsStartDo(J9JavaVM *vm, J9ROMClass *romClass, J9Class *superClazz, J9ROMFieldOffsetWalkState *state, U_32 flags);
Expand Down Expand Up @@ -2667,7 +2667,7 @@ fullTraversalFieldOffsetsStartDo(J9JavaVM *vm, J9Class *clazz, J9ROMFullTraversa
J9ROMFieldShape *
fullTraversalFieldOffsetsNextDo(J9ROMFullTraversalFieldOffsetWalkState *state);

#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
/**
* @brief Search for ramClass in flattened class cache
*
Expand Down
6 changes: 3 additions & 3 deletions runtime/vm/ObjectFieldInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ObjectFieldInfo::countInstanceFields(void)
const U_32 modifiers = field->modifiers;
if (J9_ARE_NO_BITS_SET(modifiers, J9AccStatic) ) {
if (modifiers & J9FieldFlagObject) {
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
J9UTF8 *fieldSig = J9ROMFIELDSHAPE_SIGNATURE(field);
U_8 *fieldSigBytes = J9UTF8_DATA(J9ROMFIELDSHAPE_SIGNATURE(field));
if ('Q' == *fieldSigBytes) {
Expand Down Expand Up @@ -152,7 +152,7 @@ ObjectFieldInfo::calculateTotalFieldsSizeAndBackfill()
accumulator = ROUND_UP_TO_POWEROF2((UDATA)accumulator, (UDATA)_cacheLineSize) - _objectHeaderSize; /* Rounding takes care of the odd number of 4-byte fields. Remove the header */
} else {
accumulator = _superclassFieldsSize + (_totalObjectCount * _referenceSize) + (_totalSingleCount * sizeof(U_32)) + (_totalDoubleCount * sizeof(U_64));
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
accumulator += _totalFlatFieldDoubleBytes + _totalFlatFieldRefBytes + _totalFlatFieldSingleBytes;

/* ValueTypes cannot be subtyped and their superClass contains no fields */
Expand All @@ -179,7 +179,7 @@ ObjectFieldInfo::calculateTotalFieldsSizeAndBackfill()
} else {
_subclassBackfillOffset = _superclassBackfillOffset;
}
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
} else {
/* If the first field does not start at zero, this means we added padding to satisfy
* alignment requirements of double slot fields. We will use the J9ClassHasPrePadding flag
Expand Down
8 changes: 4 additions & 4 deletions runtime/vm/ObjectFieldInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ObjectFieldInfo {
U_32 _contendedSingleCount;
U_32 _contendedDoubleCount;

#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
bool _isValue;
J9FlattenedClassCache *_flattenedClassCache;
U_32 _totalFlatFieldDoubleBytes;
Expand Down Expand Up @@ -99,7 +99,7 @@ class ObjectFieldInfo {
OBJECT_SIZE_INCREMENT_IN_BYTES = 8
};

#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
ObjectFieldInfo(J9JavaVM *vm, J9ROMClass *romClass, J9FlattenedClassCache *flattenedClassCache):
#else
ObjectFieldInfo(J9JavaVM *vm, J9ROMClass *romClass):
Expand All @@ -120,7 +120,7 @@ class ObjectFieldInfo {
_contendedObjectCount(0),
_contendedSingleCount(0),
_contendedDoubleCount(0),
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
_isValue(J9ROMCLASS_IS_VALUE(romClass)),
_flattenedClassCache(flattenedClassCache),
_totalFlatFieldDoubleBytes(0),
Expand Down Expand Up @@ -498,7 +498,7 @@ class ObjectFieldInfo {
return start + (isContendedClassLayout() ? _contendedObjectCount: getNonBackfilledObjectCount()) * _referenceSize;
}

#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
/**
* @param start end of previous field area, which should be the first field area
* @return offset to end of the flat doubles area
Expand Down
10 changes: 5 additions & 5 deletions runtime/vm/resolvefield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ addOrUpdateHotField(J9JavaVM *javaVM, J9Class* clazz, uint8_t fieldOffset, int32
}

J9ROMFieldOffsetWalkResult *
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
fieldOffsetsStartDo(J9JavaVM *vm, J9ROMClass *romClass, J9Class *superClazz, J9ROMFieldOffsetWalkState *state, U_32 flags, J9FlattenedClassCache *flattenedClassCache)
#else /* J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES */
fieldOffsetsStartDo(J9JavaVM *vm, J9ROMClass *romClass, J9Class *superClazz, J9ROMFieldOffsetWalkState *state, U_32 flags)
Expand All @@ -767,7 +767,7 @@ fieldOffsetsStartDo(J9JavaVM *vm, J9ROMClass *romClass, J9Class *superClazz, J9R
state->romClass = romClass;
state->hiddenInstanceFieldWalkIndex = (UDATA)-1;

#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
state->flattenedClassCache = flattenedClassCache;

ObjectFieldInfo fieldInfo(vm, romClass, flattenedClassCache);
Expand Down Expand Up @@ -865,7 +865,7 @@ fieldOffsetsStartDo(J9JavaVM *vm, J9ROMClass *romClass, J9Class *superClazz, J9R
}

state->result.totalInstanceSize = fieldInfo.calculateTotalFieldsSizeAndBackfill();
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
state->flatBackFillSize = fieldInfo.getBackfillSize();
state->classRequiresPrePadding = fieldInfo.doesClassRequiresPrePadding();
state->firstFlatDoubleOffset = fieldInfo.calculateFieldDataStart();
Expand Down Expand Up @@ -1000,7 +1000,7 @@ fieldOffsetsNextDo(J9ROMFieldOffsetWalkState *state)
BOOLEAN walkHiddenFields = FALSE;

state->result.field = NULL;
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
state->result.flattenedClass = NULL;
#endif /* J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES */

Expand Down Expand Up @@ -1102,7 +1102,7 @@ fieldOffsetsFindNext(J9ROMFieldOffsetWalkState *state, J9ROMFieldShape *field)
if( state->walkFlags & J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE ) {
{
if( modifiers & J9FieldFlagObject ) {
#ifdef J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
J9UTF8 *fieldSig = J9ROMFIELDSHAPE_SIGNATURE(field);
U_8 *fieldSigBytes = J9UTF8_DATA(fieldSig);
if ('Q' == *fieldSigBytes) {
Expand Down

0 comments on commit b37c95a

Please sign in to comment.