Spreads.Unsafe | Unsafe package with additional methods
kandi X-RAY | Spreads.Unsafe Summary
kandi X-RAY | Spreads.Unsafe Summary
This library adds several methods to System.Runtime.CompilerServices.Unsafe [package] that are used in [Spreads library] to get the maximum performance. It could be compiled from a working repo of [corefx] if placed alogside with S.R.CS.U folder. The added methods emit a constrained call to instance methods of known interfaces on instances of a generic type T without a type constraint where T : IKnownInterface.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Spreads.Unsafe
Spreads.Unsafe Key Features
Spreads.Unsafe Examples and Code Snippets
Community Discussions
Trending Discussions on Spreads.Unsafe
QUESTION
Calli opcode requires a calling convention. By default it is stdcall
, while extern "C"
in native libraries uses cdecl
.
JIT recently allowed to inline methods with calli
, but only with default calling convention. When I call a method with calli
without unmanaged cdecl
it works on x64
and performance is 58% faster than DllImport
and 2.2x faster than unmanaged function pointer
. (on netcoreapp2.1
, on net471
the difference is bigger: 82% and 5.5x ) When I run a method with calli unmanaged cdecl
, performance is on par with DllImport
(around 1% slower).
I have read that on x64 there is no longer a mess with stdcall
vs cdecl
and all methods use cdecl
(or fastcall
, seen that in another place, cannot find a link). The difference only applies to x86
, where my call without unmanaged cdecl
does indeed crash the app with segfault.
The method in question is the following. For tests I use noop native method only to measure native call overhead.
...ANSWER
Answered 2018-Sep-22 at 20:48The answer is, it is not safe. See this discussion at dotnet/coreclr: https://github.com/dotnet/coreclr/issues/19997
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Spreads.Unsafe
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page