Skip to content

Commit 4fdd83e

Browse files
committed
Fix init sequence for flattened fields
In cases where a flattened field is contained in an identitytype, there is a bug where the flattenedfield is not being initialized before the container type is initialized. This is because there is an unneccesary valuetype guard before that code. Since identitytypes can have flattened fields, identity type must also ensure that all flattened fields are initialized before itself. The flattenedclass cache will be non-NULL if the type is a valuetype or the type has at least one flattened field. This means that one simply needs to check if the flattenedClass cache is non-NULL before initializing flattened fields. Signed-off-by: Tobi Ajila <atobia@ca.ibm.com>
1 parent 181fabe commit 4fdd83e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

runtime/vm/ClassInitialization.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ classInitStateMachine(J9VMThread *currentThread, J9Class *clazz, J9ClassInitStat
374374

375375
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
376376
/* verify flattened fields */
377-
if (J9_IS_J9CLASS_VALUETYPE(clazz)) {
377+
if (NULL != clazz->flattenedClassCache) {
378378
UDATA numberOfFlattenedFields = clazz->flattenedClassCache->numberOfEntries;
379379

380380
for (UDATA i = 0; i < numberOfFlattenedFields; i++) {
@@ -494,7 +494,7 @@ classInitStateMachine(J9VMThread *currentThread, J9Class *clazz, J9ClassInitStat
494494

495495
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
496496
/* prepare flattened fields */
497-
if (J9_IS_J9CLASS_VALUETYPE(clazz)) {
497+
if (NULL != clazz->flattenedClassCache) {
498498
UDATA numberOfFlattenedFields = clazz->flattenedClassCache->numberOfEntries;
499499

500500
for (UDATA i = 0; i < numberOfFlattenedFields; i++) {
@@ -611,7 +611,7 @@ classInitStateMachine(J9VMThread *currentThread, J9Class *clazz, J9ClassInitStat
611611

612612
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
613613
/* init flattened fields */
614-
if (J9_IS_J9CLASS_VALUETYPE(clazz)) {
614+
if (NULL != clazz->flattenedClassCache) {
615615
UDATA numberOfFlattenedFields = clazz->flattenedClassCache->numberOfEntries;
616616

617617
for (UDATA i = 0; i < numberOfFlattenedFields; i++) {

0 commit comments

Comments
 (0)