Is CallingConvention ignored in 64-bit .NET applications?

When interacting with a 64-bit native library through an explicitly 64-bit .NET application through P / Invoke, is this CallingConvention property in DllImport effectively ignored?

I ask this because on โ€œtraditionalโ€ x86 you need to specify the way in which the caller or callee clears the stack variable stack (as well as how the function itself can use certain processor registers, etc.); but, as I understand it, x64 has only one convention, __fastcall (despite the recent addition of __vectorcall ).

So, the CLR just goes ahead and calls the marshal functions using the __fastcall x64 __fastcall , regardless of what you set for the CallingConvention property?

+5
source share
1 answer

Yes, completely ignored. The 64-bit output router only supports x64 ABI , freely based on __fastcall. Very free. You will not get an exception if you specify CallingConvention, it just brushes it off.

Please note that __vectorcall is not x64 specific, there is also an x86 variant. None of them are supported by the pinvoke marshaller; you have to write a C ++ / CLI shell. It would make very little sense to support it, .NET jitters still have very weak support for SSE2 / AVX. A small bit in System.Numerics.Vector with RyuJIT jitter, the new x64 jitter that ships with VS2015 but not anywhere near the ability to pass arguments to a method. Requiring tight alignment will require a very radical re-writing of the CLR, future future music.

+9
source

Source: https://habr.com/ru/post/1240775/


All Articles