Skip to content

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

Merged
davidwrighton merged 11 commits into
dotnet: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 into
dotnet:mainfrom
davidwrighton:mini_interpreter_linker_2

Conversation

@davidwrighton

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/coreclr/interpreter/compiler.cpp Outdated
Comment thread src/coreclr/interpreter/compiler.cpp
Comment thread src/coreclr/interpreter/compiler.h Outdated
Comment thread src/coreclr/interpreter/interpmethoddata.cpp
Comment thread src/coreclr/interpreter/interpmethoddata.cpp
Comment thread src/coreclr/interpreter/interpmethoddata.h Outdated
Comment thread src/coreclr/interpreter/interpmethoddata.h
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 3, 2026 22:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/coreclr/interpreter/eeinterp.cpp
Comment thread src/coreclr/interpreter/compiler.cpp
Comment thread src/coreclr/interpreter/compiler.cpp
Comment thread src/coreclr/interpreter/compiler.cpp Outdated
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/coreclr/interpreter/compiler.h
Comment thread src/coreclr/interpreter/interpmethoddata.cpp
Copilot AI review requested due to automatic review settings March 4, 2026 18:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/coreclr/interpreter/compiler.cpp
Comment thread src/coreclr/interpreter/compiler.cpp Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 4, 2026 19:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

@janvorli janvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

Comment thread src/coreclr/interpreter/interpmethoddata.cpp
@davidwrighton
davidwrighton merged commit b85f109 into dotnet:main Mar 6, 2026
106 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants