Skip to content

Commit

Permalink
Merge pull request #20325 from theresa-m/fix_19611
Browse files Browse the repository at this point in the history
Rename Preload attribute to LoadableDescriptors
  • Loading branch information
hangshao0 authored Oct 22, 2024
2 parents 636d4a0 + 25469ba commit bd36b1d
Show file tree
Hide file tree
Showing 26 changed files with 295 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ J9JavaClassFlags.J9ClassRequiresPrePadding = 0

J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE = 0
J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_INJECTED_INTERFACE_INFO = 0
J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE = 0
J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PERMITTEDSUBCLASSES_ATTRIBUTE = 0
J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE = 0
J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_RECORD_ATTRIBUTE = 0

J9Object.OBJECT_HEADER_LOCK_LEARNING = 0
Expand Down
24 changes: 12 additions & 12 deletions debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/OptInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_ENCLOSING_METHOD;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_GENERIC_SIGNATURE;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PERMITTEDSUBCLASSES_ATTRIBUTE;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SIMPLE_NAME;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SOURCE_DEBUG_EXTENSION;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SOURCE_FILE_NAME;
Expand Down Expand Up @@ -268,28 +268,28 @@ public static J9UTF8Pointer getPermittedSubclassNameAtIndex(J9ROMClassPointer ro
return J9UTF8Pointer.NULL;
}

public static int getPreloadClassCount(J9ROMClassPointer romClass) throws CorruptDataException {
U32Pointer preloadClassInfoPointer = getPreloadClassInfoPointer(romClass);
if (preloadClassInfoPointer.notNull()) {
return preloadClassInfoPointer.at(0).intValue();
public static int getLoadableDescriptorsCount(J9ROMClassPointer romClass) throws CorruptDataException {
U32Pointer loadableDescriptorsInfoPointer = getLoadableDescriptorsInfoPointer(romClass);
if (loadableDescriptorsInfoPointer.notNull()) {
return loadableDescriptorsInfoPointer.at(0).intValue();
}
return 0;
}

private static U32Pointer getPreloadClassInfoPointer(J9ROMClassPointer romClass) throws CorruptDataException {
private static U32Pointer getLoadableDescriptorsInfoPointer(J9ROMClassPointer romClass) throws CorruptDataException {
SelfRelativePointer srpPtr = getSRPPtr(J9ROMClassHelper.optionalInfo(romClass), romClass.optionalFlags(),
J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE);
J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE);
if (srpPtr.notNull()) {
return U32Pointer.cast(srpPtr.get());
}
return U32Pointer.NULL;
}

public static J9UTF8Pointer getPreloadClassNameAtIndex(J9ROMClassPointer romClass, int index) throws CorruptDataException {
U32Pointer preloadClassInfoPointer = getPreloadClassInfoPointer(romClass);
if (preloadClassInfoPointer.notNull()) {
/* extra 1 is to move past the preload class count */
SelfRelativePointer nameSrp = SelfRelativePointer.cast(preloadClassInfoPointer.add(index + 1));
public static J9UTF8Pointer getLoadableDescriptorAtIndex(J9ROMClassPointer romClass, int index) throws CorruptDataException {
U32Pointer loadableDescriptorsInfoPointer = getLoadableDescriptorsInfoPointer(romClass);
if (loadableDescriptorsInfoPointer.notNull()) {
/* extra 1 is to move past the descriptors count */
SelfRelativePointer nameSrp = SelfRelativePointer.cast(loadableDescriptorsInfoPointer.add(index + 1));
return J9UTF8Pointer.cast(nameSrp.get());
}
return J9UTF8Pointer.NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import static com.ibm.j9ddr.vm29.structure.J9JavaAccessFlags.*;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE;

import com.ibm.j9ddr.CorruptDataException;
import com.ibm.j9ddr.vm29.pointer.U32Pointer;
Expand Down Expand Up @@ -135,8 +135,8 @@ public static boolean isSealed(J9ROMClassPointer romclass) throws CorruptDataExc
return romclass.extraModifiers().allBitsIn(J9AccSealed);
}

public static boolean hasPreloadAttribute(J9ROMClassPointer romclass) throws CorruptDataException {
return romclass.optionalFlags().allBitsIn(J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE);
public static boolean hasLoadableDescriptorsAttribute(J9ROMClassPointer romclass) throws CorruptDataException {
return romclass.optionalFlags().allBitsIn(J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE);
}

public static boolean hasImplicitCreationAttribute(J9ROMClassPointer romclass) throws CorruptDataException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,9 +750,9 @@ void allSlotsInOptionalInfoDo() throws CorruptDataException
cursor = cursor.add(1);
}

if (J9ROMClassHelper.hasPreloadAttribute(romClass)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_SRP, cursor, "preloadAttributeSRP");
preloadAttributeDo(U32Pointer.cast(cursor.get()));
if (J9ROMClassHelper.hasLoadableDescriptorsAttribute(romClass)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_SRP, cursor, "loadableDescriptorsAttributeSRP");
loadableDescriptorsAttributeDo(U32Pointer.cast(cursor.get()));
cursor = cursor.add(1);
}
}
Expand Down Expand Up @@ -1018,19 +1018,21 @@ void permittedSubclassAttributeDo(U32Pointer attribute) throws CorruptDataExcept
classWalkerCallback.addSection(clazz, attributeStart, attribute.getAddress() - attributeStart.getAddress(), "permittedSubclass", true);
}

void preloadAttributeDo(U32Pointer attribute) throws CorruptDataException
void loadableDescriptorsAttributeDo(U32Pointer attribute) throws CorruptDataException
{
if (attribute.isNull()) {
return;
}
U32Pointer attributeStart = attribute;
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, attribute, "numberPreloadClasses");
for (int i = 0, numPreloadClasses = attribute.at(0).intValue(); i < numPreloadClasses; i++) {
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, attribute, "numberLoadableDescriptors");
for (int i = 0, numLoadableDescriptors = attribute.at(0).intValue(); i < numLoadableDescriptors; i++) {
attribute = attribute.add(1);
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, attribute, "preloadClassName");
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, attribute, "loadableDescriptorName");
}
attribute = attribute.add(1);
classWalkerCallback.addSection(clazz, attributeStart, attribute.getAddress() - attributeStart.getAddress(), "preloadAttribute", true);
classWalkerCallback.addSection(clazz, attributeStart,
attribute.getAddress() - attributeStart.getAddress(),
"loadableDescriptorsAttribute", true);
}

void implicitCreationAttributeDo(U32Pointer attribute) throws CorruptDataException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,13 @@ public static void j9bcutil_dumpRomClass(PrintStream out, J9ROMClassPointer romC
}
}

if (J9ROMClassHelper.hasPreloadAttribute(romClass)) {
int preloadClassCount = OptInfo.getPreloadClassCount(romClass);
out.format("Preload classes (%d):%n", preloadClassCount);
if (J9ROMClassHelper.hasLoadableDescriptorsAttribute(romClass)) {
int loadableDescriptorsCount = OptInfo.getLoadableDescriptorsCount(romClass);
out.format("Loadable Descriptors (%d):%n", loadableDescriptorsCount);

for (int i = 0; i < preloadClassCount; i++) {
J9UTF8Pointer preloadClassName = OptInfo.getPreloadClassNameAtIndex(romClass, i);
out.format(" %s%n", J9UTF8Helper.stringValue(preloadClassName));
for (int i = 0; i < loadableDescriptorsCount; i++) {
J9UTF8Pointer loadableDescriptor = OptInfo.getLoadableDescriptorAtIndex(romClass, i);
out.format(" %s%n", J9UTF8Helper.stringValue(loadableDescriptor));
}
}

Expand Down
12 changes: 6 additions & 6 deletions runtime/bcutil/ClassFileOracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ ClassFileOracle::ClassFileOracle(BufferManager *bufferManager, J9CfrClassFile *c
_isRecord(false),
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
_hasNonStaticSynchronizedMethod(false),
_preloadAttribute(NULL),
_loadableDescriptorsAttribute(NULL),
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
_hasImplicitCreationAttribute(false),
Expand Down Expand Up @@ -632,11 +632,11 @@ ClassFileOracle::walkAttributes()
break;
}
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
case CFR_ATTRIBUTE_Preload: {
_preloadAttribute = (J9CfrAttributePreload *)attrib;
for (U_16 numberOfClasses = 0; numberOfClasses < _preloadAttribute->numberOfClasses; numberOfClasses++) {
U_16 classCpIndex = _preloadAttribute->classes[numberOfClasses];
markClassAsReferenced(classCpIndex);
case CFR_ATTRIBUTE_LoadableDescriptors: {
_loadableDescriptorsAttribute = (J9CfrAttributeLoadableDescriptors *)attrib;
for (U_16 numberOfDescriptors = 0; numberOfDescriptors < _loadableDescriptorsAttribute->numberOfDescriptors; numberOfDescriptors++) {
U_16 descriptorCpIndex = _loadableDescriptorsAttribute->descriptors[numberOfDescriptors];
markConstantUTF8AsReferenced(descriptorCpIndex);
}
break;
}
Expand Down
13 changes: 6 additions & 7 deletions runtime/bcutil/ClassFileOracle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,14 +1018,13 @@ class RecordComponentIterator
U_16 getPermittedSubclassesClassCount() const { return _isSealed ? _permittedSubclassesAttribute->numberOfClasses : 0; }
bool isValueBased() const { return _isClassValueBased; }
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
bool hasPreloadClasses() const { return NULL != _preloadAttribute; }
U_16 getPreloadClassCount() const { return hasPreloadClasses() ? _preloadAttribute->numberOfClasses : 0; }
bool hasLoadableDescriptors() const { return NULL != _loadableDescriptorsAttribute; }
U_16 getLoadableDescriptorsCount() const { return hasLoadableDescriptors() ? _loadableDescriptorsAttribute->numberOfDescriptors : 0; }

U_16 getPreloadClassNameAtIndex(U_16 index) const {
U_16 getLoadableDescriptorAtIndex(U_16 index) const {
U_16 result = 0;
if (hasPreloadClasses()) {
U_16 classCpIndex = _preloadAttribute->classes[index];
result = _classFile->constantPool[classCpIndex].slot1;
if (hasLoadableDescriptors()) {
result = _loadableDescriptorsAttribute->descriptors[index];
}
return result;
}
Expand Down Expand Up @@ -1163,7 +1162,7 @@ class RecordComponentIterator
J9CfrAttributeBootstrapMethods *_bootstrapMethodsAttribute;
J9CfrAttributePermittedSubclasses *_permittedSubclassesAttribute;
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
J9CfrAttributePreload *_preloadAttribute;
J9CfrAttributeLoadableDescriptors *_loadableDescriptorsAttribute;
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
bool _hasImplicitCreationAttribute;
Expand Down
52 changes: 20 additions & 32 deletions runtime/bcutil/ClassFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DECLARE_UTF8_ATTRIBUTE_NAME(BOOTSTRAP_METHODS, "BootstrapMethods");
DECLARE_UTF8_ATTRIBUTE_NAME(RECORD, "Record");
DECLARE_UTF8_ATTRIBUTE_NAME(PERMITTED_SUBCLASSES, "PermittedSubclasses");
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
DECLARE_UTF8_ATTRIBUTE_NAME(PRELOAD, "Preload");
DECLARE_UTF8_ATTRIBUTE_NAME(LOADABLEDESCRIPTORS, "LoadableDescriptors");
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
DECLARE_UTF8_ATTRIBUTE_NAME(IMPLICITCREATION, "ImplicitCreation");
Expand Down Expand Up @@ -118,14 +118,14 @@ ClassFileWriter::analyzeROMClass()
}

#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE)) {
addEntry((void*) &PRELOAD, 0, CFR_CONSTANT_Utf8);
if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE)) {
addEntry((void *) &LOADABLEDESCRIPTORS, 0, CFR_CONSTANT_Utf8);

U_32 *preloadInfoPtr = getPreloadInfoPtr(_romClass);
U_32 numberOfPreloadClasses = *preloadInfoPtr;
for (U_32 i = 0; i < numberOfPreloadClasses; i++) {
J9UTF8* preloadClassNameUtf8 = preloadClassNameAtIndex(preloadInfoPtr, i);
addEntry(preloadClassNameUtf8, 0, CFR_CONSTANT_Utf8);
U_32 *loadableDescriptorsInfoPtr = getLoadableDescriptorsInfoPtr(_romClass);
U_32 numberOfLoadableDescriptors = *loadableDescriptorsInfoPtr;
for (U_32 i = 0; i < numberOfLoadableDescriptors; i++) {
J9UTF8 *loadableDescriptorUtf8 = loadableDescriptorAtIndex(loadableDescriptorsInfoPtr, i);
addEntry(loadableDescriptorUtf8, 0, CFR_CONSTANT_Utf8);
}
}
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
Expand Down Expand Up @@ -1044,7 +1044,7 @@ ClassFileWriter::writeAttributes()
}
#endif /* JAVA_SPEC_VERSION >= 11 */
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE)) {
if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE)) {
attributesCount += 1;
}
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
Expand Down Expand Up @@ -1222,29 +1222,17 @@ ClassFileWriter::writeAttributes()
}

#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
/* write Preload attribute */
if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE)) {
U_32 *preloadInfoPtr = getPreloadInfoPtr(_romClass);
/* The first 32 bits of preloadInfoPtr contain the number of preload classes */
U_32 numberPreloadClasses = *preloadInfoPtr;
writeAttributeHeader((J9UTF8 *) &PRELOAD, sizeof(U_16) + (numberPreloadClasses * sizeof(U_16)));
writeU16(numberPreloadClasses);

for (U_32 i = 0; i < numberPreloadClasses; i++) {
J9UTF8* preloadClassNameUtf8 = preloadClassNameAtIndex(preloadInfoPtr, i);
/* CONSTANT_Class_info index should be written. Find class entry that references the preload class name in constant pool. */
J9HashTableState hashTableState;
HashTableEntry * entry = (HashTableEntry *) hashTableStartDo(_cpHashTable, &hashTableState);
while (NULL != entry) {
if (CFR_CONSTANT_Class == entry->cpType) {
J9UTF8* classNameCandidate = (J9UTF8*)entry->address;
if (J9UTF8_EQUALS(classNameCandidate, preloadClassNameUtf8)) {
writeU16(entry->cpIndex);
break;
}
}
entry = (HashTableEntry *) hashTableNextDo(&hashTableState);
}
/* write LoadableDescriptors attribute */
if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE)) {
U_32 *loadableDescriptorsInfoPtr = getLoadableDescriptorsInfoPtr(_romClass);
/* The first 32 bits of loadableDescriptorsInfoPtr contain the number of descriptors */
U_32 numberLoadableDescriptors = *loadableDescriptorsInfoPtr;
writeAttributeHeader((J9UTF8 *) &LOADABLEDESCRIPTORS, sizeof(U_16) + (numberLoadableDescriptors * sizeof(U_16)));
writeU16(numberLoadableDescriptors);

for (U_32 i = 0; i < numberLoadableDescriptors; i++) {
J9UTF8 *loadableDescriptorUtf8 = loadableDescriptorAtIndex(loadableDescriptorsInfoPtr, i);
writeU16(indexForUTF8(loadableDescriptorUtf8));
}
}
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
Expand Down
4 changes: 2 additions & 2 deletions runtime/bcutil/ROMClassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1429,8 +1429,8 @@ ROMClassBuilder::computeOptionalFlags(ClassFileOracle *classFileOracle, ROMClass
if (_interfaceInjectionInfo.numOfInterfaces > 0) {
optionalFlags |= J9_ROMCLASS_OPTINFO_INJECTED_INTERFACE_INFO;
}
if (classFileOracle->hasPreloadClasses()) {
optionalFlags |= J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE;
if (classFileOracle->hasLoadableDescriptors()) {
optionalFlags |= J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE;
}
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
Expand Down
34 changes: 17 additions & 17 deletions runtime/bcutil/ROMClassWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ ROMClassWriter::ROMClassWriter(BufferManager *bufferManager, ClassFileOracle *cl
#endif /* defined(J9VM_OPT_METHOD_HANDLE) */
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
_injectedInterfaceInfoSRPKey(srpKeyProducer->generateKey()),
_preloadInfoSRPKey(srpKeyProducer->generateKey()),
_loadableDescriptorsInfoSRPKey(srpKeyProducer->generateKey()),
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
_implicitCreationSRPKey(srpKeyProducer->generateKey()),
Expand Down Expand Up @@ -460,7 +460,7 @@ ROMClassWriter::writeROMClass(Cursor *cursor,
writePermittedSubclasses(cursor, markAndCountOnly);
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
writeInjectedInterfaces(cursor, markAndCountOnly);
writePreload(cursor, markAndCountOnly);
writeloadableDescriptors(cursor, markAndCountOnly);
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
writeImplicitCreation(cursor, markAndCountOnly);
Expand Down Expand Up @@ -1913,30 +1913,30 @@ ROMClassWriter::writeImplicitCreation(Cursor *cursor, bool markAndCountOnly)

#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
/*
* Preload ROM class layout:
* 4 bytes for number of classes (actually takes up two, but use 4 for alignment)
* for number of classes:
* 4 byte SRP to class name
* LoadableDescriptors ROM class layout:
* 4 bytes for number of descriptors (actually takes up two, but use 4 for alignment)
* for number of descriptors:
* 4 byte SRP to descriptor
*/
void
ROMClassWriter::writePreload(Cursor *cursor, bool markAndCountOnly)
ROMClassWriter::writeloadableDescriptors(Cursor *cursor, bool markAndCountOnly)
{
if (_classFileOracle->hasPreloadClasses()) {
cursor->mark(_preloadInfoSRPKey);
if (_classFileOracle->hasLoadableDescriptors()) {
cursor->mark(_loadableDescriptorsInfoSRPKey);

U_16 classCount = _classFileOracle->getPreloadClassCount();
U_16 descriptorCount = _classFileOracle->getLoadableDescriptorsCount();
if (markAndCountOnly) {
cursor->skip(sizeof(U_32));
} else {
cursor->writeU32(classCount, Cursor::GENERIC);
cursor->writeU32(descriptorCount, Cursor::GENERIC);
}

for (U_16 index = 0; index < classCount; index++) {
for (U_16 index = 0; index < descriptorCount; index++) {
if (markAndCountOnly) {
cursor->skip(sizeof(J9SRP));
} else {
U_16 classNameCpIndex = _classFileOracle->getPreloadClassNameAtIndex(index);
cursor->writeSRP(_srpKeyProducer->mapCfrConstantPoolIndexToKey(classNameCpIndex), Cursor::SRP_TO_UTF8);
U_16 descriptorCpIndex = _classFileOracle->getLoadableDescriptorAtIndex(index);
cursor->writeSRP(_srpKeyProducer->mapCfrConstantPoolIndexToKey(descriptorCpIndex), Cursor::SRP_TO_UTF8);
}
}
}
Expand Down Expand Up @@ -1993,7 +1993,7 @@ ROMClassWriter::writeOptionalInfo(Cursor *cursor)
* SRP to record class component attributes
* SRP to PermittedSubclasses attribute
* SRP to injected interfaces info
* SRP to Preload attribute
* SRP to LoadableDescriptors attribute
* SRP to ImplicitCreation attribute
*/
cursor->mark(_optionalInfoSRPKey);
Expand Down Expand Up @@ -2040,8 +2040,8 @@ ROMClassWriter::writeOptionalInfo(Cursor *cursor)
if (_interfaceInjectionInfo->numOfInterfaces > 0) {
cursor->writeSRP(_injectedInterfaceInfoSRPKey, Cursor::SRP_TO_GENERIC);
}
if (_classFileOracle->hasPreloadClasses()) {
cursor->writeSRP(_preloadInfoSRPKey, Cursor::SRP_TO_GENERIC);
if (_classFileOracle->hasLoadableDescriptors()) {
cursor->writeSRP(_loadableDescriptorsInfoSRPKey, Cursor::SRP_TO_GENERIC);
}
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
Expand Down
4 changes: 2 additions & 2 deletions runtime/bcutil/ROMClassWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class ROMClassWriter
void writePermittedSubclasses(Cursor *cursor, bool markAndCountOnly);
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
void writeInjectedInterfaces(Cursor *cursor, bool markAndCountOnly);
void writePreload(Cursor *cursor, bool markAndCountOnly);
void writeloadableDescriptors(Cursor *cursor, bool markAndCountOnly);
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
void writeImplicitCreation(Cursor *cursor, bool markAndCountOnly);
Expand Down Expand Up @@ -197,7 +197,7 @@ class ROMClassWriter
UDATA _permittedSubclassesInfoSRPKey;
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
UDATA _injectedInterfaceInfoSRPKey;
UDATA _preloadInfoSRPKey;
UDATA _loadableDescriptorsInfoSRPKey;
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
UDATA _implicitCreationSRPKey;
Expand Down
Loading

0 comments on commit bd36b1d

Please sign in to comment.