Skip to content

Inline GetEnumerator under NativeAOT - #134427

Merged
jkotas merged 1 commit into
dotnet:mainfrom
hez2010:patch-5
Sep 22, 2026
Merged

jkotas merged 1 commit into
dotnet:mainfrom
hez2010:patch-5

Conversation

@hez2010

@hez2010 hez2010 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Noticed while working on #131265.

We were not inlining GetEnumerator here under NativeAOT, leading to foreach over array interfaces not able to be inlined even after devirtualization.

Copilot AI lite review requested due to automatic review settings September 22, 2026 15:32
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Sep 22, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
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.

Copilot review overview

🟢 Approval recommended

The change is narrowly scoped; the requested measurements are a non-blocking nit.

Review effort: Lite
Findings: None

What changed in this PR

Adds aggressive inlining to NativeAOT’s generic array GetEnumerator, enabling optimized interface-based foreach loops.

Changes:

  • Applies AggressiveInlining to Array<T>.GetEnumerator().
File Summary
src/​coreclr/​nativeaot/​System.Private.CoreLib/​src/​System/​Array.NativeAot.cs Enables inlining for NativeAOT array enumeration.

@jkotas

jkotas commented Sep 22, 2026

Copy link
Copy Markdown
Member

Matches equivalent method in CoreCLR w/ JIT:

[MethodImpl(MethodImplOptions.AggressiveInlining)]

LGTM

@jkotas
jkotas merged commit e4a207e into dotnet:main Sep 22, 2026
122 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants