Rewrite of Windows x64 value type ABI to support DirectX wrapper libraries.
authorlateralusX <lateralusx.github@gmail.com>
Thu, 14 Jul 2016 11:27:44 +0000 (13:27 +0200)
committerlateralusX <lateralusx.github@gmail.com>
Thu, 14 Jul 2016 17:34:52 +0000 (19:34 +0200)
commita4eeef2f2fc816463c83e8d6a2d1c4c7e26999f9
tree1d8ab5a48d3d8c0c381c856b2e37b83818d6171b
parent41b65b08a5f70148f625e83f4b44b2a6514e9a74
Rewrite of Windows x64 value type ABI to support DirectX wrapper libraries.

Current implementation used different value type ABI’s depending on if call
was a managed->native, native->managed or managed->managed call. The implementation
was also overcomplicated since it was a tweaked copy from System V x64 value type
ABI with scenarios and conditions that wouldn’t apply to the Windows x64 value
type ABI. Having a uniform value type ABI when possible regardless of managed->native,
native->managed or managed->managed calls simplifies scenarios and reduce complexity.

While all the above are legitimate reasons the primary driving factor behind
the rewrite was a different issue. There are .NET wrapper libraries around DirectX API
used by game engines and other libraries that uses a pattern using a call into a stub
managed method that gets patched directly in the MSIL to a calli that will end up in a
native DirectX vtable method. In current ABI we can’t detect scenario like this, so arguments
are passed as if the call was a managed->managed call causing issues for value types. Since DirectX
uses value types a lot (vectors, matrixes etc.), this was a blocker getting these technologies
running on Windows using DirectX at all. Another approach could be to change the behavior of the
library, but this would require a major redesign of the library and since several of these libraries
are mature, that wasn’t a realistic option, especially since MS .NET runtime handles the libraries as is
without modifications.

The rewrite makes sure Windows x64 value type ABI follow the platform value type ABI in all scenarios.
mono/mini/mini-amd64.c
mono/mini/mini-amd64.h