Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-li-2003 committed Dec 16, 2024
1 parent d369958 commit 0ce7d9c
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 282 deletions.
13 changes: 7 additions & 6 deletions runtime/compiler/control/JITClientCompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2960,9 +2960,10 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
break;
case MessageType::KnownObjectTable_addFieldAddressFromBaseIndex:
{
auto recv = client->getRecvData<TR::KnownObjectTable::Index, intptr_t>();
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;

Expand All @@ -2974,11 +2975,11 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
uintptr_t objectPointer = fe->getReferenceFieldAtAddress(fieldAddress);

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

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

client->write(response, resultIndex, resultPointer);
}
Expand All @@ -2989,15 +2990,15 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
TR::KnownObjectTable::Index baseObjectIndex = std::get<0>(recv);
intptr_t fieldOffset = std::get<1>(recv);

UDATA data = 0;
J9::TransformUtil::value data;

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

uintptr_t fieldAddress = baseObjectAddress + fieldOffset;

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

client->write(response, data);
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 @@ -230,7 +230,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 @@ -256,6 +256,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
Loading

0 comments on commit 0ce7d9c

Please sign in to comment.