Skip to content

Remove Implicit creation work - #22975

Merged
hangshao0 merged 1 commit into
eclipse-openj9:masterfrom
AditiS11:implicit_1
Dec 4, 2025
Merged

Remove Implicit creation work#22975
hangshao0 merged 1 commit into
eclipse-openj9:masterfrom
AditiS11:implicit_1

Conversation

@AditiS11

Copy link
Copy Markdown

Related: #22642
Remove the implicit creation work.
Update the ValhallaAttribute tests to follow the new spec.

@theresa-m
theresa-m self-requested a review November 19, 2025 15:01
@theresa-m theresa-m added comp:vm project:valhalla Used to track Project Valhalla related work labels Nov 19, 2025

@theresa-m theresa-m left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass.

}
if (J9ROMClassHelper.hasImplicitCreationAttribute(romClass)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_SRP, cursor, "implicitCreationAttributeSRP");
implicitCreationAttributeDo(U32Pointer.cast(cursor.get()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implicitCreationAttributeDo should also be removed.

rangeValid = callbacks->validateRangeCallback(romClass, cursor, sizeof(J9SRP), userData);
if (rangeValid) {
callbacks->slotCallback(romClass, J9ROM_SRP, cursor, "implicitCreationAttributeSRP", userData);
allSlotsInImplicitCreationAttributeDo(romClass, SRP_PTR_GET(cursor, U_32*), callbacks, userData);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The allSlotsInImplicitCreationAttributeDo method should also be removed.

_isClassValueBased = true;
}
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
if (containsKnownAnnotation(foundAnnotations, LOOSELYCONSISTENTVALUE_ANNOTATION)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove all the references to LOOSELYCONSISTENTVALUE_ANNOTATION as well since we aren't doing anything with it right now.

#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE)) {
U_32 implicitCreationFlags = (U_32)getImplicitCreationFlags(_romClass);
addEntry((void*) &IMPLICITCREATION, 0, CFR_CONSTANT_Utf8);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the IMPLICITCREATION definition in line 71.

ROMClassWriter::writeImplicitCreation(Cursor *cursor, bool markAndCountOnly)
{
if (_classFileOracle->hasImplicitCreation()) {
cursor->mark(_implicitCreationSRPKey);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove _implicitCreationSRPKey from line 327.

@@ -193,8 +193,5 @@
(J9StaticFieldRefStrictInitWritten == ((classAndFlags) & J9StaticFieldRefStrictInitMask))
#endif /* defined(J9VM_OPT_VALHALLA_STRICT_FIELDS) */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the extra space here as well.

#define J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE 0x20000
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
#define J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE 0x40000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing this rename it as UNUSED like the other values below.

Comment thread runtime/nls/j9vm/j9vm.nls
# END NON-TRANSLATABLE

# NullRestricted is not translatable
J9NLS_VM_NULLRESTRICTED_MUST_BE_IN_DEFAULT_IMPLICITCREATION_VALUE_CLASS=An instance field with a NullRestricted attribute must be in a value class with an implicit constructor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't rename NLS messages, create a new one at the end of the file.

U_8 *elementAddress = (U_8*)indexableEffectiveAddress(vmThread, arrayRef, index, J9ARRAYCLASS_GET_STRIDE((J9Class *) arrayClazz));
IDATA elementOffset = (elementAddress - (U_8*)arrayRef);
J9Class *elementClazz = J9GC_J9OBJECT_CLAZZ_THREAD(srcObject, vmThread);
Assert_MM_true(J9_IS_J9CLASS_ALLOW_DEFAULT_VALUE(elementClazz));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing these I think we can at least check that elementClazz is a value class.

Comment thread runtime/vm/classsupport.c
* Don't try to initialize class for null-restricted array creation since
* the regular arrayClass will always be created first.
*/
if (J9_IS_J9CLASS_ALLOW_DEFAULT_VALUE(elementClass)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the comment above this line as well.

@AditiS11
AditiS11 force-pushed the implicit_1 branch 2 times, most recently from d1a364b to 96a5772 Compare November 21, 2025 15:04

@theresa-m theresa-m left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second pass. Please also remove the ImplicitCreationAttribute class in ValhallaUtils.java.

inline
#endif
#endif
static size_t

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the type changes here and line 188.

return len + asso_values[(unsigned char)str[1]];
}

#ifdef __GNUC__

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep this unchanged.

Comment thread runtime/bcutil/cfreader.c
offset = address;
goto _errorFound;
}
implicitCreationAttributeRead = TRUE;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the implicitCreationAttributeRead declaration.

Comment thread runtime/bcutil/cfreader.c
}

#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
if (valueTypeClass) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to remove this?

Comment thread runtime/gc_base/ObjectAccessBarrier.cpp Outdated
IDATA elementOffset = (elementAddress - (U_8*)arrayRef);
J9Class *elementClazz = J9GC_J9OBJECT_CLAZZ_THREAD(srcObject, vmThread);
Assert_MM_true(J9_IS_J9CLASS_ALLOW_DEFAULT_VALUE(elementClazz));
Assert_MM_true(J9_IS_J9CLASS_VALUEBASED(elementClazz));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're looking for J9_IS_J9CLASS_VALUETYPE here. J9_IS_J9CLASS_VALUEBASED refers to the ValueBased annotation.

J9NLS_CFR_ERR_PRELOAD_CLASS_ENTRY_NOT_CLASS_TYPE.user_response=Contact the provider of the classfile for a corrected version.
# END NON-TRANSLATABLE

# ImplicitCreation is not translatable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't remove these, see notes at the top of the file.

Comment thread runtime/nls/j9vm/j9vm.nls
J9NLS_VM_CRIU_RESTORE_RESET_VIRTUALTHREAD_FORKJOINPOOL_PARALLELISM_INVALID_PARALLELISM_OFFSET.user_response=View CRIU documentation to determine how to resolve the exception.
# END NON-TRANSLATABLE

# NullRestricted is not translatable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can't be removed, see notes at the top of the file.

Comment thread runtime/oti/j9nonbuilder.h Outdated
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
#define J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE 0x40000
#define J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE_UNUSED_40000 0x40000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE_UNUSED_40000 -> J9_ROMCLASS_OPTINFO_UNUSED_40000

#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
if (_classFileOracle->hasImplicitCreation()) {
cursor->writeSRP(_implicitCreationSRPKey, Cursor::SRP_TO_GENERIC);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the declaration for _implicitCreationSRPKey as well as the comment SRP to ImplicitCreation attribute in ROMClassWriter.cpp.

/* A class may have no more than one ImplicitCreation attribute. */
@Test(expectedExceptions = java.lang.ClassFormatError.class, expectedExceptionsMessageRegExp = ".*Multiple ImplicitCreation attributes.*")
public static void testMultipleImplicitCreationAttributes() throws Throwable {
ValhallaAttributeGenerator.generateClassWithTwoImplicitCreationAttributes("MultiImplicitCreationAttributes");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the ValhallaAttributeGenerator functions corresponding to the removed tests such as ValhallaAttributeGenerator.generateClassWithTwoImplicitCreationAttributes.

Comment thread runtime/vm/createramclass.cpp Outdated
if (!J9ROMCLASS_IS_VALUE(valueROMClass)
|| J9_ARE_NO_BITS_SET(valueROMClass->optionalFlags, J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE)
|| J9_ARE_NO_BITS_SET(getImplicitCreationFlags(valueROMClass), J9AccImplicitCreateHasDefaultValue)
) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to the same line as the if statement.

if (J9_ARE_ALL_BITS_SET(romClass->optionalFlags, J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE)) {
U_16 implicitCreationFlags = getImplicitCreationFlags(romClass);
if (J9_ARE_ALL_BITS_SET(implicitCreationFlags, J9AccImplicitCreateNonAtomic)) {
classFlags |= J9ClassAllowsNonAtomicCreation;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the definition of J9ClassAllowsNonAtomicCreation and comment referencing it in on line 3363.

@theresa-m theresa-m Nov 21, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove references to J9ClassIsPrimitiveValueType as well while you are here, this is very out of date. Chatting with Aditi and this is staying in for now due to references in the jit.

}
}
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
if (J9_ARE_ALL_BITS_SET(classFlags, J9ClassAllowsInitialDefaultValue)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is still needed to measure classes for flattening. Instead of checking for J9ClassAllowsInitialDefaultValue this should be done for all value classes.

classFlags |= J9ClassAllowsNonAtomicCreation;
}
if (J9_ARE_ALL_BITS_SET(implicitCreationFlags, J9AccImplicitCreateHasDefaultValue)) {
classFlags |= J9ClassAllowsInitialDefaultValue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove other references to J9ClassAllowsInitialDefaultValue in the code base.

Comment thread runtime/vm/classsupport.c Outdated
* the regular arrayClass will always be created first.
*/
if (J9_IS_J9CLASS_ALLOW_DEFAULT_VALUE(elementClass)
if (J9ROMCLASS_IS_VALUE(elementClass->romClass)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually sorry I don't think we need this section at all. Its no longer the case that a value type array will be initialized with default values.

Comment thread runtime/bcutil/attrlookup.h Outdated
__attribute__ ((__gnu_inline__))
#endif
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line does not need to be added.

*
* + J9ClassEnsureHashed (inherited)
* + J9ClassHasOffloadAllowSubtasksNatives
* + J9ClassIsPrimitiveValueType | J9ClassAllowsInitialDefaultValue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave the J9ClassIsPrimitiveValueType since it hasn't been fully removed from the code base.


if (isStatic) {
U_32 fieldModifiers = entry->field->modifiers;
if (J9_ARE_ALL_BITS_SET(fieldModifiers, J9FieldFlagIsNullRestricted)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here can you add back the test testStaticNullRestrictedFieldMustBeInValueClass that was removed in #22922 ? I think I got rid of it too hastily.

#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
) {
if (J9_ARE_ALL_BITS_SET(options, J9_FINDCLASS_FLAG_CLASS_OPTION_NULL_RESTRICTED_ARRAY)) {
ramArrayClass->classFlags |= J9ClassContainsUnflattenedFlattenables;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The J9ClassContainsUnflattenedFlattenables flag will automatically set default values for fields. This flag and the code that uses it will need to be removed as well. I expect this will be another large chunk of work so I suggest doing this in another pull request.

* + J9ClassEnsureHashed (inherited)
* + J9ClassHasOffloadAllowSubtasksNatives
* + J9ClassIsPrimitiveValueType | J9ClassAllowsInitialDefaultValue
* + J9ClassAllowsNonAtomicCreation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace this with Unused instead of removing the line like is done in line 3387.

Comment thread runtime/vm/createramclass.cpp Outdated
classFlags |= J9ClassAllowsInitialDefaultValue;
}
}
UDATA instanceSize = state->ramClass->totalInstanceSize;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest getting rid of this variable and directly adding state->ramClass->totalInstanceSize in the if statement.

@theresa-m
theresa-m requested a review from hangshao0 December 4, 2025 14:21
Comment thread runtime/oti/j9nonbuilder.h Outdated
Comment thread runtime/vm/createramclass.cpp Outdated
Related: eclipse-openj9#22642
Remove the implicit creation work.
Update the tests to follow the new spec.
@hangshao0

Copy link
Copy Markdown
Contributor

Jenkins test sanity.functional,extended plinuxval jdknext

@hangshao0

Copy link
Copy Markdown
Contributor

Jenkins compile amac,win jdk21

@hangshao0

Copy link
Copy Markdown
Contributor

Jenkins test sanity.functional,extended.functional zlinux jdk17

@hangshao0
hangshao0 merged commit 5bfd48a into eclipse-openj9:master Dec 4, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:vm project:valhalla Used to track Project Valhalla related work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants