Skip to content
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

[mono] Implement GC descriptor for structs with InlineArray attribute #84097

Merged

Conversation

kotlarmilos
Copy link
Member

@kotlarmilos kotlarmilos commented Mar 29, 2023

This PR contributes to #80798. It implements/fixes GC descriptor for structs with InlineArray attribute and adds a Mono-specific GC descriptor test.

Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

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

Cute hack.

Thoughts:

  1. Maybe we should add a warning if field_iter > 500 (or some other large-ish arbitrary value) in case we suspect we're spending a lot of time in this loop.
  2. Maybe create an issue to change to a more optimized version (copying the bitmap of the field N times instead of redoing the whole loop).
  3. In some sense even bit copying is still not optimal if N gets large enough.
    We should have a way for the sgen GC descriptor to encode an inlined vector in the middle of another descriptor - I'm not sure if that's encodable using what is in src/mono/mono/sgen/sgen-descriptor.h. But if it is, we might need some more sophisticated version of mono_class_compute_gc_descriptor for valuetypes [that contain valuetypes] that contain inlined arrays. Instead of just computing a bitmap, it does something to creates an sgen descriptor directly. Either that or somehow give sgen the ability to detect repeated runs - there's probably some leetcode dynamic programming algorithm for finding the maximal repeating sequence in the middle of a bit sequence.

@lambdageek lambdageek requested a review from BrzVlad March 29, 2023 22:38
@lambdageek
Copy link
Member

@BrzVlad do you know if sgen descriptors can encode a repeated run in the middle of a descriptor?

@kotlarmilos
Copy link
Member Author

Follow-up tracking issue - #84116

@kotlarmilos kotlarmilos merged commit 822fc81 into dotnet:main Mar 30, 2023
148 of 152 checks passed
@kotlarmilos kotlarmilos deleted the feature/inline-array-attribute-gc-desc branch March 30, 2023 13:58
@dotnet dotnet locked as resolved and limited conversation to collaborators Apr 29, 2023
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.

None yet

2 participants