-
Notifications
You must be signed in to change notification settings - Fork 737
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
Inline SegmentViewVarHandle operations in JDK21+ #20146
Conversation
@jdmpapin I'd appreciate your review for these changes. |
@0xdaryl : tagging myself |
5c8b2b9
to
27c988f
Compare
Skipping windows to avoid stressing the single available build machine. These changes are all platform-agnostic. JDK17 is there to build and test without Jenkins test sanity.functional,sanity.openjdk alinux64,plinux,xlinux,zlinux,aix,xmac,amac jdk17,jdk21,jdk23 |
Most of the failures are known issues:
but the JDK21 sanity.openjdk failures were assertion failures in
which is here:
As part of some in-progress work on --- a/runtime/compiler/optimizer/InterpreterEmulator.cpp
+++ b/runtime/compiler/optimizer/InterpreterEmulator.cpp
@@ -922,7 +1170,7 @@ InterpreterEmulator::maintainStackForCall()
{
assertHasState();
- int32_t numOfArgs = 0;
+ int32_t numOfArgs = -1;
TR::DataType returnType = TR::NoType;
Operand* result = NULL;
@@ -960,18 +1208,47 @@ InterpreterEmulator::maintainStackForCall()
case J9BCinvokestatic:
isStatic = true;
break;
+
case J9BCinvokedynamic:
- case J9BCinvokehandle:
- TR_ASSERT_FATAL(false, "Can't maintain stack for unresolved invokehandle");
+ {
+ // Find the signature, which corresponds to the arguments on the stack.
+ // cpIndex is really the invokedynamic call site index
+ J9ROMClass *romClass = TR::Compiler->cls.romClassOf(method()->classOfMethod());
+ J9SRP *namesAndSigs = (J9SRP*)J9ROMCLASS_CALLSITEDATA(romClass);
+ J9ROMNameAndSignature *nameAndSig = NNSRP_GET(namesAndSigs[cpIndex], J9ROMNameAndSignature*);
+ J9UTF8 *sig = J9ROMNAMEANDSIGNATURE_SIGNATURE(nameAndSig);
+
+ // Parse the signature to determine the number of arguments and
+ // whether or not there is a return value.
+ U_8 sigTypes[256]; // signatures are limited to 255 params + 1 return type
+ UDATA numParams = 0;
+ UDATA numParamSlots = 0;
+ jitParseSignature(sig, sigTypes, &numParams, &numParamSlots);
+ numOfArgs = numParams;
+
+ // returnType is only used to distinguish void return (TR::NoType)
+ // from non-void return (any other value), so it's not necessary to
+ // get the correct non-void type here.
+ if (sigTypes[numParams] == J9_NATIVE_TYPE_VOID)
+ returnType = TR::NoType;
+ else
+ returnType = TR::Int32;
+
break;
+ }
default:
break;
}
- TR::Method * calleeMethod = comp()->fej9()->createMethod(trMemory(), _calltarget->_calleeMethod->containingClass(), cpIndex);
- numOfArgs = calleeMethod->numberOfExplicitParameters() + (isStatic ? 0 : 1);
- returnType = calleeMethod->returnType();
+
+ if (numOfArgs < 0)
+ {
+ TR::Method * calleeMethod = comp()->fej9()->createMethod(trMemory(), _calltarget->_calleeMethod->containingClass(), cpIndex);
+ numOfArgs = calleeMethod->numberOfExplicitParameters() + (isStatic ? 0 : 1);
+ returnType = calleeMethod->returnType();
+ }
}
+
maintainStackForCall(result, numOfArgs, returnType);
}
|
27c988f
to
54d2766
Compare
The changes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed and approve the changes to InterpreterEmulator.cpp.
Jenkins test sanity.functional,sanity.openjdk alinux64,plinux,xlinux,zlinux,aix,xmac,amac jdk17,jdk21,jdk23 |
In TR_ResolvedJ9Method::getResolvedInterfaceMethod, if the the class of the interface method is an interface class, then the resulting resolved method was just discarded, as the interface class was not expected to contain any interface method implementation prior to default interface methods being introduced in Java 8. This change removes the condition ensuring that the interface methods are not inside an interface class, enabling this function to obtain resolved interface methods that are default implementations. Signed-off-by: Nazim Bhuiyan <[email protected]>
NPH was being asked if peeking is necessary right after init, prior to any of the bytecode iteration was taking place, following which NPH.doPeeking() could return true. This meant that NPH was not having any impact on whether any peeking took place, whether the heuristics determined it being useful or not. This commit reorders the processBytecodeAndGenerateCFG phase of ECS to take place prior to the step checking whether peeking is necessary, so that if and when peeking is necessary, NPH can utilized to trigger ILGen with the new function setNeedsPeekingToTrue(). Previously, _needsPeeking was set to true if there was a param load within distance, which is now disabled so as not to modify the ECS behaviour where NPH was not having any impact on peeking. Only by explicitly using NPH.setNeedsPeekingToTrue() can peeking be triggered. Signed-off-by: Nazim Bhuiyan <[email protected]>
This changeset enables inlining of SegmentViewVarHandle operations that have been introduced in JDK21 through the following: * Add recognized method info for ValueLayouts$AbstractValueLayout.accessHandle and MemorySegment methods. * Add VM API getLayoutVarHandle to obtain the layout VH object info * Add getReturnValue handler in InterpreterEmulator to evaluate the result of accessHandle() * During ECS, set NeedsPeekingHeuristics to true for the caller of MemorySegment methods so that the final field loads in the caller that are relevant for obtaining the layout VH can be folded. * ECS now sets MemorySegment methods to iterate with state in the InterpreterEmulator. * In InterpreterEmulator:: maintainStackForCall(), obtain the arg count for invokedynamic calls by parsing the signature obtained from the call site Signed-off-by: Nazim Bhuiyan <[email protected]> Co-authored-by: Devin Papineau <[email protected]>
54d2766
to
63941ca
Compare
This commit adds JITServer support for the FE helper VM_getLayoutVarHandle. Signed-off-by: Nazim Bhuiyan <[email protected]>
63941ca
to
c41c05f
Compare
Looks like my ECA expired. I signed it again but it might take some time until that updates. |
As far as I can tell the ECA check failure is spurious. I put your email address (copied from a commit) into the "ECA validation tool" on the check failure details page, and it said that you had a valid ECA |
Jenkins test sanity.functional,sanity.openjdk alinux64 jdk21 |
Jenkins test sanity.functional xmac jdk17 |
Jenkins test sanity.openjdk aix jdk23 |
The JDK21 AArch64 Linux sanity.openjdk failure is #20200, like the other JDK21 sanity.openjdk failures were, so all failures have been known issues The ECA check has also passed now |
This changeset enables inlining of SegmentViewVarHandle operations
that have been introduced in JDK21 through the following:
Enable static final field folding for field types involved in suchVarHandle operations: ValueLayout, ValueLayouts, MemorySegment
ValueLayouts$AbstractValueLayout.accessHandle and MemorySegment methods
result of accessHandle()
MemorySegment methods so that the final field loads in the caller
that are relevant for obtaining the layout VH can be folded.
state in the InterpreterEmulator.
In addition to the above, this PR also introduces changes to how NeedsPeekingHeuristics is used, as well as added capability to look up resolved interface methods that are default methods defined within the interface class.