Skip to content

Commit

Permalink
TransformIndirectLoadChain at JITServer
Browse files Browse the repository at this point in the history
Implement TransformIndirectLoadChain partially for the JITServer
so it can employ the Vector API during optimization.

Signed-off-by: Luke Li <[email protected]>
  • Loading branch information
luke-li-2003 committed Dec 18, 2024
1 parent 85b9c02 commit 3a7a696
Show file tree
Hide file tree
Showing 9 changed files with 341 additions and 58 deletions.
46 changes: 46 additions & 0 deletions runtime/compiler/control/JITClientCompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2958,6 +2958,52 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
client->write(response, vectorBitSize);
}
break;
case MessageType::KnownObjectTable_addFieldAddressFromBaseIndex:
{
auto recv = client->getRecvData<TR::KnownObjectTable::Index, intptr_t, bool>();
TR::KnownObjectTable::Index baseObjectIndex = std::get<0>(recv);
intptr_t fieldOffset = std::get<1>(recv);
bool isArrayWithConstantElements = std::get<2>(recv);

TR::KnownObjectTable::Index resultIndex = TR::KnownObjectTable::UNKNOWN;

{
TR::VMAccessCriticalSection addFieldAddressFromBaseIndex(fe);
uintptr_t baseObjectAddress = knot->getPointer(baseObjectIndex);
uintptr_t fieldAddress = baseObjectAddress + fieldOffset;

uintptr_t objectPointer = fe->getReferenceFieldAtAddress(fieldAddress);

if (objectPointer)
resultIndex = knot->getOrCreateIndexAt(&objectPointer, isArrayWithConstantElements);
}

uintptr_t *resultPointer = (resultIndex == TR::KnownObjectTable::UNKNOWN) ?
NULL : knot->getPointerLocation(resultIndex);

client->write(response, resultIndex, resultPointer);
}
break;
case MessageType::KnownObjectTable_getFieldAddressData:
{
auto recv = client->getRecvData<TR::KnownObjectTable::Index, intptr_t>();
TR::KnownObjectTable::Index baseObjectIndex = std::get<0>(recv);
intptr_t fieldOffset = std::get<1>(recv);

J9::TransformUtil::value data;

{
TR::VMAccessCriticalSection addFieldAddressFromBaseIndex(fe);
uintptr_t baseObjectAddress = knot->getPointer(baseObjectIndex);

uintptr_t fieldAddress = baseObjectAddress + fieldOffset;

data = *(J9::TransformUtil::value *) fieldAddress;
}

client->write(response, data);
}
break;
case MessageType::AOTCache_getROMClassBatch:
{
auto recv = client->getRecvData<std::vector<J9Class *>>();
Expand Down
5 changes: 4 additions & 1 deletion runtime/compiler/env/J9KnownObjectTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ J9::KnownObjectTable::getPointerLocation(Index index)

#if defined(J9VM_OPT_JITSERVER)
void
J9::KnownObjectTable::updateKnownObjectTableAtServer(Index index, uintptr_t *objectReferenceLocationClient)
J9::KnownObjectTable::updateKnownObjectTableAtServer(Index index, uintptr_t *objectReferenceLocationClient, bool isArrayWithConstantElements)
{
TR_ASSERT_FATAL(self()->comp()->isOutOfProcessCompilation(), "updateKnownObjectTableAtServer should only be called at the server");
if (index == TR::KnownObjectTable::UNKNOWN)
Expand All @@ -257,6 +257,9 @@ J9::KnownObjectTable::updateKnownObjectTableAtServer(Index index, uintptr_t *obj
{
TR_ASSERT_FATAL(false, "index %d from the client is greater than the KOT nextIndex %d at the server", index, nextIndex);
}

if (isArrayWithConstantElements)
addArrayWithConstantElements(index);
}
#endif /* defined(J9VM_OPT_JITSERVER) */

Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/env/J9KnownObjectTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class OMR_EXTENSIBLE KnownObjectTable : public OMR::KnownObjectTableConnector
uintptr_t getPointer(Index index);

#if defined(J9VM_OPT_JITSERVER)
void updateKnownObjectTableAtServer(Index index, uintptr_t *objectReferenceLocationClient);
void updateKnownObjectTableAtServer(Index index, uintptr_t *objectReferenceLocationClient, bool isArrayWithConstantElements = false);
void getKnownObjectTableDumpInfo(std::vector<TR_KnownObjectTableDumpInfo> &knotDumpInfoList);
#endif /* defined(J9VM_OPT_JITSERVER) */

Expand Down
3 changes: 2 additions & 1 deletion runtime/compiler/env/VMJ9Server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ class TR_J9ServerVM: public TR_J9VM
virtual intptr_t getVFTEntry(TR_OpaqueClassBlock *clazz, int32_t offset) override;
virtual bool isClassArray(TR_OpaqueClassBlock *klass) override;
virtual uintptr_t getFieldOffset(TR::Compilation * comp, TR::SymbolReference* classRef, TR::SymbolReference* fieldRef) override { return 0; } // safe answer
virtual bool canDereferenceAtCompileTime(TR::SymbolReference *fieldRef, TR::Compilation *comp) override { return false; } // safe answer, might change in the future
// The base version should be safe, no need to override.
// virtual bool canDereferenceAtCompileTime(TR::SymbolReference *fieldRef, TR::Compilation *comp) override; // safe answer, might change in the future
virtual bool instanceOfOrCheckCast(J9Class *instanceClass, J9Class* castClass) override;
virtual bool instanceOfOrCheckCastNoCacheUpdate(J9Class *instanceClass, J9Class* castClass) override;
virtual bool transformJlrMethodInvoke(J9Method *callerMethod, J9Class *callerClass) override;
Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/net/CommunicationStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class CommunicationStream
// likely to lose an increment when merging/rebasing/etc.
//
static const uint8_t MAJOR_NUMBER = 1;
static const uint16_t MINOR_NUMBER = 75; // ID: kzkyjklaOnYjEzzJyIl7
static const uint16_t MINOR_NUMBER = 76; // ID: BpR0Syhau116Bh0vAoVr
static const uint8_t PATCH_NUMBER = 0;
static uint32_t CONFIGURATION_FLAGS;

Expand Down
2 changes: 2 additions & 0 deletions runtime/compiler/net/MessageTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ const char *messageNames[] =
"KnownObjectTable_getKnownObjectTableDumpInfo",
"KnownObjectTable_getOpaqueClass",
"KnownObjectTable_getVectorBitSize",
"KnownObjectTable_addFieldAddressFromBaseIndex",
"KnownObjectTable_getFieldAddressData",
"AOTCache_getROMClassBatch",
"AOTCacheMap_request",
"AOTCacheMap_reply"
Expand Down
3 changes: 3 additions & 0 deletions runtime/compiler/net/MessageTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ enum MessageType : uint16_t
KnownObjectTable_getOpaqueClass,
// for getting a vectorBitSize from KnownObjectTable
KnownObjectTable_getVectorBitSize,
// used with J9TransformUtil
KnownObjectTable_addFieldAddressFromBaseIndex,
KnownObjectTable_getFieldAddressData,

AOTCache_getROMClassBatch,

Expand Down
Loading

0 comments on commit 3a7a696

Please sign in to comment.