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

[NativeAOT-LLVM] [Question]: Should GCPointerMap have a provision for adding optional fields to GCStaticEETypeNode #2606

Closed
yowl opened this issue Jun 9, 2024 · 3 comments
Labels
area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly)

Comments

@yowl
Copy link
Contributor

yowl commented Jun 9, 2024

WIth this code

    public static class InteropReturnArea
    {
        [InlineArray(3)]
        internal struct ReturnArea
        {
            private ulong buffer;
            
            internal unsafe nint AddressOfReturnArea()
            {
                return (nint)Unsafe.AsPointer(ref buffer);
            }
        }
        
        [ThreadStatic]
        [FixedAddressValueType]
        internal static ReturnArea returnArea = default;

ReturnArea should be align 8, so GCStaticEETypeNode should be written with an optional field OptionalFieldsFlag I assume. The mechanism seems to be to do with GCPointerMap but there is nothing present to do this. Am I off track here or is there something missing?

Thanks

@yowl yowl changed the title [NativeAOT-LLVM]: Should GCPointerMap have a provision for adding optional fields to GCStaticEETypeNode [NativeAOT-LLVM] [Question]: Should GCPointerMap have a provision for adding optional fields to GCStaticEETypeNode Jun 9, 2024
@jkotas
Copy link
Member

jkotas commented Jun 10, 2024

Should GCPointerMap have a provision for adding optional fields to GCStaticEETypeNode

I do not think we want to have a generic provision for arbitrary optional fields in GCPointerMap.

We may want to track the RequiresAlign8 in GCPointerMap (more convenient); or RequiresAlign8 can be tracked independently from GCPointerMap.

GCStaticEETypeNode for regular statics has the same problem, but it is masked by the thread statics being allocated on PINNED_OBJECT_HEAP that happens to guarantee 8-byte alignment even on 32-bit platforms. A quick work around for thread statics would be to allocate all thread statics conservatively with 8-byte alignment.

Linux arm32 is probably affected by this bug as well. We may want to fix it in upstream. cc @filipnavara

@jkotas
Copy link
Member

jkotas commented Jun 10, 2024

I have opened dotnet/runtime#103234 for the upstream bug on Linux arm32

@filipnavara
Copy link
Member

Linux arm32 is probably affected by this bug as well. We may want to fix it in upstream. cc @filipnavara

Sounds like it. I am not sure I fully understand the scope of the issue yet. Generally, Align8 was one of the last items on the dotnet/runtime#97729 list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly)
Projects
None yet
Development

No branches or pull requests

3 participants