Skip to content

JIT: honor JitObjectStackAllocation{RefClass,BoxedValueClass,Array} in Release builds - #138557

Open
DavidObando wants to merge 2 commits into
dotnet:mainfrom
DavidObando:fix/object-stack-alloc-release-config
Open

DavidObando wants to merge 2 commits into
dotnet:mainfrom
DavidObando:fix/object-stack-alloc-release-config

Conversation

@DavidObando

Copy link
Copy Markdown
Member

Description

JitObjectStackAllocationRefClass, JitObjectStackAllocationBoxedValueClass, and JitObjectStackAllocationArray are declared with RELEASE_CONFIG_INTEGER in src/coreclr/jit/jitconfigvalues.h, matching the other release-enabled object stack allocation switches (JitObjectStackAllocation, JitObjectStackAllocationConditionalEscape, JitObjectStackAllocationSize, and JitObjectStackAllocationTrackFields).

However, ObjectAllocator::CanAllocateLclVarOnStack in src/coreclr/jit/objectalloc.cpp read those three switches inside #ifdef DEBUG, causing them to be silently ignored in Release builds.

This change removes the #ifdef DEBUG guard so all three switches are honored in Release builds as intended.

Validation

Built Release CoreCLR native + CoreLib on osx-arm64:

./build.sh clr.native+clr.corelib -rc Release

Result: Build succeeded. 0 Warning(s), 0 Error(s).

Verified with the repro from #138549 against the built Release corerun + libclrjit.dylib:

  • Default: Ref=0, Box=0, Arr=0
  • DOTNET_JitObjectStackAllocationRefClass=0: Ref=24, Box=0, Arr=0
  • DOTNET_JitObjectStackAllocationBoxedValueClass=0: Ref=0, Box=24, Arr=0
  • DOTNET_JitObjectStackAllocationArray=0: Ref=0, Box=0, Arr=32
  • All three =0: Ref=24, Box=24, Arr=32

Resolves #138549

Note

This pull request was authored and submitted with the assistance of GitHub Copilot.

@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 30, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: JitObjectStackAllocation{RefClass,BoxedValueClass,Array} config switches are ignored in Release builds

1 participant