dotnet / dotnet/runtime

WasmLowering: Empty struct detection doesn't exist for ABI purposes, and should

Đang mở
#127,361 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
arch-wasm area-TypeSystem-coreclr
Ngôn ngữ chính
C#
Star
18.3k
Fork
5.6k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

The WebAssembly Basic C ABI (https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md) specifies that empty structs and unions are "ignored" for both parameters and returns. In WasmLowering.GetSignature, empty struct parameters are currently detected via
paramType.GetElementSize().AsInt == 0. However, .NET pads empty value types to a minimum size of 1 byte:

// MetadataFieldLayoutAlgorithm.cs:1177
// Pad the length of structs to be 1 if they are empty, so we have no zero-length structures
if (type.IsValueType && instanceSize == LayoutInt.Zero)
instanceSize = LayoutInt.One;

What needs to change

1. Detect empty structs by instance field count (0 non-static fields), no explicit layout.
2. Empty struct return/parameters should not contribute to the arguments of the function at the Wasm level.
3. This applies to all calling conventions (managed and unmanaged).

Location

src/coreclr/tools/Common/JitInterface/WasmLowering.cs — the GetSignature(MethodSignature, LoweringFlags) method.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu trong src/coreclr/tools/Common/JitInterface/WasmLowering.cs tại GetSignature(MethodSignature, LoweringFlags), sau đó đọc phần xử lý kiểu giá trị rỗng được nêu trong MetadataFieldLayoutAlgorithm.cs:1177 và hướng dẫn Basic C ABI được liên kết. Hoàn thành có nghĩa là các struct rỗng không có trường không tĩnh, bao gồm các trường hợp explicit-layout được chỉ định, bị loại khỏi các tham số và giá trị trả về WebAssembly đối với các quy ước gọi managed và unmanaged.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, wasm
Lĩnh vực
compilers
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
68/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.