Skip to content

Fix handling of multidimensional arrays in type system and dotnet-pgo #51764

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

Merged

Conversation

davidwrighton
Copy link
Member

  • Provide representation for multidimensional array non-standard shapes in embedded signature data (to allow overloads)
    • This fixes possible issues in interop with C++ and IL generated binaries in crossgen2 as well as these issues in dotnet-pgo
  • Move type system metadata emitter logic from dotnet-pgo source base to common
    • Enables creation of unittests to cover the bugs identified
  • Fix emission of multidimensional arrays in signature emitter
    • Emit complex array shape when available
    • Even when standard shape is in place, pass empty ImmutableArrays for bounds and lobounds, not just default
  • Fix handling of multidimensional arrays when generating a type reference
    • If a type isn't a MetadataType don't treat it as one

Also a small drive-by fix to reduce unnecessary throwing of exceptions while running dotnet-pgo

- Provide representation for multidimensional array non-standard shapes in embedded signature data (to allow overloads)
  - This fixes possible issues in interop with C++ and IL generated binaries in crossgen2 as well as these issues in dotnet-pgo
- Move type system metadata emitter logic from dotnet-pgo source base to common
  - Enables creation of unittests to cover the bugs identified
- Fix emission of multidimensional arrays in signature emitter
  - Emit complex array shape when available
  - Even when standard shape is in place, pass empty ImmutableArrays for bounds and lobounds, not just default
- Fix handling of multidimensional arrays when generating a type reference
  - If a type isn't a MetadataType don't treat it as one

Also a small drive-by fix to reduce unnecessary throwing of exceptions while running dotnet-pgo
@davidwrighton
Copy link
Member Author

@dotnet/crossgen-contrib

@davidwrighton davidwrighton requested a review from trylek April 23, 2021 21:37
@davidwrighton
Copy link
Member Author

@Lxiamail Alicia, when this gets in we should be able to enable the Orchard optimization scenario

loBounds[i] = Int32.Parse(loBoundsStr[i]);
}

shapeEncoder.Shape(rank, ImmutableArray.Create(bounds), ImmutableArray.Create(loBounds));
Copy link
Member

Choose a reason for hiding this comment

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

Nit - would it be useful to add assertions checking the bounds / lower bounds length against the array rank?

@@ -472,7 +517,6 @@ void EncodeMethodSignature(BlobBuilder signatureBuilder, MethodSignature sig, Em

signatureEncoder.MethodSignature(sigCallingConvention, genericParameterCount, isInstanceMethod);
signatureBuilder.WriteCompressedInteger(sig.Length);
// TODO Process custom modifiers in some way
Copy link
Member

Choose a reason for hiding this comment

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

Just for my education - does deletion of this comment mean that this has been fixed independently or that we no longer care about custom modifiers?

Copy link
Member Author

Choose a reason for hiding this comment

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

We already wrote the code to handle custom modifiers a year or so ago, but never actually cleaned up this comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

In particular that's what the embedded signature data stuff was written for originally. I will say that it is completely and totally incomprehensible as Michal has noted before, but it does work. And with handling of array shapes we hopefully won't ever have to touch it again.

Copy link
Member

@trylek trylek left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@davidwrighton davidwrighton merged commit 3e8884c into dotnet:main Apr 26, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
@davidwrighton davidwrighton deleted the FixMDArrayHandlingInDotnetPgo branch April 13, 2023 18:47
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