Allocate all long-lived contents of interpreter memory via the jit interface allocation apis#125091
Merged
davidwrighton merged 11 commits intodotnet:mainfrom Mar 6, 2026
Merged
Conversation
…aBuilder Remove the unused InterpReloc struct, m_relocs member, and AddReloc method from InterpMethodDataBuilder. The relocation application loop in Finalize is also removed since there are no relocs to apply. The MemPoolAllocator constructor parameter is removed since it was only needed for the TArray<InterpReloc> member, and the datastructs.h include is dropped as TArray is no longer used in the header. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors CoreCLR interpreter method compilation to place long-lived per-method data (bytecode header + bytecodes + method metadata + related structures) into a single allocation obtained via the JIT allocMem interface, with the goal of preventing leaks for collectible assemblies.
Changes:
- Introduces
InterpMethodDataBuilderto size/lay out a unified method-data allocation. - Switches
InterpCompiler::CompileMethodto returnbooland addsGetTotalAllocationSize/FinalizeMethodDatato drive unified allocation and finalization. - Adds a new interpreter memory kind (
IMK_MethodData) and updates allocator plumbing (MemPoolAllocator) and build inputs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/interpreter/interpmethoddata.h | Adds method-data section model and builder API for unified allocation layout. |
| src/coreclr/interpreter/interpmethoddata.cpp | Implements section sizing, alignment, and final offset computation for unified allocation. |
| src/coreclr/interpreter/interpmemkind.h | Adds MethodData memkind for compilation-time method data allocations. |
| src/coreclr/interpreter/interpalloc.h | Moves MemPoolAllocator into shared allocator header and changes it to wrap InterpAllocator. |
| src/coreclr/interpreter/eeinterp.cpp | Updates compile pipeline to allocate one unified block and finalize method data into it. |
| src/coreclr/interpreter/compiler.h | Updates compiler API for new allocation/finalization flow; adds builder + fixup tracking state. |
| src/coreclr/interpreter/compiler.cpp | Implements new finalization/copy/fixup logic; changes AllocMethodData to use arena allocator. |
| src/coreclr/interpreter/CMakeLists.txt | Adds interpmethoddata.cpp to interpreter build. |
This was referenced Mar 3, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…righton/runtime into mini_interpreter_linker_2
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes all allocation of memory for the interpreter which are long-lived be allocated in the one big allocation. This should fix any issues where we have memory leaking from collectible assemblies.