Skip to content

Commit

Permalink
Stop setting known object index in findOrCreateStaticSymbol()
Browse files Browse the repository at this point in the history
SymbolReferenceTable::findOrCreateStaticSymbol() is used only when
generating IL for putstatic and getstatic.

For putstatic, if it attempts to store to a static final field, it's
very likely that the store is illegal, in which case it will be treated
as unresolved. But even if the store is legal, the known object index is
useless.

For getstatic, the IL generator will use foldReliableStaticFinalField()
from TransformUtil to get the same effect anyway, so setting the known
object index here is redundant.
  • Loading branch information
jdmpapin committed Jan 24, 2025
1 parent 4f87f3f commit 23757db
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions runtime/compiler/compile/J9SymbolReferenceTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1940,29 +1940,7 @@ J9::SymbolReferenceTable::findOrCreateStaticSymbol(TR::ResolvedMethodSymbol * ow
if (sharesSymbol)
symRef->setReallySharesSymbol();

TR::KnownObjectTable::Index knownObjectIndex = TR::KnownObjectTable::UNKNOWN;
if (resolved && isFinal && type == TR::Address)
{
TR_OpaqueClassBlock *declaringClass =
owningMethod->getDeclaringClassFromFieldOrStatic(comp(), cpIndex);

TR::Symbol::RecognizedField recField = sym->getRecognizedField();
TR_YesNoMaybe canFold =
TR::TransformUtil::canFoldStaticFinalField(
comp(), declaringClass, recField, owningMethod, cpIndex);

if (canFold == TR_yes)
{
TR::AnyConst value = TR::AnyConst::makeAddress(0);
bool gotValue = TR::TransformUtil::staticFinalFieldValue(
comp(), owningMethod, cpIndex, dataAddress, TR::Address, recField, &value);

if (gotValue && value.isKnownObject())
knownObjectIndex = value.getKnownObjectIndex();
}
}

symRef = new (trHeapMemory()) TR::SymbolReference(self(), sym, owningMethodSymbol->getResolvedMethodIndex(), cpIndex, unresolvedIndex, knownObjectIndex);
symRef = new (trHeapMemory()) TR::SymbolReference(self(), sym, owningMethodSymbol->getResolvedMethodIndex(), cpIndex, unresolvedIndex, TR::KnownObjectTable::UNKNOWN);

checkUserField(symRef);

Expand Down

0 comments on commit 23757db

Please sign in to comment.