From 8139bfe381b970e6b27b6ef8473cf02a7b32b6e1 Mon Sep 17 00:00:00 2001 From: Annabelle Huo Date: Fri, 22 Sep 2023 12:33:34 -0400 Subject: [PATCH] Update genAconst_init to check NullRestricted attribute Related: #18170 Signed-off-by: Annabelle Huo --- runtime/compiler/env/J9ClassEnv.cpp | 9 +++++---- runtime/compiler/ilgen/Walker.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/runtime/compiler/env/J9ClassEnv.cpp b/runtime/compiler/env/J9ClassEnv.cpp index d45b434a86a..15e4abccf79 100644 --- a/runtime/compiler/env/J9ClassEnv.cpp +++ b/runtime/compiler/env/J9ClassEnv.cpp @@ -597,9 +597,10 @@ static void addEntryForFieldImpl(TR_VMField *field, TR::TypeLayoutBuilder &tlb, char *fieldName = mergeFieldNames(prefix, prefixLength, field->shape, region, mergedLength); int32_t offset = offsetBase + field->offset + TR::Compiler->om.objectHeaderSizeInBytes(); - bool isVolatile = (field->modifiers & J9AccVolatile) ? true : false; - bool isPrivate = (field->modifiers & J9AccPrivate) ? true : false; - bool isFinal = (field->modifiers & J9AccFinal) ? true : false; + bool isVolatile = J9_ARE_ALL_BITS_SET(field->modifiers, J9AccVolatile); + bool isPrivate = J9_ARE_ALL_BITS_SET(field->modifiers, J9AccPrivate); + bool isFinal = J9_ARE_ALL_BITS_SET(field->modifiers, J9AccFinal); + bool isFieldNullRestricted = J9_ARE_ALL_BITS_SET(field->modifiers, J9FieldFlagIsNullRestricted); int sigLen = strlen(signature); char *fieldSignature = new (region) char[sigLen+1]; @@ -608,7 +609,7 @@ static void addEntryForFieldImpl(TR_VMField *field, TR::TypeLayoutBuilder &tlb, if (trace) traceMsg(comp, "type layout definingClass %p field: %s signature: %s field offset: %d offsetBase %d\n", definingClass, fieldName, fieldSignature, field->offset, offsetBase); - tlb.add(TR::TypeLayoutEntry(dataType, offset, fieldName, isVolatile, isPrivate, isFinal, fieldSignature)); + tlb.add(TR::TypeLayoutEntry(dataType, offset, fieldName, isVolatile, isPrivate, isFinal, isFieldNullRestricted, fieldSignature)); } } diff --git a/runtime/compiler/ilgen/Walker.cpp b/runtime/compiler/ilgen/Walker.cpp index 50522766e36..6e976646bf4 100644 --- a/runtime/compiler/ilgen/Walker.cpp +++ b/runtime/compiler/ilgen/Walker.cpp @@ -6589,12 +6589,15 @@ TR_J9ByteCodeIlGenerator::genAconst_init(TR_OpaqueClassBlock *valueTypeClass, in { if (!TR::Compiler->om.isQDescriptorForValueTypesSupported()) { - TR_ASSERT_FATAL(false, "Support for null-restricted types without Q descriptor is to be implemented!!!"); + isNullRestricted = entry._isNullRestricted; } else if (fieldSignature[0] == 'Q') { isNullRestricted = true; + } + if (isNullRestricted) + { // In non-SVM AOT compilation, cpIndex is required for AOT relocation. // In this case, cpindex is unknown for the field. if (comp()->compileRelocatableCode() && !comp()->getOption(TR_UseSymbolValidationManager)) @@ -6606,7 +6609,7 @@ TR_J9ByteCodeIlGenerator::genAconst_init(TR_OpaqueClassBlock *valueTypeClass, in comp()->getCurrentMethod()); if (comp()->getOption(TR_TraceILGen)) { - traceMsg(comp(), "fieldSignature %s fieldClass %p\n", fieldSignature, fieldClass); + traceMsg(comp(), "isNullRestricted 1 fieldSignature %s fieldClass %p\n", fieldSignature, fieldClass); } // Set cpIndex as -1 since it's unknown for the field class