Skip to content

Simplify handling Span in the cctor interpreter#114487

Merged
MichalStrehovsky merged 2 commits intodotnet:mainfrom
MichalStrehovsky:fix114455
Apr 14, 2025
Merged

Simplify handling Span in the cctor interpreter#114487
MichalStrehovsky merged 2 commits intodotnet:mainfrom
MichalStrehovsky:fix114455

Conversation

@MichalStrehovsky
Copy link
Member

This is two things:

  • Now that we allow byrefs in more places, we can simplify handling spans (less special casing since more things just naturally fall out).
  • Handle RVA statics within the interpreter. They can be naturally used with Spans now.

Fixes #114455.

Cc @dotnet/ilc-contrib @Sergio0694

This is two things:

* Now that we allow byrefs in more places, we can simplify handling spans (less special casing since more things just naturally fall out).
* Handle RVA statics within the interpreter. They can be naturally used with Spans now.
Copilot AI review requested due to automatic review settings April 10, 2025 13:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs:2810

  • [nitpick] Consider extracting the hardcoded field name '_length' (and similarly '_reference') into a named constant to improve maintainability and reduce magic strings.
if (field.Name == "_length")

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs:3226

  • [nitpick] Verify that the new method name 'GetArrayData' clearly represents its purpose as a replacement for the previous TryGetReadOnlySpan approach, or consider renaming for better clarity.
public ByRefValue GetArrayData()


Value fieldValue;
if (field.OwningType == _type)
if (field.HasRva)
Copy link

Copilot AI Apr 10, 2025

Choose a reason for hiding this comment

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

Consider adding an inline comment to clarify the constraints on RVA statics (e.g. why fields must be IsInitOnly and without a static constructor) to aid future maintenance.

Copilot uses AI. Check for mistakes.
public override bool TryLoad(TypeDesc type, out Value value)
{
if (!type.IsPrimitive
if (!type.IsValueType
Copy link

Copilot AI Apr 10, 2025

Choose a reason for hiding this comment

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

Review whether switching the condition from 'IsPrimitive' to 'IsValueType' covers all intended scenarios without unintentionally allowing unsupported types.

Copilot uses AI. Check for mistakes.
@dotnet-policy-service
Copy link
Contributor

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

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky MichalStrehovsky merged commit 81efbf1 into dotnet:main Apr 14, 2025
100 of 102 checks passed
@MichalStrehovsky MichalStrehovsky deleted the fix114455 branch April 14, 2025 07:01
@github-actions github-actions bot locked and limited conversation to collaborators May 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support precompiling 'ComInterfaceEntry.IID' fields from RVA span fields in ILC cctor interpreter (Native AOT)

3 participants