Repository navigation
Use direct VM callbacks for interpreter-only CoreCLR builds - #137398
davidwrighton merged 3 commits into
Conversation
Select concrete interpreter callback types and remove callback virtual methods in interpreter-only runtime builds while preserving the virtual interfaces for JIT-capable builds and tools. Co-authored-by: Copilot <[email protected]> Copilot-Session: 0450a1a5-696d-455f-8288-4924e23b62d7
|
Tagging @dotnet/jit-contrib for JIT-EE GUID update |
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 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
The cross-target callback ABI and GC/debug/EH dispatch changes require runtime-owner review and platform-specific validation, with Apple/WASI builds, managed Wasm execution, and dedicated async/calli/EH suites absent from the reported checks.
No open issues 🎉
What changed in this PR
This PR enables direct interpreter-to-VM callbacks in interpreter-only CoreCLR builds while retaining virtual callbacks for JIT-capable builds and tool consumers. It targets reduced binary size without changing unrelated runtime interfaces.
Changes:
- Make callback declarations conditionally nonvirtual and use concrete interpreter callback handles.
- Preserve specialized code-publication and debug-info dispatch, with compile-time checks for both configurations.
- Update build integration, generated declarations, and the JIT-EE GUID; rename GC encoder slot types to avoid a header collision.
| File | Description |
|---|---|
src/coreclr/vm/jitinterface.h |
Apply conditional virtual qualifiers to VM callbacks. |
src/coreclr/vm/jitinterface.cpp |
Select concrete dispatch and assert expected polymorphism. |
src/coreclr/vm/common.h |
Enable direct calls for interpreter-only runtime builds. |
src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs |
Generate conditional override qualifiers. |
src/coreclr/interpreter/stackmap.h |
Use configuration-dependent callback handles. |
src/coreclr/interpreter/stackmap.cpp |
Adapt stack-map callbacks and include ordering. |
src/coreclr/interpreter/interpreter.h |
Include VM definitions in direct-call mode. |
src/coreclr/interpreter/inc/interpretershared.h |
Select the concrete interpreter handle type. |
src/coreclr/interpreter/eeinterp.cpp |
Convert incoming callbacks to the concrete handle. |
src/coreclr/interpreter/compileropt.cpp |
Pass alignment callback defaults explicitly. |
src/coreclr/interpreter/compiler.cpp |
Adapt callback handles, arguments, and includes. |
src/coreclr/interpreter/CMakeLists.txt |
Configure direct-call dependencies and static linking. |
src/coreclr/inc/jiteeversionguid.h |
Refresh the JIT-EE interface identifier. |
src/coreclr/inc/icorjitinfoimpl_generated.h |
Regenerate conditional callback declarations. |
src/coreclr/inc/gcinfoencoder.h |
Select callback types and rename encoder slot descriptors. |
src/coreclr/inc/corjit.h |
Make JIT callback virtual qualifiers conditional. |
src/coreclr/inc/corinfo.h |
Define conditional qualifiers for metadata callbacks. |
src/coreclr/gcinfo/gcinfoencoder.cpp |
Adapt encoder callbacks and renamed slot types. |
src/coreclr/gcinfo/CMakeLists.txt |
Scope direct-call encoder integration to runtime builds. |
Review effort: Balanced
jkoritzinsky
left a comment
There was a problem hiding this comment.
One comment on the infra side of things.
The implementation looks good, but this is just as horrifying as it was when we talked about it before. Effective though, so LGTM!
Co-authored-by: Copilot <[email protected]>
Compute FEATURE_INTERPRETER_DIRECT_CALLS in clrfeatures.cmake and define it globally from clrdefinitions.cmake, instead of deriving it in vm/common.h and separately defining it for the gcinfo and interpreter targets. JITs, the cross-target gcinfo encoders, and SuperPMI keep the virtual ICorJitInfo interface by opting out through the IGNORE_FEATURE_INTERPRETER_DIRECT_CALLS target property. Co-authored-by: Copilot <[email protected]>
Summary
Use direct interpreter-to-VM calls when
FEATURE_INTERPRETERis enabled andFEATURE_DYNAMIC_CODE_COMPILEDis disabled, including interpreter-only Wasm and Apple configurations. Preserve the existing virtual callback interfaces on JIT-capable builds.ICorStaticInfo/ICorDynamicInfo/ICorJitInfocallback hierarchy and its VM implementations nonvirtual in interpreter-only runtime builds.CInterpreterJitInfohandles for the interpreter compiler and runtime GC encoder, without forwarding stubs.ICorJitCompiler,ICorJitHost, and unrelated runtime virtual interfaces remain unchanged. The GC encoder slot descriptor is renamed to avoid a collision with the decoder when including the VM headers.Related to the callback-overhead discussion in #6751; this PR does not attempt to close that broader issue.
Size measurements
Matching browser-wasm Release builds, based on
d990730ba1ca5e163fa067ae40c4a2ff9114c9f2, with identical link flags:corerun.wasmBrotli 1.1.0, quality 11, window 22, generic mode; decompression round trips verified. Neither image contains custom/debug sections. The changed image has 168 fewer defined functions. A linker-map relink produces byte-identical Wasm and retains no
CEEJitInfofunctions.These are binary-size measurements, not startup or compilation-throughput measurements.
Validation
Passed:
The four
JIT.CodeGenBringUpTests_{d,do,r,ro}.dllrunners each returned the expected exit code 100 on both the interpreter-only runtime and the JIT-capable runtime withDOTNET_InterpMode=3(eight successful runner invocations). The final interpreter-only native build and all eight invocations were repeated before committing.Native object relocations show direct calls to concrete VM metadata callbacks. Expanding the conditional qualifiers in the normal configuration reproduces the original callback interface and generated declarations exactly.
Not run locally: Apple/iOS/MacCatalyst/tvOS or WASI builds, Wasm managed test execution, dedicated async/calli/EH suites, or startup/compilation-throughput benchmarks. Apple validation requires an Apple host.
Note
This PR description and the code changes were generated with GitHub Copilot.