Skip to content

Commit

Permalink
Support resolved invokeHandle/invokeDynamic dispatch in SVM AOT
Browse files Browse the repository at this point in the history
Signed-off-by: Irwin D'Souza <[email protected]>
  • Loading branch information
dsouzai committed Nov 6, 2024
1 parent 411f8c0 commit ba441fc
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 5 deletions.
2 changes: 2 additions & 0 deletions runtime/compiler/control/JITClientCompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
// These offsets are initialized later on
vmInfo._vmtargetOffset = 0;
vmInfo._vmindexOffset = 0;
vmInfo._shareLambdaForm
= J9_ARE_ALL_BITS_SET(javaVM->sharedClassConfig->runtimeFlags2, J9SHR_RUNTIMEFLAG2_SHARE_LAMBDAFORM);
#endif /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */
}

Expand Down
24 changes: 24 additions & 0 deletions runtime/compiler/env/j9method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,30 @@ TR_ResolvedRelocatableJ9Method::isUnresolvedMethodHandle(I_32 cpIndex)
return true;
}

bool
TR_ResolvedRelocatableJ9Method::isUnresolvedCallSiteTableEntry(int32_t callSiteIndex)
{
bool unresolved = true;
J9JavaVM * javaVM = fej9()->_jitConfig->javaVM;
if (J9_ARE_ALL_BITS_SET(javaVM->sharedClassConfig->runtimeFlags2, J9SHR_RUNTIMEFLAG2_SHARE_LAMBDAFORM))
{
unresolved = TR_ResolvedJ9Method::isUnresolvedCallSiteTableEntry(callSiteIndex);
}
return unresolved;
}

bool
TR_ResolvedRelocatableJ9Method::isUnresolvedMethodTypeTableEntry(int32_t cpIndex)
{
bool unresolved = true;
J9JavaVM * javaVM = fej9()->_jitConfig->javaVM;
if (J9_ARE_ALL_BITS_SET(javaVM->sharedClassConfig->runtimeFlags2, J9SHR_RUNTIMEFLAG2_SHARE_LAMBDAFORM))
{
unresolved = TR_ResolvedJ9Method::isUnresolvedMethodTypeTableEntry(cpIndex);
}
return unresolved;
}

TR_ResolvedMethod *
TR_ResolvedRelocatableJ9Method::getResolvedPossiblyPrivateVirtualMethod(
TR::Compilation *comp,
Expand Down
4 changes: 2 additions & 2 deletions runtime/compiler/env/j9method.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ class TR_ResolvedRelocatableJ9Method : public TR_ResolvedJ9Method
virtual bool isUnresolvedMethodType(int32_t cpIndex);
virtual void * methodHandleConstant(int32_t cpIndex);
virtual bool isUnresolvedMethodHandle(int32_t cpIndex);
virtual bool isUnresolvedCallSiteTableEntry(int32_t callSiteIndex) { return true; }
virtual bool isUnresolvedMethodTypeTableEntry(int32_t cpIndex) { return true; }
virtual bool isUnresolvedCallSiteTableEntry(int32_t callSiteIndex);
virtual bool isUnresolvedMethodTypeTableEntry(int32_t cpIndex);

virtual bool fieldAttributes ( TR::Compilation *, int32_t cpIndex, uint32_t * fieldOffset, TR::DataType * type, bool * volatileP, bool * isFinal, bool *isPrivate, bool isStore, bool * unresolvedInCP, bool needsAOTValidation);

Expand Down
28 changes: 28 additions & 0 deletions runtime/compiler/env/j9methodServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,34 @@ TR_ResolvedRelocatableJ9JITServerMethod::isUnresolvedMethodHandle(I_32 cpIndex)
return true;
}

bool
TR_ResolvedRelocatableJ9JITServerMethod::isUnresolvedMethodTypeTableEntry(int32_t cpIndex)
{
bool unresolved = true;
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
auto *vmInfo = _fe->_compInfoPT->getClientData()->getOrCacheVMInfo(_stream);
if (vmInfo->_shareLambdaForm)
{
unresolved = TR_ResolvedJ9JITServerMethod::isUnresolvedMethodTypeTableEntry(cpIndex);
}
#endif // defined(J9VM_OPT_OPENJDK_METHODHANDLE)
return unresolved;
}

bool
TR_ResolvedRelocatableJ9JITServerMethod::isUnresolvedCallSiteTableEntry(int32_t callSiteIndex)
{
bool unresolved = true;
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
auto *vmInfo = _fe->_compInfoPT->getClientData()->getOrCacheVMInfo(_stream);
if (vmInfo->_shareLambdaForm)
{
unresolved = TR_ResolvedJ9JITServerMethod::isUnresolvedCallSiteTableEntry(callSiteIndex);
}
#endif // defined(J9VM_OPT_OPENJDK_METHODHANDLE)
return unresolved;
}

TR_OpaqueClassBlock *
TR_ResolvedRelocatableJ9JITServerMethod::getDeclaringClassFromFieldOrStatic(TR::Compilation *comp, int32_t cpIndex)
{
Expand Down
4 changes: 2 additions & 2 deletions runtime/compiler/env/j9methodServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ class TR_ResolvedRelocatableJ9JITServerMethod : public TR_ResolvedJ9JITServerMet
virtual bool isUnresolvedMethodType(int32_t cpIndex) override;
virtual void * methodHandleConstant(int32_t cpIndex) override;
virtual bool isUnresolvedMethodHandle(int32_t cpIndex) override;
virtual bool isUnresolvedMethodTypeTableEntry(int32_t cpIndex) override { return true; }
virtual bool isUnresolvedCallSiteTableEntry(int32_t callSiteIndex) override { return true; }
virtual bool isUnresolvedMethodTypeTableEntry(int32_t cpIndex) override;
virtual bool isUnresolvedCallSiteTableEntry(int32_t callSiteIndex) override;
virtual TR_OpaqueClassBlock * classOfStatic(int32_t cpIndex, bool returnClassForAOT = false) override;
virtual TR_ResolvedMethod * getResolvedPossiblyPrivateVirtualMethod(TR::Compilation *, int32_t cpIndex, bool ignoreRtResolve, bool * unresolvedInCP) override;
virtual bool getUnresolvedFieldInCP(I_32 cpIndex) 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 @@ -128,7 +128,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 = 70; // ID:5nbb7nhW+R7OABuv+aRm
static const uint16_t MINOR_NUMBER = 71; // ID:1QMsN16q0acJzn1qRQHY
static const uint8_t PATCH_NUMBER = 0;
static uint32_t CONFIGURATION_FLAGS;

Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/runtime/JITClientSession.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ class ClientSessionData
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
UDATA _vmtargetOffset;
UDATA _vmindexOffset;
bool _shareLambdaForm;
#endif /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */
bool _useAOTCache;
// Should we use server offsets (idAndType of AOT cache serialization records) instead of
Expand Down

0 comments on commit ba441fc

Please sign in to comment.