Skip to content

Commit

Permalink
Avoid shared lambda form statics name comparison
Browse files Browse the repository at this point in the history
When lambda form sharing is enabled, distinct lambda forms can end up
with identical names and signatures, since that option causes the
non-deterministic address suffix in their name to be replaced with a
NULL address. Thus, the existing name comparison in
TR_ResolvedJ9JITServerMethod::staticsAreSame() could cause distinct
lambda forms to be identified together inappropriately, leading to
crashes in remotely-compiled code. The new code instead always treats
two lambda forms with identical names as being distinct, relying on the
existing fallback in TR_J9ServerVM::jitStaticsAreSame() to ensure that
equal lambda forms are correctly identified as such.

Signed-off-by: Christian Despres <[email protected]>
  • Loading branch information
cjjdespres committed Dec 16, 2024
1 parent 39acfec commit 2669f1f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions runtime/compiler/env/j9methodServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ TR_ResolvedJ9JITServerMethod::fieldsAreSame(int32_t cpIndex1, TR_ResolvedMethod
bool
TR_ResolvedJ9JITServerMethod::staticsAreSame(int32_t cpIndex1, TR_ResolvedMethod *m2, int32_t cpIndex2, bool &sigSame)
{
if (TR::comp()->compileRelocatableCode())
auto comp = TR::comp();
if (comp->compileRelocatableCode())
// in AOT, this should always return false, because mainline compares class loaders
// with fe->sameClassLoaders, which always returns false for AOT compiles
return false;
Expand Down Expand Up @@ -509,7 +510,16 @@ TR_ResolvedJ9JITServerMethod::staticsAreSame(int32_t cpIndex1, TR_ResolvedMethod
char *declaringClassName2 = serverMethod2->classNameOfFieldOrStatic(cpIndex2, class2Len);

if (class1Len == class2Len && !memcmp(declaringClassName1, declaringClassName2, class1Len))
return true;
{
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
// Lambda form name comparison is unreliable when they are shared, so
// pretend that the name and signature comparison was inconclusive and
// rely on the fallback in TR_J9VM::jitStaticsAreSame().
if (isLambdaFormClassName(declaringClassName1, class1Len, NULL))
return false;
#endif /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */
return true;
}
}
else
{
Expand Down

0 comments on commit 2669f1f

Please sign in to comment.