Skip to content

Commit

Permalink
Merge pull request #20875 from dsouzai/aotmhJitserver
Browse files Browse the repository at this point in the history
Add SVM validations for JITServer ResolvedHandle/DynamicMethod APIs
  • Loading branch information
mpirvu authored Jan 2, 2025
2 parents ce391cc + 58b5f4d commit fee2f8a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
60 changes: 56 additions & 4 deletions runtime/compiler/env/j9methodServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,10 +1129,36 @@ TR_ResolvedJ9JITServerMethod::getResolvedHandleMethod(TR::Compilation *comp, I_3
auto ramMethod = std::get<0>(recv);
auto &methodInfo = std::get<1>(recv);
auto &signature = std::get<2>(recv);
auto unresolved = std::get<3>(recv);
auto invokeCacheAppendixNull = std::get<4>(recv);
if (unresolvedInCP)
*unresolvedInCP = std::get<3>(recv);
*unresolvedInCP = unresolved;
if (isInvokeCacheAppendixNull)
*isInvokeCacheAppendixNull = std::get<4>(recv);
*isInvokeCacheAppendixNull = invokeCacheAppendixNull;

#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
if (comp->compileRelocatableCode())
{
if (!unresolved)
{
bool valid =
comp->getSymbolValidationManager()->addHandleMethodFromCPIndex(
ramMethod,
getNonPersistentIdentifier(),
cpIndex,
invokeCacheAppendixNull);

if (!valid)
comp->failCompilation<J9::AOTHasInvokeHandle>("Failed to add validation record for resolved handle method %p", ramMethod);
}
else
{
// Call getMethodFromName to create an SVM record
auto dummyInvoke = _fe->getMethodFromName("java/lang/invoke/MethodHandle", "linkToStatic", "([Ljava/lang/Object;)Ljava/lang/Object;");
TR_ASSERT_FATAL(ramMethod == dummyInvoke, "%p != %p; Unresolved targetMethod not dummyInvoke\n", ramMethod, dummyInvoke);
}
}
#endif // #if defined(J9VM_OPT_OPENJDK_METHODHANDLE)

return static_cast<TR_J9ServerVM *>(_fe)->createResolvedMethodWithSignature(
comp->trMemory(), ramMethod, NULL, (char *)signature.data(), signature.length(), this, methodInfo
Expand Down Expand Up @@ -1198,10 +1224,36 @@ TR_ResolvedJ9JITServerMethod::getResolvedDynamicMethod(TR::Compilation *comp, I_
auto ramMethod = std::get<0>(recv);
auto &methodInfo = std::get<1>(recv);
auto &signature = std::get<2>(recv);
auto unresolved = std::get<3>(recv);
auto invokeCacheAppendixNull = std::get<4>(recv);
if (unresolvedInCP)
*unresolvedInCP = std::get<3>(recv);
*unresolvedInCP = unresolved;
if (isInvokeCacheAppendixNull)
*isInvokeCacheAppendixNull = std::get<4>(recv);
*isInvokeCacheAppendixNull = invokeCacheAppendixNull;

#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
if (comp->compileRelocatableCode())
{
if (!unresolved)
{
bool valid =
comp->getSymbolValidationManager()->addDynamicMethodFromCallsiteIndex(
ramMethod,
getNonPersistentIdentifier(),
callSiteIndex,
invokeCacheAppendixNull);

if (!valid)
comp->failCompilation<J9::AOTHasInvokeHandle>("Failed to add validation record for resolved dynamic method %p", ramMethod);
}
else
{
// Call getMethodFromName to create an SVM record
auto dummyInvoke = _fe->getMethodFromName("java/lang/invoke/MethodHandle", "linkToStatic", "([Ljava/lang/Object;)Ljava/lang/Object;");
TR_ASSERT_FATAL(ramMethod == dummyInvoke, "%p != %p; Unresolved targetMethod not dummyInvoke\n", ramMethod, dummyInvoke);
}
}
#endif // #if defined(J9VM_OPT_OPENJDK_METHODHANDLE)

return static_cast<TR_J9ServerVM *>(_fe)->createResolvedMethodWithSignature(
comp->trMemory(), ramMethod, NULL, (char *)signature.data(), signature.size(), this, methodInfo
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 = 76; // ID: BpR0Syhau116Bh0vAoVr
static const uint16_t MINOR_NUMBER = 77; // ID: J440z7/ZN5+KF233VhGB
static const uint8_t PATCH_NUMBER = 0;
static uint32_t CONFIGURATION_FLAGS;

Expand Down

0 comments on commit fee2f8a

Please sign in to comment.