Skip to content

ABI for Decimal32/64/128 is incorrect with regards to native ABI for by value parameter passing #131341

Description

@tannergooding

The by-value native ABI for System.Numerics.Decimal32, Decimal64, and Decimal128 is not yet implemented in the JIT, mirroring the situation for Int128/UInt128 tracked by #74209.

Known issues:

  • Decimal128 is a 16-byte, 16-byte-aligned type and hits the same unimplemented register-pair/stack-alignment paths as Int128 on Arm64 and Unix x64 (both enregistered and when spilled to the stack).
  • Decimal32/Decimal64 are 4/8-byte scalars, but the JIT has no decimal floating-point calling convention. To the JIT they are struct{uint}/struct{ulong} passed in integer registers, which does not match a platform _Decimal32/_Decimal64 (SSE class on the System V ABI).

Until this is implemented, by-value marshaling of these types (and structs containing them) is blocked, and the field layout for Decimal128 is given a 16-byte alignment to match the native ABI (the same treatment as Int128/UInt128).

When this is fixed, re-enable the by-value scenarios in $(XunitTestBinBase)/Interop/PInvoke/Decimal128/.

category:correctness
theme:calling-convention
skill-level:expert

Note

This issue was drafted with the assistance of GitHub Copilot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions