Skip to content

Commit

Permalink
Implement flattened storeInstance support
Browse files Browse the repository at this point in the history
Support is implemented by generating a call to the putFlattenableField
runtime helper.

Signed-off-by: Leonardo Banderali <leonardo2718@protonmail.com>
  • Loading branch information
Leonardo2718 committed Sep 9, 2020
1 parent 87d281c commit f4f609f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/compiler/ilgen/J9ByteCodeIlGenerator.hpp
Expand Up @@ -186,7 +186,7 @@ class TR_J9ByteCodeIlGenerator : public TR_IlGenerator, public TR_J9ByteCodeIter
void loadMonitorArg();

void storeInstance(int32_t);
void storeInstance(TR::SymbolReference *symRef);
void storeFlattenableInstanceWithHelper(int32_t);
void storeStatic(int32_t);
void storeAuto(TR::DataType type, int32_t slot, bool isAdjunct = false);
void storeArrayElement(TR::DataType dt){ storeArrayElement(dt, comp()->il.opCodeForIndirectArrayStore(dt)); }
Expand Down
33 changes: 33 additions & 0 deletions runtime/compiler/ilgen/Walker.cpp
Expand Up @@ -6734,6 +6734,20 @@ TR_J9ByteCodeIlGenerator::storeInstance(int32_t cpIndex)
if (_generateWriteBarriersForFieldWatch && comp()->compileRelocatableCode())
comp()->failCompilation<J9::AOTNoSupportForAOTFailure>("NO support for AOT in field watch");

TR_ResolvedJ9Method * owningMethod = static_cast<TR_ResolvedJ9Method*>(_methodSymbol->getResolvedMethod());
if (TR::Compiler->om.areValueTypesEnabled() && owningMethod->isFieldQType(cpIndex))
{
if (!isFieldResolved(comp(), owningMethod, cpIndex, true))
{
abortForUnresolvedValueTypeOp("putfield", "field");
}
else if (owningMethod->isFieldFlattened(comp(), cpIndex, _methodSymbol->isStatic()))
{
storeFlattenableInstanceWithHelper(cpIndex);
return;
}
}

TR::SymbolReference * symRef = symRefTab()->findOrCreateShadowSymbol(_methodSymbol, cpIndex, true);
TR::Symbol * symbol = symRef->getSymbol();
TR::DataType type = symbol->getDataType();
Expand Down Expand Up @@ -6867,6 +6881,25 @@ TR_J9ByteCodeIlGenerator::storeInstance(int32_t cpIndex)
}
}

void
TR_J9ByteCodeIlGenerator::storeFlattenableInstanceWithHelper(int32_t cpIndex)
{
TR::Node * value = pop();
TR::Node * address = pop();
if (!address->isNonNull())
{
auto* nullchk = TR::Node::create(TR::PassThrough, 1, address);
nullchk = genNullCheck(nullchk);
genTreeTop(nullchk);
}
auto* j9ResolvedMethod = static_cast<TR_ResolvedJ9Method *>(_methodSymbol->getResolvedMethod());
auto* ramFieldRef = reinterpret_cast<J9RAMFieldRef*>(j9ResolvedMethod->cp()) + cpIndex;
auto* ramFieldRefNode = TR::Node::aconst(reinterpret_cast<uintptr_t>(ramFieldRef));
auto* helperCallNode = TR::Node::createWithSymRef(TR::acall, 3, 3, value, address, ramFieldRefNode, comp()->getSymRefTab()->findOrCreatePutFlattenableFieldSymbolRef());
handleSideEffect(helperCallNode);
genTreeTop(helperCallNode);
}

void
TR_J9ByteCodeIlGenerator::storeStatic(int32_t cpIndex)
{
Expand Down

0 comments on commit f4f609f

Please sign in to comment.