Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify compile-time static field ref resolution #20847

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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