Align NativeAOT array element size limit#130019
Open
Copilot wants to merge 3 commits into
Open
Conversation
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix maximum allowed size of base type in arrays in NativeAOT
Align NativeAOT array element size limit
Jun 30, 2026
MichalStrehovsky
approved these changes
Jun 30, 2026
jkotas
approved these changes
Jun 30, 2026
Member
|
/azp run runtime-nativeaot-outerloop, runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns NativeAOT’s array element-size validation with the runtime limit so that value-type array elements of exactly 65,535 bytes are accepted (matching CoreCLR behavior at the boundary). This avoids rejecting a size that still fits the GCDesc/component-size encodings used by the NativeAOT toolchain.
Changes:
- Adjusted NativeAOT type loadability validation for arrays to reject only element sizes greater than
ushort.MaxValue. - Added a new InlineArray-focused regression test project and test that exercises using an
[InlineArray(65535)]struct as an array element type.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs | Updates array element-size check from >= ushort.MaxValue to > ushort.MaxValue, allowing the 65,535-byte boundary. |
| src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.csproj | Adds a new standalone test project for the regression scenario. |
| src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.cs | Adds a test covering [InlineArray(65535)] as an array element type (size + successful array construction). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
NativeAOT rejected array element value types of exactly 65,535 bytes, while CoreCLR allows that boundary value. The validation now rejects only element sizes greater than
ushort.MaxValue.>= ushort.MaxValue→> ushort.MaxValue[InlineArray(65535)]can be used as an array element type.IlcCompile.Test methodology
Additional context
This keeps NativeAOT behavior consistent with CoreCLR at the maximum supported array element size boundary.