diff --git a/runtime/bcutil/ClassFileOracle.cpp b/runtime/bcutil/ClassFileOracle.cpp index 74f3165dcb1..4e84ec162fc 100644 --- a/runtime/bcutil/ClassFileOracle.cpp +++ b/runtime/bcutil/ClassFileOracle.cpp @@ -231,8 +231,10 @@ ClassFileOracle::ClassFileOracle(BufferManager *bufferManager, J9CfrClassFile *c _hasNonStaticFields(false), _hasNonEmptyConstructor(false), _preloadAttribute(NULL), +#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) _implicitCreation(NULL), -#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */ +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ _recordComponentCount(0), _permittedSubclassesAttribute(NULL), _isSealed(false), @@ -457,6 +459,11 @@ ClassFileOracle::walkFields() case CFR_ATTRIBUTE_Deprecated: /* Do nothing */ break; +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) + case CFR_ATTRIBUTE_NullRestricted: + _fieldsInfo[fieldIndex].isNullRestricted = true; + break; +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ default: Trc_BCU_ClassFileOracle_walkFields_UnknownAttribute((U_32)attrib->tag, (U_32)getUTF8Length(attrib->nameIndex), getUTF8Data(attrib->nameIndex), attrib->length); break; @@ -615,11 +622,13 @@ ClassFileOracle::walkAttributes() } break; } +#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) case CFR_ATTRIBUTE_ImplicitCreation: { _implicitCreation = (J9CfrAttributeImplicitCreation *)attrib; break; } -#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ #if JAVA_SPEC_VERSION >= 11 case CFR_ATTRIBUTE_NestMembers: /* ignore CFR_ATTRIBUTE_NestMembers for hidden classes, as the nest members never know the name of hidden classes */ diff --git a/runtime/bcutil/ClassFileOracle.hpp b/runtime/bcutil/ClassFileOracle.hpp index a82a2138431..a1ef6ae693b 100644 --- a/runtime/bcutil/ClassFileOracle.hpp +++ b/runtime/bcutil/ClassFileOracle.hpp @@ -46,9 +46,6 @@ * */ #define UTF8_INDEX_FROM_CLASS_INDEX(cp, cpIndex) ((U_16)((cpIndex == 0)? 0 : cp[cpIndex].slot1)) -#define IMPLICIT_CREATION_FLAGS_DEFAULT 1 -#define IMPLICIT_CREATION_FLAGS_NON_ATOMIC 2 - class BufferManager; class ConstantPoolMap; class ROMClassCreationContext; @@ -68,6 +65,9 @@ class ClassFileOracle J9CfrAttributeRuntimeVisibleAnnotations *annotationsAttribute; J9CfrAttributeRuntimeVisibleTypeAnnotations *typeAnnotationsAttribute; bool isFieldContended; +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) + bool isNullRestricted; +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ }; struct StackMapFrameInfo @@ -345,7 +345,9 @@ class FieldIterator bool hasAnnotation() const { return _fieldsInfo[_index].annotationsAttribute != NULL;} bool hasTypeAnnotation() const { return _fieldsInfo[_index].typeAnnotationsAttribute != NULL;} bool isFieldContended() const { return _fieldsInfo[_index].isFieldContended; } - +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) + bool isNullRestricted() const { return _fieldsInfo[_index].isNullRestricted; } +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ U_32 getConstantValueSlot1() const { return _classFile->constantPool[getConstantValueConstantPoolIndex()].slot1; } U_32 getConstantValueSlot2() const { return _classFile->constantPool[getConstantValueConstantPoolIndex()].slot2; } @@ -1020,10 +1022,6 @@ class RecordComponentIterator bool needsIdentityFlag() const { return _isIdentityFlagNeeded; } bool hasIdentityFlagSet() const { return _hasIdentityFlagSet; } bool isValueType() const { return _isValueType; } - bool hasImplicitCreation() const { return NULL != _implicitCreation; } - U_16 getImplicitCreationFlags() const { return hasImplicitCreation() ? _implicitCreation->implicitCreationFlags : 0; } - bool isImplicitCreationHasDefaultValue() const { return J9_ARE_ALL_BITS_SET(getImplicitCreationFlags(), IMPLICIT_CREATION_FLAGS_DEFAULT); } - bool isImplicitCreationNonAtomic() const { return J9_ARE_ALL_BITS_SET(getImplicitCreationFlags(), IMPLICIT_CREATION_FLAGS_NON_ATOMIC); } bool hasPreloadClasses() const { return NULL != _preloadAttribute; } U_16 getPreloadClassCount() const { return hasPreloadClasses() ? _preloadAttribute->numberOfClasses : 0; } @@ -1035,7 +1033,16 @@ class RecordComponentIterator } return result; } -#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */ +#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) + #define IMPLICIT_CREATION_FLAGS_DEFAULT 1 + #define IMPLICIT_CREATION_FLAGS_NON_ATOMIC 2 + + bool hasImplicitCreation() const { return NULL != _implicitCreation; } + U_16 getImplicitCreationFlags() const { return hasImplicitCreation() ? _implicitCreation->implicitCreationFlags : 0; } + bool isImplicitCreationHasDefaultValue() const { return J9_ARE_ALL_BITS_SET(getImplicitCreationFlags(), IMPLICIT_CREATION_FLAGS_DEFAULT); } + bool isImplicitCreationNonAtomic() const { return J9_ARE_ALL_BITS_SET(getImplicitCreationFlags(), IMPLICIT_CREATION_FLAGS_NON_ATOMIC); } +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ U_16 getPermittedSubclassesClassNameAtIndex(U_16 index) const { U_16 result = 0; @@ -1165,9 +1172,11 @@ class RecordComponentIterator J9CfrAttributeBootstrapMethods *_bootstrapMethodsAttribute; J9CfrAttributePermittedSubclasses *_permittedSubclassesAttribute; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - J9CfrAttributeImplicitCreation *_implicitCreation; J9CfrAttributePreload *_preloadAttribute; #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) + J9CfrAttributeImplicitCreation *_implicitCreation; +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ #if JAVA_SPEC_VERSION >= 11 J9CfrAttributeNestMembers *_nestMembers; #endif /* JAVA_SPEC_VERSION >= 11 */ diff --git a/runtime/bcutil/ROMClassBuilder.cpp b/runtime/bcutil/ROMClassBuilder.cpp index de4b027f93c..7ecc59ece08 100644 --- a/runtime/bcutil/ROMClassBuilder.cpp +++ b/runtime/bcutil/ROMClassBuilder.cpp @@ -1337,14 +1337,14 @@ ROMClassBuilder::computeExtraModifiers(ClassFileOracle *classFileOracle, ROMClas modifiers |= J9AccSealed; } -#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) if (classFileOracle->isImplicitCreationNonAtomic()) { modifiers |= J9AccImplicitCreateNonAtomic; } if (classFileOracle->isImplicitCreationHasDefaultValue()) { modifiers |= J9AccImplicitCreateHasDefaultValue; } -#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ return modifiers; } diff --git a/runtime/bcutil/ROMClassWriter.cpp b/runtime/bcutil/ROMClassWriter.cpp index fe25d6706be..ad8aaf318d1 100644 --- a/runtime/bcutil/ROMClassWriter.cpp +++ b/runtime/bcutil/ROMClassWriter.cpp @@ -651,6 +651,11 @@ ROMClassWriter::writeFields(Cursor *cursor, bool markAndCountOnly) if (iterator.hasTypeAnnotation()) { modifiers |= J9FieldFlagHasTypeAnnotations; } +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) + if (iterator.isNullRestricted()) { + modifiers |= J9FieldFlagIsNullRestricted; + } +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ cursor->writeU32(modifiers, Cursor::GENERIC); } diff --git a/runtime/bcutil/attrlookup.gperf b/runtime/bcutil/attrlookup.gperf index 3343182bf08..24386de5d12 100644 --- a/runtime/bcutil/attrlookup.gperf +++ b/runtime/bcutil/attrlookup.gperf @@ -24,7 +24,10 @@ * This file is the input to the gperf utility for generating a perfect * hash table of attribute names, which is used by attributeTagFor(). * - * To generate attrlookup.h, use the following command-line with gperf 3.0.4: + * Types generated by gperf cause compiler issues in the OpenJ9 Windows builds, + * use the existing types. + * + * To generate attrlookup.h, use the following command-line with the latest version of gperf: * * gperf -CD -t --output-file=attrlookup.h attrlookup.gperf * @@ -74,3 +77,4 @@ Record, CFR_ATTRIBUTE_Record, CFR_ATTRIBUTE_Record PermittedSubclasses, CFR_ATTRIBUTE_PermittedSubclasses, CFR_ATTRIBUTE_PermittedSubclasses ImplicitCreation, CFR_ATTRIBUTE_ImplicitCreation, CFR_ATTRIBUTE_ImplicitCreation Preload, CFR_ATTRIBUTE_Preload, CFR_ATTRIBUTE_Preload +NullRestricted, CFR_ATTRIBUTE_NullRestricted, CFR_ATTRIBUTE_NullRestricted diff --git a/runtime/bcutil/attrlookup.h b/runtime/bcutil/attrlookup.h index fef190bc22a..ff2b0825641 100644 --- a/runtime/bcutil/attrlookup.h +++ b/runtime/bcutil/attrlookup.h @@ -20,7 +20,7 @@ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 *******************************************************************************/ -/* ANSI-C code produced by gperf version 3.0.4 */ +/* ANSI-C code produced by gperf version 3.1 */ /* Command-line: gperf -CD -t --output-file=attrlookup.h attrlookup.gperf */ /* Computed positions: -k'2' */ @@ -48,10 +48,10 @@ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." +#error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif -#line 39 "attrlookup.gperf" +#line 42 "attrlookup.gperf" struct AttribType { const char *name; @@ -59,7 +59,7 @@ struct AttribType U_8 strippedAttribCode; }; -#define TOTAL_KEYWORDS 30 +#define TOTAL_KEYWORDS 31 #define MIN_WORD_LENGTH 4 #define MAX_WORD_LENGTH 36 #define MIN_HASH_VALUE 4 @@ -73,8 +73,8 @@ __inline inline #endif #endif -static unsigned int -attributeHash (register const char *str, register unsigned int len) +static size_t +attributeHash (register const char *str, register size_t len) { static const unsigned char asso_values[] = { @@ -115,85 +115,87 @@ __attribute__ ((__gnu_inline__)) #endif #endif const struct AttribType * -lookupKnownAttribute (register const char *str, register unsigned int len) +lookupKnownAttribute (register const char *str, register size_t len) { static const struct AttribType wordlist[] = { -#line 47 "attrlookup.gperf" +#line 50 "attrlookup.gperf" {"Code", CFR_ATTRIBUTE_Code, CFR_ATTRIBUTE_Code}, -#line 76 "attrlookup.gperf" +#line 79 "attrlookup.gperf" {"Preload", CFR_ATTRIBUTE_Preload, CFR_ATTRIBUTE_Preload}, -#line 49 "attrlookup.gperf" +#line 52 "attrlookup.gperf" {"Synthetic", CFR_ATTRIBUTE_Synthetic, CFR_ATTRIBUTE_Synthetic}, -#line 53 "attrlookup.gperf" +#line 56 "attrlookup.gperf" {"SourceFile", CFR_ATTRIBUTE_SourceFile, CFR_ATTRIBUTE_SourceFile}, -#line 54 "attrlookup.gperf" +#line 57 "attrlookup.gperf" {"InnerClasses", CFR_ATTRIBUTE_InnerClasses, CFR_ATTRIBUTE_InnerClasses}, -#line 55 "attrlookup.gperf" +#line 58 "attrlookup.gperf" {"ConstantValue", CFR_ATTRIBUTE_ConstantValue, CFR_ATTRIBUTE_ConstantValue}, -#line 57 "attrlookup.gperf" +#line 80 "attrlookup.gperf" + {"NullRestricted", CFR_ATTRIBUTE_NullRestricted, CFR_ATTRIBUTE_NullRestricted}, +#line 60 "attrlookup.gperf" {"EnclosingMethod", CFR_ATTRIBUTE_EnclosingMethod, CFR_ATTRIBUTE_EnclosingMethod}, -#line 59 "attrlookup.gperf" +#line 62 "attrlookup.gperf" {"BootstrapMethods", CFR_ATTRIBUTE_BootstrapMethods, CFR_ATTRIBUTE_BootstrapMethods}, -#line 60 "attrlookup.gperf" +#line 63 "attrlookup.gperf" {"AnnotationDefault", CFR_ATTRIBUTE_AnnotationDefault, CFR_ATTRIBUTE_AnnotationDefault}, -#line 61 "attrlookup.gperf" +#line 64 "attrlookup.gperf" {"LocalVariableTable", CFR_ATTRIBUTE_LocalVariableTable, CFR_ATTRIBUTE_StrippedLocalVariableTable}, -#line 62 "attrlookup.gperf" +#line 65 "attrlookup.gperf" {"SourceDebugExtension", CFR_ATTRIBUTE_SourceDebugExtension, CFR_ATTRIBUTE_StrippedSourceDebugExtension}, -#line 75 "attrlookup.gperf" +#line 78 "attrlookup.gperf" {"ImplicitCreation", CFR_ATTRIBUTE_ImplicitCreation, CFR_ATTRIBUTE_ImplicitCreation}, -#line 63 "attrlookup.gperf" +#line 66 "attrlookup.gperf" {"LocalVariableTypeTable", CFR_ATTRIBUTE_LocalVariableTypeTable, CFR_ATTRIBUTE_StrippedLocalVariableTypeTable}, -#line 48 "attrlookup.gperf" +#line 51 "attrlookup.gperf" {"StackMap", CFR_ATTRIBUTE_StackMap, CFR_ATTRIBUTE_StackMap}, -#line 50 "attrlookup.gperf" +#line 53 "attrlookup.gperf" {"Signature", CFR_ATTRIBUTE_Signature, CFR_ATTRIBUTE_Signature}, -#line 64 "attrlookup.gperf" +#line 67 "attrlookup.gperf" {"RuntimeVisibleAnnotations", CFR_ATTRIBUTE_RuntimeVisibleAnnotations, CFR_ATTRIBUTE_RuntimeVisibleAnnotations}, -#line 65 "attrlookup.gperf" +#line 68 "attrlookup.gperf" {"RuntimeInvisibleAnnotations", CFR_ATTRIBUTE_RuntimeInvisibleAnnotations, CFR_ATTRIBUTE_RuntimeInvisibleAnnotations}, -#line 56 "attrlookup.gperf" +#line 59 "attrlookup.gperf" {"StackMapTable", CFR_ATTRIBUTE_StackMapTable, CFR_ATTRIBUTE_StackMapTable}, -#line 66 "attrlookup.gperf" +#line 69 "attrlookup.gperf" {"RuntimeVisibleTypeAnnotations", CFR_ATTRIBUTE_RuntimeVisibleTypeAnnotations, CFR_ATTRIBUTE_RuntimeVisibleTypeAnnotations}, -#line 58 "attrlookup.gperf" +#line 61 "attrlookup.gperf" {"LineNumberTable", CFR_ATTRIBUTE_LineNumberTable, CFR_ATTRIBUTE_StrippedLineNumberTable}, -#line 67 "attrlookup.gperf" +#line 70 "attrlookup.gperf" {"RuntimeInvisibleTypeAnnotations", CFR_ATTRIBUTE_RuntimeInvisibleTypeAnnotations, CFR_ATTRIBUTE_RuntimeInvisibleTypeAnnotations}, -#line 68 "attrlookup.gperf" +#line 71 "attrlookup.gperf" {"RuntimeVisibleParameterAnnotations", CFR_ATTRIBUTE_RuntimeVisibleParameterAnnotations, CFR_ATTRIBUTE_RuntimeVisibleParameterAnnotations}, -#line 52 "attrlookup.gperf" +#line 55 "attrlookup.gperf" {"Exceptions", CFR_ATTRIBUTE_Exceptions, CFR_ATTRIBUTE_Exceptions}, -#line 69 "attrlookup.gperf" +#line 72 "attrlookup.gperf" {"RuntimeInvisibleParameterAnnotations", CFR_ATTRIBUTE_RuntimeInvisibleParameterAnnotations, CFR_ATTRIBUTE_RuntimeInvisibleParameterAnnotations}, -#line 73 "attrlookup.gperf" +#line 76 "attrlookup.gperf" {"Record", CFR_ATTRIBUTE_Record, CFR_ATTRIBUTE_Record}, -#line 72 "attrlookup.gperf" +#line 75 "attrlookup.gperf" {"NestHost", CFR_ATTRIBUTE_NestHost, CFR_ATTRIBUTE_NestHost}, -#line 51 "attrlookup.gperf" +#line 54 "attrlookup.gperf" {"Deprecated", CFR_ATTRIBUTE_Deprecated, CFR_ATTRIBUTE_Deprecated}, -#line 71 "attrlookup.gperf" +#line 74 "attrlookup.gperf" {"NestMembers", CFR_ATTRIBUTE_NestMembers, CFR_ATTRIBUTE_NestMembers}, -#line 70 "attrlookup.gperf" +#line 73 "attrlookup.gperf" {"MethodParameters", CFR_ATTRIBUTE_MethodParameters, CFR_ATTRIBUTE_MethodParameters}, -#line 74 "attrlookup.gperf" +#line 77 "attrlookup.gperf" {"PermittedSubclasses", CFR_ATTRIBUTE_PermittedSubclasses, CFR_ATTRIBUTE_PermittedSubclasses} }; static const signed char lookup[] = { -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, 3, -1, 4, 5, - -1, 6, 7, 8, 9, -1, 10, 11, 12, 13, 14, 15, -1, 16, - 17, 18, 19, 20, -1, -1, 21, 22, 23, 24, -1, 25, -1, 26, - 27, -1, -1, -1, -1, 28, -1, -1, 29 + 6, 7, 8, 9, 10, -1, 11, 12, 13, 14, 15, 16, -1, 17, + 18, 19, 20, 21, -1, -1, 22, 23, 24, 25, -1, 26, -1, 27, + 28, -1, -1, -1, -1, 29, -1, -1, 30 }; if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { - register int key = attributeHash (str, len); + register size_t key = attributeHash (str, len); - if (key <= MAX_HASH_VALUE && key >= 0) + if (key <= MAX_HASH_VALUE) { register int index = lookup[key]; diff --git a/runtime/bcutil/cfreader.c b/runtime/bcutil/cfreader.c index 3262460c04b..c4b4e43bff0 100644 --- a/runtime/bcutil/cfreader.c +++ b/runtime/bcutil/cfreader.c @@ -110,7 +110,7 @@ utf8Equal(J9CfrConstantPoolInfo* utf8, char* string, UDATA length) static U_8 attributeTagFor(J9CfrConstantPoolInfo *utf8, BOOLEAN stripDebugAttributes) { - const struct AttribType *attribType = lookupKnownAttribute((const char *)utf8->bytes, (unsigned int)utf8->slot1); + const struct AttribType *attribType = lookupKnownAttribute((const char *)utf8->bytes, (size_t)utf8->slot1); if (NULL != attribType) { return (stripDebugAttributes ? attribType->strippedAttribCode : attribType->attribCode); @@ -148,8 +148,10 @@ readAttributes(J9CfrClassFile * classfile, J9CfrAttribute *** pAttributes, U_32 J9CfrAttributePermittedSubclasses *permittedSubclasses; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) J9CfrAttributePreload *preload; - J9CfrAttributeImplicitCreation *implicitCreation; #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) + J9CfrAttributeImplicitCreation *implicitCreation; +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ #if JAVA_SPEC_VERSION >= 11 J9CfrAttributeNestHost *nestHost; J9CfrAttributeNestMembers *nestMembers; @@ -174,8 +176,11 @@ readAttributes(J9CfrClassFile * classfile, J9CfrAttribute *** pAttributes, U_32 BOOLEAN permittedSubclassesAttributeRead = FALSE; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) BOOLEAN preloadAttributeRead = FALSE; - BOOLEAN implicitCreationAttributeRead = FALSE; #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) + BOOLEAN implicitCreationAttributeRead = FALSE; + BOOLEAN nullRestrictedAttributeRead = FALSE; +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ #if JAVA_SPEC_VERSION >= 11 BOOLEAN nestAttributeRead = FALSE; #endif /* JAVA_SPEC_VERSION >= 11 */ @@ -953,7 +958,8 @@ readAttributes(J9CfrClassFile * classfile, J9CfrAttribute *** pAttributes, U_32 NEXT_U16(preload->classes[j], index); } break; - +#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) case CFR_ATTRIBUTE_ImplicitCreation: /* JVMS: There may be at most one ImplicitCreation attribute in the attributes table of a ClassFile structure... */ if (implicitCreationAttributeRead) { @@ -972,7 +978,23 @@ readAttributes(J9CfrClassFile * classfile, J9CfrAttribute *** pAttributes, U_32 NEXT_U16(implicitCreation->implicitCreationFlags, index); break; -#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ + case CFR_ATTRIBUTE_NullRestricted: + /* JVMS: There must be no more than one NullRestricted attribute in the attributes table of a field_info structure */ + if (nullRestrictedAttributeRead) { + errorCode = J9NLS_CFR_ERR_MULTIPLE_NULLRESTRICTED_ATTRIBUTES__ID; + offset = address; + goto _errorFound; + } + nullRestrictedAttributeRead = TRUE; + + if (!ALLOC_CAST(attrib, J9CfrAttributeNullRestricted, J9CfrAttribute)) { + return -2; + } + if (length != 0) { + errorCode = J9NLS_CFR_ERR_NULLRESTRICTED_ATTRIBUTES_LENGTH_IS_ZERO__ID; + } + break; +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ #if JAVA_SPEC_VERSION >= 11 case CFR_ATTRIBUTE_NestHost: @@ -2607,7 +2629,8 @@ checkAttributes(J9PortLibrary* portLib, J9CfrClassFile* classfile, J9CfrAttribut } } break; - +#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) case CFR_ATTRIBUTE_ImplicitCreation: value = ((J9CfrAttributeImplicitCreation*)attrib)->nameIndex; if ((0 == value) || (value >= cpCount)) { @@ -2621,7 +2644,15 @@ checkAttributes(J9PortLibrary* portLib, J9CfrClassFile* classfile, J9CfrAttribut break; } break; -#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ + case CFR_ATTRIBUTE_NullRestricted: + value = ((J9CfrAttributeNullRestricted*)attrib)->nameIndex; + if ((0 == value) || (value >= cpCount)) { + errorCode = J9NLS_CFR_ERR_BAD_INDEX__ID; + goto _errorFound; + break; + } + break; +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ #if JAVA_SPEC_VERSION >= 11 case CFR_ATTRIBUTE_NestHost: diff --git a/runtime/nls/cfre/cfrerr.nls b/runtime/nls/cfre/cfrerr.nls index 1758088f463..64da2e506f3 100644 --- a/runtime/nls/cfre/cfrerr.nls +++ b/runtime/nls/cfre/cfrerr.nls @@ -1734,3 +1734,19 @@ J9NLS_CFR_ERR_IMPLICITCREATION_NAME_NOT_UTF8.explanation=Please consult the Java J9NLS_CFR_ERR_IMPLICITCREATION_NAME_NOT_UTF8.system_action=The JVM will throw a verification or classloading related exception such as java.lang.ClassFormatError. J9NLS_CFR_ERR_IMPLICITCREATION_NAME_NOT_UTF8.user_response=Contact the provider of the classfile for a corrected version. # END NON-TRANSLATABLE + +# NullRestricted is not translatable +J9NLS_CFR_ERR_MULTIPLE_NULLRESTRICTED_ATTRIBUTES=Multiple NullRestricted attributes present +# START NON-TRANSLATABLE +J9NLS_CFR_ERR_MULTIPLE_NULLRESTRICTED_ATTRIBUTES.explanation=Please consult the Java Virtual Machine Specification for a detailed explanation. +J9NLS_CFR_ERR_MULTIPLE_NULLRESTRICTED_ATTRIBUTES.system_action=The JVM will throw a verification or classloading related exception such as java.lang.ClassFormatError. +J9NLS_CFR_ERR_MULTIPLE_NULLRESTRICTED_ATTRIBUTES.user_response=Contact the provider of the classfile for a corrected version. +# END NON-TRANSLATABLE + +# NullRestricted is not translatable +J9NLS_CFR_ERR_NULLRESTRICTED_ATTRIBUTES_LENGTH_IS_ZERO=NullRestricted attribute_length item must be zero +# START NON-TRANSLATABLE +J9NLS_CFR_ERR_NULLRESTRICTED_ATTRIBUTES_LENGTH_IS_ZERO.explanation=Please consult the Java Virtual Machine Specification for a detailed explanation. +J9NLS_CFR_ERR_NULLRESTRICTED_ATTRIBUTES_LENGTH_IS_ZERO.system_action=The JVM will throw a verification or classloading related exception such as java.lang.ClassFormatError. +J9NLS_CFR_ERR_NULLRESTRICTED_ATTRIBUTES_LENGTH_IS_ZERO.user_response=Contact the provider of the classfile for a corrected version. +# END NON-TRANSLATABLE diff --git a/runtime/oti/cfr.h b/runtime/oti/cfr.h index 4b21f34c917..79205e1ce52 100644 --- a/runtime/oti/cfr.h +++ b/runtime/oti/cfr.h @@ -243,6 +243,7 @@ typedef struct J9CfrAttribute { #define CFR_ATTRIBUTE_PermittedSubclasses 28 #define CFR_ATTRIBUTE_Preload 29 #define CFR_ATTRIBUTE_ImplicitCreation 30 +#define CFR_ATTRIBUTE_NullRestricted 31 #define CFR_ATTRIBUTE_StrippedLocalVariableTypeTable 122 #define CFR_ATTRIBUTE_StrippedSourceDebugExtension 123 #define CFR_ATTRIBUTE_StrippedInnerClasses 124 @@ -542,7 +543,8 @@ typedef struct J9CfrAttributePreload { U_16 numberOfClasses; U_16* classes; } J9CfrAttributePreload; - +#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) typedef struct J9CfrAttributeImplicitCreation { U_8 tag; U_16 nameIndex; @@ -551,7 +553,13 @@ typedef struct J9CfrAttributeImplicitCreation { U_16 implicitCreationFlags; } J9CfrAttributeImplicitCreation; -#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ +typedef struct J9CfrAttributeNullRestricted { + U_8 tag; + U_16 nameIndex; + U_32 length; + UDATA romAddress; +} J9CfrAttributeNullRestricted; +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ /* @ddr_namespace: map_to_type=J9CfrConstantPoolInfo */ diff --git a/runtime/oti/j9nonbuilder.h b/runtime/oti/j9nonbuilder.h index 1188fe6b9e7..58f79cd16b1 100644 --- a/runtime/oti/j9nonbuilder.h +++ b/runtime/oti/j9nonbuilder.h @@ -100,7 +100,7 @@ #define J9FieldFlagIsContended 0x10000000 #define J9FieldFlagObject 0x20000 #define J9FieldFlagFlattened 0x1000000 -#define J9FieldFlagUnused_2000000 0x2000000 +#define J9FieldFlagIsNullRestricted 0x2000000 #define J9FieldFlagUnused_4000000 0x4000000 #define J9FieldFlagPutResolved 0x8000000 #define J9FieldFlagResolved 0x80000000 diff --git a/runtime/vm/createramclass.cpp b/runtime/vm/createramclass.cpp index 4081d1ad9de..35bb5d34754 100644 --- a/runtime/vm/createramclass.cpp +++ b/runtime/vm/createramclass.cpp @@ -2300,6 +2300,7 @@ internalCreateRAMClassDone(J9VMThread *vmThread, J9ClassLoader *classLoader, J9C } } +#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) if (J9ROMCLASS_ALLOWS_NON_ATOMIC_CREATION(romClass)) { classFlags |= J9ClassAllowsNonAtomicCreation; } @@ -2307,6 +2308,7 @@ internalCreateRAMClassDone(J9VMThread *vmThread, J9ClassLoader *classLoader, J9C /* J9ClassIsValueType is being reused here intentionally */ classFlags |= J9ClassIsValueType; } +#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */ if (J9ROMCLASS_IS_VALUE(romClass)) { classFlags |= J9ClassIsValueType;