Skip to content
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: array allocation fixes #112676

Merged
merged 1 commit into from
Feb 19, 2025
Merged

Conversation

AndyAyersMS
Copy link
Member

Fix some issues with array stack allocation that are currently hard to observe:

  • use correct method table for shared array types
  • pad array layout out to a multiple of TARGET_POINTER_SIZE

It's currently not easy to observe the type of a stack allocated array as accessing the type causes escape. But this becomes possible when supporting span capture or once we have a version of the covariant store check that can handle stack allocated arrays.

Non-padded layouts may mean elements just off the end of an odd-length short or byte array won't be zeroed, which some unsafe uses may expect.

Added some test cases.

Fix some issues with array stack allocation that are currently hard to observe:
* use correct method table for shared array types
* pad array layout out to a multiple of TARGET_POINTER_SIZE

It's currently not easy to observe the type of a stack allocated array as
accessing the type causes escape. But this becomes possible when supporting
span capture or once we have a version of the covariant store check that can
handle stack allocated arrays.

Non-padded layouts may mean elements just off the end of an odd-length
short or byte array won't be zeroed, which some unsafe uses may expect.

Added some test cases.
@Copilot Copilot bot review requested due to automatic review settings February 19, 2025 02:39
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 19, 2025

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • src/coreclr/jit/helperexpansion.cpp: Language not supported
  • src/coreclr/jit/layout.cpp: Language not supported
Comments suppressed due to low confidence (2)

src/tests/JIT/opt/ObjectStackAllocation/ObjectStackAllocationTests.cs:393

  • [nitpick] The method name AllocateArrayT is not very descriptive. It should be renamed to AllocateGenericArray.
static int AllocateArrayT<T>()

src/tests/JIT/opt/ObjectStackAllocation/ObjectStackAllocationTests.cs:465

  • [nitpick] The method name Use is too generic. It should be renamed to UseString.
static void Use(ref string s)
Copy link
Contributor

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

@AndyAyersMS
Copy link
Member Author

Some issues I noted while working on #112543

@jakobbotsch PTAL
cc @dotnet/jit-contrib

@AndyAyersMS AndyAyersMS merged commit bde9ba9 into dotnet:main Feb 19, 2025
119 checks passed
grendello added a commit to grendello/runtime that referenced this pull request Feb 19, 2025
* main: (27 commits)
  Fold null checks against known non-null values (dotnet#109164)
  JIT: Always track the context for late devirt (dotnet#112396)
  JIT: array allocation fixes (dotnet#112676)
  [H/3] Fix test closing connection too fast (dotnet#112691)
  Fix LINQ handling of iterator.Take(...).Last(...) (dotnet#112680)
  [browser][MT] move wasm MT CI legs to extra-platforms (dotnet#112690)
  JIT: Don't use `Compiler::compFloatingPointUsed` to check if FP kills are needed (dotnet#112668)
  [LoongArch64] Fix a typo within PR#112166. (dotnet#112672)
  Fix new EH hang on DebugBreak (dotnet#112640)
  Use encode callback instead of renting a buffer to write to in DSAKeyFormatHelper
  Move some links to other doc (dotnet#112574)
  Reflection-based XmlSerializer - Deserialize empty collections and allow for sub-types in collection items. (dotnet#111723)
  JIT: Use `fgCalledCount` for OSR method entry weight (dotnet#112662)
  Use Avx10.2 Instructions in Floating Point Conversions (dotnet#111775)
  Expose StressLog via CDAC and port StressLogAnalyzer to managed code (dotnet#104999)
  JIT: Use linear block order for MinOpts in LSRA (dotnet#108147)
  Update dependencies from https://github.com/dotnet/arcade build 20250213.2 (dotnet#112625)
  JIT: Clean up and optimize call arg lowering (dotnet#112639)
  Update dependencies from https://github.com/dotnet/emsdk build 20250217.1 (dotnet#112645)
  JIT: Support `FIELD_LIST` for returns (dotnet#112308)
  ...
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.

2 participants