Skip to content

Allocate all long-lived contents of interpreter memory via the jit interface allocation apis#125091

Merged
davidwrighton merged 11 commits intodotnet:mainfrom
davidwrighton:mini_interpreter_linker_2
Mar 6, 2026
Merged

Allocate all long-lived contents of interpreter memory via the jit interface allocation apis#125091
davidwrighton merged 11 commits intodotnet:mainfrom
davidwrighton:mini_interpreter_linker_2

Conversation

@davidwrighton
Copy link
Member

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.

davidwrighton and others added 3 commits March 2, 2026 14:13
…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>
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a 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 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 InterpMethodDataBuilder to size/lay out a unified method-data allocation.
  • Switches InterpCompiler::CompileMethod to return bool and adds GetTotalAllocationSize/FinalizeMethodData to 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.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 3, 2026 22:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

davidwrighton and others added 2 commits March 3, 2026 15:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 3, 2026 23:32
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings March 4, 2026 18:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 4, 2026 19:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@davidwrighton davidwrighton merged commit b85f109 into dotnet:main Mar 6, 2026
106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants