From ba441fcd37b2282d8ec946f06727f0a82f815ce1 Mon Sep 17 00:00:00 2001 From: Irwin D'Souza Date: Tue, 5 Nov 2024 13:09:12 -0500 Subject: [PATCH] Support resolved invokeHandle/invokeDynamic dispatch in SVM AOT Signed-off-by: Irwin D'Souza --- .../control/JITClientCompilationThread.cpp | 2 ++ runtime/compiler/env/j9method.cpp | 24 ++++++++++++++++ runtime/compiler/env/j9method.h | 4 +-- runtime/compiler/env/j9methodServer.cpp | 28 +++++++++++++++++++ runtime/compiler/env/j9methodServer.hpp | 4 +-- runtime/compiler/net/CommunicationStream.hpp | 2 +- runtime/compiler/runtime/JITClientSession.hpp | 1 + 7 files changed, 60 insertions(+), 5 deletions(-) diff --git a/runtime/compiler/control/JITClientCompilationThread.cpp b/runtime/compiler/control/JITClientCompilationThread.cpp index d8bd9a846d7..70ced258a37 100644 --- a/runtime/compiler/control/JITClientCompilationThread.cpp +++ b/runtime/compiler/control/JITClientCompilationThread.cpp @@ -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) */ } diff --git a/runtime/compiler/env/j9method.cpp b/runtime/compiler/env/j9method.cpp index 9906bb4dc7c..59971b208f8 100644 --- a/runtime/compiler/env/j9method.cpp +++ b/runtime/compiler/env/j9method.cpp @@ -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, diff --git a/runtime/compiler/env/j9method.h b/runtime/compiler/env/j9method.h index 6631718bcb1..2e7987922c8 100644 --- a/runtime/compiler/env/j9method.h +++ b/runtime/compiler/env/j9method.h @@ -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); diff --git a/runtime/compiler/env/j9methodServer.cpp b/runtime/compiler/env/j9methodServer.cpp index 8f4b856c2e8..7fb487b4306 100644 --- a/runtime/compiler/env/j9methodServer.cpp +++ b/runtime/compiler/env/j9methodServer.cpp @@ -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) { diff --git a/runtime/compiler/env/j9methodServer.hpp b/runtime/compiler/env/j9methodServer.hpp index edd980d2e65..95adc56b360 100644 --- a/runtime/compiler/env/j9methodServer.hpp +++ b/runtime/compiler/env/j9methodServer.hpp @@ -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; diff --git a/runtime/compiler/net/CommunicationStream.hpp b/runtime/compiler/net/CommunicationStream.hpp index ae5b4a056eb..afbcaf2ef70 100644 --- a/runtime/compiler/net/CommunicationStream.hpp +++ b/runtime/compiler/net/CommunicationStream.hpp @@ -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; diff --git a/runtime/compiler/runtime/JITClientSession.hpp b/runtime/compiler/runtime/JITClientSession.hpp index 4d0e8c6cff7..dbcc1d72e44 100644 --- a/runtime/compiler/runtime/JITClientSession.hpp +++ b/runtime/compiler/runtime/JITClientSession.hpp @@ -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