Skip to content

Commit

Permalink
Merge pull request #20847 from cjjdespres/relo-static-ref-2
Browse files Browse the repository at this point in the history
Modify compile-time static field ref resolution
  • Loading branch information
mpirvu authored Dec 18, 2024
2 parents d7450f0 + 4f4e181 commit 81ec96a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
20 changes: 19 additions & 1 deletion runtime/compiler/runtime/SymbolValidationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,25 @@ TR::SymbolValidationManager::validateStaticClassFromCPRecord(uint16_t classID, u
{
J9Class *beholder = getJ9ClassFromID(beholderID);
J9ConstantPool *beholderCP = J9_CP_FROM_CLASS(beholder);
return validateSymbol(classID, TR_ResolvedJ9Method::getClassOfStaticFromCP(_fej9, beholderCP, cpIndex));
TR_OpaqueClassBlock *clazz = NULL;

if (cpIndex != -1)
{
// VM access is acquired explicitly here to avoid acquiring and releasing
// it several times if the initial getClassOfStaticFromCP() fails.
TR::VMAccessCriticalSection getClassFromConstantPool(_fej9);
clazz = TR_ResolvedJ9Method::getClassOfStaticFromCP(_fej9, beholderCP, cpIndex);
if (!clazz)
{
// This relocation may be early enough that the referenced class is
// loaded but not yet resolved at this index. Try to resolve the field
// and get the class again.
_vmThread->javaVM->internalVMFunctions->resolveStaticFieldRef(_fej9->vmThread(), NULL, beholderCP, cpIndex, J9_RESOLVE_FLAG_JIT_COMPILE_TIME, NULL);
clazz = TR_ResolvedJ9Method::getClassOfStaticFromCP(_fej9, beholderCP, cpIndex);
}
}

return validateSymbol(classID, clazz);
}

bool
Expand Down
8 changes: 0 additions & 8 deletions runtime/jit_vm/ctsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ jitGetClassInClassloaderFromUTF8(J9VMThread *vmStruct, J9ClassLoader *classLoade
}

/**
* This function returns the class associated to a static field ref at a particular cpIndex in a constant pool.
* The class entry will be resolved with resolveStaticFieldRef if it is not already resolved.
*
* @param vmStruct, the current J9VMThread
* @param constantPool, the constant pool that the cpIndex is referring to
* @param fieldIndex, the index of an entry in a constant pool, pointing at a static field ref.
Expand All @@ -98,11 +95,6 @@ jitGetClassOfFieldFromCP(J9VMThread *vmStruct, J9ConstantPool *constantPool, UDA

/* romConstantPool is a J9ROMConstantPoolItem */
ramRefWrapper = ((J9RAMStaticFieldRef*) constantPool) + fieldIndex;

if (!J9RAMSTATICFIELDREF_IS_RESOLVED(ramRefWrapper)) {
vmStruct->javaVM->internalVMFunctions->resolveStaticFieldRef(vmStruct, NULL, constantPool, fieldIndex, J9_RESOLVE_FLAG_JIT_COMPILE_TIME, NULL);
}

if (J9RAMSTATICFIELDREF_IS_RESOLVED(ramRefWrapper)) {
J9Class *classWrapper = J9RAMSTATICFIELDREF_CLASS(ramRefWrapper);
UDATA initStatus = classWrapper->initializeStatus;
Expand Down

0 comments on commit 81ec96a

Please sign in to comment.