Repository navigation
[clrinterp] Split interpreter entry betwen managed and unmanaged callers - #133417
Conversation
ExecuteIntepretedMethod was carrying quite a bit of logic to handle interpreter entry to an unmanaged callers only. This commit splits the logic into 3 methods: - ExecuteInterpretedMethodBody -> creates the interpreter frames then starts executing, acts as a fastpath - ExecuteInterpretedMethodFromUnmanagedWorker -> does all the necessary UCO checks/work then calls the above, acts as a slowpath - ExecuteInterpretedMethod -> depending on whether the interpreted method is UCO or not, calls the fastpath or the slowpath We could probably move more code outside the fastpath, for example the async continuation storing, for now the change is kept more targeted. Improves interp entry microbenchmark by about 5%.
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @BrzVlad, @janvorli |
There was a problem hiding this comment.
🔵 Needs a closer look
It changes a sensitive CoreCLR VM interpreter entry/GC-transition path with architecture-specific calling conventions, warranting careful human validation beyond a diff-only review.
Pull request overview
This PR refactors the CoreCLR interpreter entrypoint in prestub.cpp by splitting the interpreter execution logic into separate helper functions, with the goal of reducing overhead on the managed-caller fast path while keeping the unmanaged (UnmanagedCallersOnly) entry checks on a slow path.
Changes:
- Introduces
ExecuteInterpretedMethodBodyto encapsulate frame setup, interpreter execution, and async-continuation publication. - Introduces
ExecuteInterpretedMethodFromUnmanagedto handle reverse-P/Invoke/UCO-specific thread and GC-mode validation plus profiling/debugger transition hooks. - Updates
ExecuteInterpretedMethodto dispatch to the fast/slow path based onunmanagedCallersOnly.
File summaries
| File | Description |
|---|---|
| src/coreclr/vm/prestub.cpp | Splits interpreter entry into fast/slow paths to reduce overhead for managed callers while preserving UCO reverse-P/Invoke checks and profiler/debugger hooks. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
|
@BrzVlad so the perf gain happens just because you've split / refactored the function? |
|
Yes, there is no change in logic, just that we now consider the managed to managed transition as the common hot path and we remove some checks from it. While this doesn't have significant perf gains as of right now, I believe it is good refactoring to have that could allow us in the future to reduce unnecessary work from this path even more. For example we could remove handling for async methods, or make the stubs call this hot path directly, completely avoiding any checks for UCO. But these are micro optimizations and I don't believe we need to overly commit to them right now. |
|
/ba-g unrelated failure |
…ers (dotnet#133417) ExecuteIntepretedMethod was carrying quite a bit of logic to handle interpreter entry to an unmanaged callers only. This commit splits the logic into 3 methods: - ExecuteInterpretedMethodBody -> creates the interpreter frames then starts executing, acts as a fastpath - ExecuteInterpretedMethodFromUnmanagedWorker -> does all the necessary UCO checks/work then calls the above, acts as a slowpath - ExecuteInterpretedMethod -> depending on whether the interpreted method is UCO or not, calls the fastpath or the slowpath We could probably move more code outside the fastpath, for example the async continuation storing, but for now the diff is kept more targeted. Improves interp entry microbenchmark by about 5% on desktop.
ExecuteIntepretedMethod was carrying quite a bit of logic to handle interpreter entry to an unmanaged callers only. This commit splits the logic into 3 methods:
We could probably move more code outside the fastpath, for example the async continuation storing, but for now the diff is kept more targeted. Improves interp entry microbenchmark by about 5% on desktop.