Skip to content

Mono C# low-level struct feature support #48113

@lambdageek

Description

@lambdageek

See #46104. Basically there are two new C#1language features that we need to support. ref fields in ref structs, and fixed size buffers of any type. (See C# and CoreCLR issues in the linked issue).

  • ref fields in ref structs. Consume Roslyn with ref fields support #71498
    For Mono due to conservative stack scanning, it is likely that the only additional work for ref fields is to verify that we don't reject ref fields during loading and class initialization.

  • safe fixed size buffers (This is in flux pending the outcome of the FixSizedBufferAttribute proposal Expose an attribute to allow sizing a fixed sized buffer based on type and element count. #12320). [API Proposal]: InlineArrayAttribute #61135
    The approach with InlineArrayAttribute is to modify the struct layout algorithm to adjust the inferred size of a single-field struct to contain space for N extra copies of the field. Also the GC descriptor will need to be array-like.
    The rest is based on the proposed translation in https://github.com/dotnet/csharplang/blob/master/proposals/fixed-sized-buffers.md
    The proposed translation relies on creating a generic struct type with potentially thousands of fields.
    ~ - [ ] First cut at support: Just verify that class layout and initialization don't perform pathologically on such giant declarations.~
    ~ - [ ] Second cut at support: Look for the FixedBufferAttribute on the field declaration and synthesize the class layout for the defining class without initializing the underlying thousand-field struct.~
    - [ ] Stretch goal: Ideally also compile the indexer in the struct without doing class layout. (This is hard)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-VM-meta-monotrackingThis issue is tracking the completion of other related issues.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions