Skip to content

Commit

Permalink
Merge pull request #18035 from theresa-m/nr_cfdump
Browse files Browse the repository at this point in the history
NullRestricted Valhalla attribute cfdump support
  • Loading branch information
hangshao0 authored Sep 5, 2023
2 parents bbe274b + 623f73e commit 8675daf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions runtime/bcutil/ClassFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ DECLARE_UTF8_ATTRIBUTE_NAME(PRELOAD, "Preload");
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
DECLARE_UTF8_ATTRIBUTE_NAME(IMPLICITCREATION, "ImplicitCreation");
DECLARE_UTF8_ATTRIBUTE_NAME(NULLRESTRICTED, "NullRestricted");
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
#if JAVA_SPEC_VERSION >= 11
DECLARE_UTF8_ATTRIBUTE_NAME(NEST_MEMBERS, "NestMembers");
Expand Down Expand Up @@ -435,6 +436,12 @@ ClassFileWriter::analyzeFields()
}
}

#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
if (J9_ARE_ALL_BITS_SET(fieldShape->modifiers, J9FieldFlagIsNullRestricted)) {
addEntry((void *) &NULLRESTRICTED, 0, CFR_CONSTANT_Utf8);
}
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */

fieldShape = romFieldsNextDo(&fieldWalkState);
}
}
Expand Down Expand Up @@ -805,6 +812,11 @@ ClassFileWriter::writeField(J9ROMFieldShape * fieldShape)
if (NULL != typeAnnotationsData) {
attributesCount += 1;
}
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
if (J9_ARE_ALL_BITS_SET(fieldShape->modifiers, J9FieldFlagIsNullRestricted)) {
attributesCount += 1;
}
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */

writeU16(U_16(fieldShape->modifiers & CFR_FIELD_ACCESS_MASK));
writeU16(indexForUTF8(name));
Expand Down Expand Up @@ -844,6 +856,11 @@ ClassFileWriter::writeField(J9ROMFieldShape * fieldShape)
if (NULL != typeAnnotationsData) {
writeTypeAnnotationsAttribute(typeAnnotationsData);
}
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
if (J9_ARE_ALL_BITS_SET(fieldShape->modifiers, J9FieldFlagIsNullRestricted)) {
writeAttributeHeader((J9UTF8 *) &NULLRESTRICTED, 0);
}
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
}

void
Expand Down
8 changes: 8 additions & 0 deletions runtime/cfdumper/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,14 @@ static void printField(J9CfrClassFile* classfile, J9CfrField* field)
for(i = 0; i < arity; i++)
j9tty_printf( PORTLIB, "[]");

#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
for(i = 0; i < field->attributesCount; i++) {
if (CFR_ATTRIBUTE_NullRestricted == field->attributes[i]->tag) {
j9tty_printf(PORTLIB, "!");
}
}
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */

j9tty_printf( PORTLIB, " %s;\n", classfile->constantPool[field->nameIndex].bytes);

return;
Expand Down

0 comments on commit 8675daf

Please sign in to comment.