-
Notifications
You must be signed in to change notification settings - Fork 5.2k
JIT: Fix heap allocations #120290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT: Fix heap allocations #120290
Conversation
Also override the global new operators to assert unconditionally, to catch this common pitfall proactively.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
In the single-file host, the Jit is going to be linked statically with the rest of the native code. Is the fact this override is not causing problems in that case by construction or accidental? |
Accidental. Let me hide it under a define set for the standalone jits. |
PTAL @dotnet/jit-contrib. I want to backport this to GA, but might not backport the "diagnostic" |
There was a problem hiding this 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 aims to eliminate unintended heap allocations in the JIT by routing allocations through the JIT's custom allocators and by asserting on any accidental use of the global operator new in standalone builds.
- Replaces raw global new usages with allocator-aware placement new for LSRA structures.
- Introduces overridden global operator new/delete (guarded by JIT_STANDALONE_BUILD) that assert to catch unintended allocations.
- Adds a build define to enable the new checks.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
File | Description |
---|---|
src/coreclr/jit/lsra.cpp | Switches allocations to use compiler memory kinds via placement new. |
src/coreclr/jit/alloc.cpp | Adds global operator new/delete overrides to assert on unintended allocations. |
src/coreclr/jit/CMakeLists.txt | Defines JIT_STANDALONE_BUILD to enable the new allocation assertions. |
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM assuming CI passes
/backport to release/10.0 |
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/18188174550 |
Also override the global new operators to assert unconditionally, to catch this common pitfall proactively.
Ideally that would be a compile time diagnostic, but I could not figure out how to make that happen.
Fix #120285