-
Notifications
You must be signed in to change notification settings - Fork 5k
Move InterpMethod* to the code header #114214
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
Conversation
The InterpMethod pointer is currently stored at the beginning of the IR bytecode of the interpreter. This change moves it to the code header.
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.
Pull Request Overview
This PR refactors the handling of the interpreter’s method pointer by moving it from the IR bytecode to the code header and removing the now‐unused CORINFO_FLG_INTERPRETER flag. Key changes include:
- Moving the storage of the InterpMethod pointer to the code header via new accessor methods.
- Removing CORINFO_FLG_INTERPRETER checks and updating related conditional logic.
- Propagating the new setInterpMethod API across multiple components such as JIT interfaces, SuperPMI tools, and AOT support.
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/coreclr/vm/jitinterface.h/cpp | Added and implemented setInterpMethod to update the InterpMethod pointer. |
src/coreclr/vm/interpexec.cpp | Updated interpreter execution to retrieve the InterpMethod via the new code header. |
src/coreclr/vm/codeman.h | Moved the InterpMethod pointer into the code header with new setter/getter methods. |
src/coreclr/tools/* | Updated SuperPMI, AOT, and JIT interface code to incorporate the new setInterpMethod method. |
src/coreclr/inc/{corjit.h, corinfo.h, icorjitinfoimpl_generated.h} | Updated interfaces and removed the unused interpreter flag. |
src/coreclr/interpreter/eeinterp.cpp | Modified code generation logic to leverage setInterpMethod instead of embedding the pointer. |
Files not reviewed (1)
- src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt: Language not supported
Comments suppressed due to low confidence (2)
src/coreclr/vm/interpexec.cpp:43
- Ensure that the removal of the offset adjustment for the instruction pointer is intentional and that the overall interpreter execution correctly accounts for the new code header layout.
ip = pFrame->startIp;
src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs:2515
- Consider adding a clarifying comment to document that setInterpMethod is intentionally not implemented because it is never called by the JIT, to assist future maintainers.
throw new NotImplementedException("setInterpMethod");
@@ -1778,6 +1778,10 @@ void MyICJI::reportFatalError(CorJitResult result) | |||
jitInstance->mc->cr->recReportFatalError(result); | |||
} | |||
|
|||
void MyICJI::setInterpMethod(void *pMethod) |
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.
If setInterpMethod is not expected to perform any operation in this context, please add a comment inside the method body to clarify that its empty implementation is intentional.
Copilot uses AI. Check for mistakes.
I am wondering whether it is the best data layout.
I think it would make the most sense to store CodeHeader is meant to be used for rarely use data, like GCInfo/UnwindInfo/EHInfo/DebugInfo. InterpMethod is not rarely used, so it should not be attached via CodeHeader.
|
@jkotas my view was that the code header contains metadata for the code, thus it seemed reasonable to have the InterpMethod pointer in it. It cleaned up need to adjust offsets to the actual IR when reporting them to debugger / eh. But I can see that the adjustments can be done when we generate the code to pretend the InterpMethod pointer is really part of the code and then we would not have to do them at other places. As for storing it inline as you suggest, that was something I've suggested to @BrzVlad initially. I liked the fact that we would not need to do yet another allocation to get memory for it. But Vlad preferred to have just the pointer there. @BrzVlad can you please share why you preferred that way? I don't remember the details. |
The code header structure is intentionally designed to separate hot and rarely used data. We even experimented at one point with moving the code header completely out-of-line (at the cost of slower access to code header - similar to how AOT images are structured) to achieve better code density. |
Other option would be to let the InterpreterCodeHeader contain the InterpMethod* / possibly the whole InterpMethod besides the pointer to the real code header. That would preserve the locality of the InterpMethod with the code and yet logically separate it from the byte code stream. |
I think about the |
On mono, the Personally, I don't really view the |
I expect that the EH metadata are going to be stored in the InterpreterRealCodeHeader. Is that right? |
I was not talking about the EH metadata coming from IL code. Mainly, I was referring to an array mapping each clause index to an offset on the interpreter stack. EH would use this information to store certain data on the stack of the method that needs to invoke a clause and also several interpreter EH related opcodes would make use of this. |
Right, it is the kind of metadata that |
Ok, let me close this PR now and wait until the InterpMethod becomes more or less final and then decide what approach we will take. |
The
InterpMethod
pointer is currently stored at the beginning of the IR bytecode of the interpreter. This change moves it to the code header.I have also noticed that we don't need the
CORINFO_FLG_INTERPRETER
anymore, as there is a simple way without it after the recent code managed refactoring, so I've made that simple change in this PR too.Most of the changes that add the
setInterpMethod
were generated by the ThunkGenerator tool.