Closed mgravell closed 1 year ago
Re function pointers: partly perf, partly to avoid having to declare the type etc (can't use generics with spans), partly because they rock
On Wed, 3 May 2023, 16:01 Eric Erhardt, @.***> wrote:
@.**** approved this pull request.
Nice work! This is awesome. Thanks for making this library AOT-compatible.
In tests/AotTests/AotTests.csproj https://github.com/mgravell/Pipelines.Sockets.Unofficial/pull/74#discussion_r1183792683 :
@@ -0,0 +1,17 @@ +
+
Exe net7.0 enable true ⬇️ Suggested change
-
true
In src/Pipelines.Sockets.Unofficial/Arenas/PerTypeHelpers.cs https://github.com/mgravell/Pipelines.Sockets.Unofficial/pull/74#discussion_r1183811274 :
- Cast = (delegate*<Span
, Span >)concrete.MethodHandle.GetFunctionPointer(); - }
- //Cast = (CastHelper)Delegate.CreateDelegate(typeof(CastHelper), null, concrete);
(for my learning) Why function pointers here instead of a normal delegate?
— Reply to this email directly, view it on GitHub https://github.com/mgravell/Pipelines.Sockets.Unofficial/pull/74#pullrequestreview-1411067193, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEHMDNCPKCCGDDSWQLXTDXEJXNJANCNFSM6AAAAAAXTE2UUA . You are receiving this because you authored the thread.Message ID: @.*** com>
v2.2.8 should be available
Thanks! I've been studying this and your other projects @mgravell to improve the RabbitMQ .NET client.
the primary change here is to make AOT work, by removing any ref-emit, evil poking, or usage of
MakeGenericType
/MakeGenericMethod
. This last required removing someT : unmanaged
constraints (which is why we were using generics, because those scenarios couldn't be known statically), instead using evilness to keep things working - not least, a re-implementation ofMemoryMarshal.Cast<TFrom, TTo>
without theTFrom : struct, TTo : struct
constraints (runtime checked, though) usingMemoryMarshal.CreateSpan
(note: on down-level TFMs, usesMakeGenericMethod
to use the inbuiltCast
method, but that's fine: we don't need AOT on those platforms)also: