Skip to content

Conversation

@MichalStrehovsky
Copy link
Member

Port dotnet/coreclr#27516 to native AOT.

Cc @dotnet/ilc-contrib

@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.

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.

Pull Request Overview

This PR ports support for encoding array rank information in BulkType ETW events to Native AOT.
Key changes include:

  • Expose GetParameterizedTypeShape and GetArrayRank in MethodTable
  • Define new ETW type flags for array ranks in eventtracebase.h
  • Update BulkTypeEventLogger to set rank bits for multidimensional arrays
  • Implement GetArrayRank logic in MethodTable.cpp

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/nativeaot/Runtime/inc/MethodTable.h Added declarations for GetParameterizedTypeShape and GetArrayRank
src/coreclr/nativeaot/Runtime/eventtracebase.h Introduced enum flags/masks for array rank encoding
src/coreclr/nativeaot/Runtime/eventtrace_bulktype.cpp Updated BulkType logger to set array rank bits
src/coreclr/nativeaot/Runtime/MethodTable.cpp Added implementation of GetArrayRank
Comments suppressed due to low confidence (3)

src/coreclr/nativeaot/Runtime/inc/MethodTable.h:200

  • [nitpick] Add a brief doc comment explaining that this returns the raw base size used to compute element storage (including bounds for parameterized types).
    uint32_t GetParameterizedTypeShape()

src/coreclr/nativeaot/Runtime/inc/MethodTable.h:217

  • [nitpick] Add a doc comment describing how this computes the array rank (1 for SZ arrays, >1 for multidimensional).
    uint32_t GetArrayRank();

src/coreclr/nativeaot/Runtime/eventtrace_bulktype.cpp:305

  • Add unit or integration tests to cover multidimensional array ranks being encoded correctly in BulkTypeEventLogger, especially for ranks >1.
                uint32_t rank = pEEType->GetArrayRank();

ASSERT(IsArray());
uint32_t boundsSize = GetParameterizedTypeShape() - SZARRAY_BASE_SIZE;
if (boundsSize > 0)
{
Copy link

Copilot AI Jun 17, 2025

Choose a reason for hiding this comment

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

Add an ASSERT to verify that boundsSize % (2 * sizeof(uint32_t)) == 0 to catch unexpected shape values and ensure the division yields an integer dimension count.

Suggested change
{
{
// Ensure boundsSize is divisible by (2 * sizeof(uint32_t)).
ASSERT(boundsSize % (2 * sizeof(uint32_t)) == 0);

Copilot uses AI. Check for mistakes.
@MichalStrehovsky
Copy link
Member Author

/ba-g the HostActivation failure is likely #116520 and unrelated

@MichalStrehovsky MichalStrehovsky merged commit d41a299 into dotnet:main Jun 18, 2025
92 of 95 checks passed
@MichalStrehovsky MichalStrehovsky deleted the arrevents branch June 18, 2025 09:47
@github-actions github-actions bot locked and limited conversation to collaborators Jul 19, 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.

3 participants