Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SVM validations for JITServer ResolvedHandle/DynamicMethod APIs #20875

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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