Skip to content

Commit

Permalink
Merge pull request eclipse-openj9#19586 from theresa-m/vttests_2
Browse files Browse the repository at this point in the history
VM support for value type annotations
  • Loading branch information
hangshao0 authored Jun 3, 2024
2 parents bafd042 + 3c5d543 commit dea130d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
41 changes: 37 additions & 4 deletions runtime/bcutil/ClassFileOracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ ClassFileOracle::KnownAnnotation ClassFileOracle::_knownAnnotations[] = {
{JVMTIMOUNTTRANSITION_SIGNATURE , sizeof(JVMTIMOUNTTRANSITION_SIGNATURE)},
#undef JVMTIMOUNTTRANSITION_SIGNATURE
#endif /* JAVA_SPEC_VERSION >= 20 */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
#define NULLRESTRICTED_SIGNATURE "Ljdk/internal/vm/annotation/NullRestricted;"
{NULLRESTRICTED_SIGNATURE , sizeof(NULLRESTRICTED_SIGNATURE)},
#undef NULLRESTRICTED_SIGNATURE
#define IMPLICITLYCONSTRUCTIBLE_SIGNATURE "Ljdk/internal/vm/annotation/ImplicitlyConstructible;"
{IMPLICITLYCONSTRUCTIBLE_SIGNATURE , sizeof(IMPLICITLYCONSTRUCTIBLE_SIGNATURE)},
#undef IMPLICITLYCONSTRUCTIBLE_SIGNATURE
#define LOOSELYCONSISTENTVALUE_SIGNATURE "Ljdk/internal/vm/annotation/LooselyConsistentValue;"
{LOOSELYCONSISTENTVALUE_SIGNATURE , sizeof(LOOSELYCONSISTENTVALUE_SIGNATURE)},
#undef LOOSELYCONSISTENTVALUE_SIGNATURE
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
{0, 0}
};

Expand Down Expand Up @@ -233,7 +244,8 @@ ClassFileOracle::ClassFileOracle(BufferManager *bufferManager, J9CfrClassFile *c
_preloadAttribute(NULL),
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
_implicitCreation(NULL),
_hasImplicitCreationAttribute(false),
_implicitCreationFlags(0),
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
_recordComponentCount(0),
_permittedSubclassesAttribute(NULL),
Expand Down Expand Up @@ -430,13 +442,19 @@ ClassFileOracle::walkFields()
knownAnnotations = addAnnotationBit(knownAnnotations, CONTENDED_ANNOTATION);
knownAnnotations = addAnnotationBit(knownAnnotations, JAVA8_CONTENDED_ANNOTATION);
}
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
knownAnnotations = addAnnotationBit(knownAnnotations, NULLRESTRICTED_ANNOTATION);
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
if (0 == attribAnnotations->rawDataLength) {
UDATA foundAnnotations = walkAnnotations(attribAnnotations->numberOfAnnotations, attribAnnotations->annotations, knownAnnotations);


if (containsKnownAnnotation(foundAnnotations, CONTENDED_ANNOTATION) || containsKnownAnnotation(foundAnnotations, JAVA8_CONTENDED_ANNOTATION)) {
_fieldsInfo[fieldIndex].isFieldContended = true;
}
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
if (containsKnownAnnotation(foundAnnotations, NULLRESTRICTED_ANNOTATION)) {
_fieldsInfo[fieldIndex].isNullRestricted = true;
}
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
}
_fieldsInfo[fieldIndex].annotationsAttribute = attribAnnotations;
break;
Expand Down Expand Up @@ -563,6 +581,10 @@ ClassFileOracle::walkAttributes()
}
knownAnnotations = addAnnotationBit(knownAnnotations, UNMODIFIABLE_ANNOTATION);
knownAnnotations = addAnnotationBit(knownAnnotations, VALUEBASED_ANNOTATION);
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
knownAnnotations = addAnnotationBit(knownAnnotations, IMPLICITLYCONSTRUCTIBLE_ANNOTATION);
knownAnnotations = addAnnotationBit(knownAnnotations, LOOSELYCONSISTENTVALUE_ANNOTATION);
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
_annotationsAttribute = (J9CfrAttributeRuntimeVisibleAnnotations *)attrib;
if (0 == _annotationsAttribute->rawDataLength) {
UDATA foundAnnotations = walkAnnotations(_annotationsAttribute->numberOfAnnotations, _annotationsAttribute->annotations, knownAnnotations);
Expand All @@ -575,6 +597,16 @@ ClassFileOracle::walkAttributes()
if (containsKnownAnnotation(foundAnnotations, VALUEBASED_ANNOTATION)) {
_isClassValueBased = true;
}
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
if (containsKnownAnnotation(foundAnnotations, IMPLICITLYCONSTRUCTIBLE_ANNOTATION)) {
_hasImplicitCreationAttribute = true;
_implicitCreationFlags |= J9AccImplicitCreateHasDefaultValue;
}
if (containsKnownAnnotation(foundAnnotations, LOOSELYCONSISTENTVALUE_ANNOTATION)) {
_hasImplicitCreationAttribute = true;
_implicitCreationFlags |= J9AccImplicitCreateNonAtomic;
}
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
}
break;
}
Expand Down Expand Up @@ -629,7 +661,8 @@ ClassFileOracle::walkAttributes()
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
case CFR_ATTRIBUTE_ImplicitCreation: {
_implicitCreation = (J9CfrAttributeImplicitCreation *)attrib;
_hasImplicitCreationAttribute = true;
_implicitCreationFlags = ((J9CfrAttributeImplicitCreation *)attrib)->implicitCreationFlags;
break;
}
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
Expand Down
12 changes: 9 additions & 3 deletions runtime/bcutil/ClassFileOracle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,8 +1035,8 @@ class RecordComponentIterator
}
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
bool hasImplicitCreation() const { return NULL != _implicitCreation; }
U_16 getImplicitCreationFlags() const { return hasImplicitCreation() ? _implicitCreation->implicitCreationFlags : 0; }
bool hasImplicitCreation() const { return _hasImplicitCreationAttribute; }
U_16 getImplicitCreationFlags() const { return _implicitCreationFlags; }
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */

U_16 getPermittedSubclassesClassNameAtIndex(U_16 index) const {
Expand Down Expand Up @@ -1092,6 +1092,11 @@ class RecordComponentIterator
#if JAVA_SPEC_VERSION >= 20
JVMTIMOUNTTRANSITION_ANNOTATION,
#endif /* JAVA_SPEC_VERSION >= 20 */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
NULLRESTRICTED_ANNOTATION,
IMPLICITLYCONSTRUCTIBLE_ANNOTATION,
LOOSELYCONSISTENTVALUE_ANNOTATION,
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
KNOWN_ANNOTATION_COUNT
};

Expand Down Expand Up @@ -1170,7 +1175,8 @@ class RecordComponentIterator
J9CfrAttributePreload *_preloadAttribute;
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
J9CfrAttributeImplicitCreation *_implicitCreation;
bool _hasImplicitCreationAttribute;
U_16 _implicitCreationFlags;
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
#if JAVA_SPEC_VERSION >= 11
J9CfrAttributeNestMembers *_nestMembers;
Expand Down

0 comments on commit dea130d

Please sign in to comment.