Skip to content

Commit

Permalink
Merge pull request #8646 from tajila/vt3
Browse files Browse the repository at this point in the history
Fix bug in resolution of VT arrays and fields
  • Loading branch information
gacholio committed Feb 26, 2020
2 parents 543beb6 + 24ea9c9 commit 596aec5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 22 deletions.
61 changes: 41 additions & 20 deletions runtime/vm/classsupport.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2019 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -197,35 +197,56 @@ findPrimitiveArrayClass(J9JavaVM* vm, jchar sigChar)
J9Class*
internalCreateArrayClass(J9VMThread* vmThread, J9ROMArrayClass* romClass, J9Class* elementClass)
{
J9Class *result;
J9Class *result = NULL;
j9object_t heapClass = J9VM_J9CLASS_TO_HEAPCLASS(elementClass);
j9object_t protectionDomain = NULL;
J9ROMClass* arrayRomClass = (J9ROMClass*) romClass;
J9JavaVM *const javaVM = vmThread->javaVM;
UDATA options = 0;

if (J9_ARE_ANY_BITS_SET(elementClass->classFlags, J9ClassIsAnonymous)) {
options = J9_FINDCLASS_FLAG_ANON;
BOOLEAN elementInitSuccess = TRUE;

#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
/* When creating an array of valuetype elements, the array elements are initialized to the defaultValue of the
* element type. As a result the element type must be fully initialized (if its a valuetype) before creating an
* instance of the array. Element class init must be done before the arrayClass is created so that in the case
* of an init failure the arrayClass is not temporarily exposed.
*/
if (J9_IS_J9CLASS_VALUETYPE(elementClass)) {
UDATA initStatus = elementClass->initializeStatus;
if ((J9ClassInitSucceeded != initStatus) && ((UDATA)vmThread != initStatus)) {
initializeClass(vmThread, elementClass);
if (NULL != vmThread->currentException) {
elementInitSuccess = FALSE;
}
}
}
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */

omrthread_monitor_enter(javaVM->classTableMutex);
if (elementInitSuccess) {
if (J9_ARE_ANY_BITS_SET(elementClass->classFlags, J9ClassIsAnonymous)) {
options = J9_FINDCLASS_FLAG_ANON;
}

omrthread_monitor_enter(javaVM->classTableMutex);

if (NULL != heapClass) {
protectionDomain = J9VMJAVALANGCLASS_PROTECTIONDOMAIN(vmThread, heapClass);
}

if (NULL != heapClass) {
protectionDomain = J9VMJAVALANGCLASS_PROTECTIONDOMAIN(vmThread, heapClass);
result = internalCreateRAMClassFromROMClass(
vmThread,
elementClass->classLoader,
arrayRomClass,
options, /* options */
elementClass,
protectionDomain,
NULL,
J9_CP_INDEX_NONE,
LOAD_LOCATION_UNKNOWN,
NULL,
NULL);
}

result = internalCreateRAMClassFromROMClass(
vmThread,
elementClass->classLoader,
arrayRomClass,
options, /* options */
elementClass,
protectionDomain,
NULL,
J9_CP_INDEX_NONE,
LOAD_LOCATION_UNKNOWN,
NULL,
NULL);
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions runtime/vm/resolvesupport.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2019 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -977,7 +977,7 @@ resolveInstanceFieldRefInto(J9VMThread *vmStruct, J9Method *method, J9ConstantPo
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
if ('Q' == J9UTF8_DATA(signature)[0]) {
if (fccEntryFieldNotSet) {
flattenedClassCache = classFromCP->flattenedClassCache;
flattenedClassCache = definingClass->flattenedClassCache;
fieldIndex = findIndexInFlattenedClassCache(flattenedClassCache, nameAndSig);
flattenableClass = J9_VM_FCC_ENTRY_FROM_FCC(flattenedClassCache, fieldIndex)->clazz;
}
Expand Down

0 comments on commit 596aec5

Please sign in to comment.