News for hackers. Stuff that matters.
Re:A Look at the Internals of 'Tiered JIT Compilation' in .N... by naasking on Tuesday December 19, 2017 @10:16AM (#15960736)
You can see a few tricks in my project here: https://github.com/naasking/Dynamics.NET

You can use static classes to cache information about types. That project caches delegates to perform deep copies, to invoke constructors, to check for deep immutability, and whether a type can contain any cycles. This is all done structurally via reflection, but the results are executed only once and cached in static fields by exploiting runtime types.

The cached delegate trick can be used whenever you need to some efficient dynamic dispatching. I use it here [1] in another project to cache the Dapper methods that would be invoked so I can easily compose smaller queries into larger ones that return very complicated objects.

A more complicated example would be the fastest immutable dictionary available for .NET in my Sasa library [2]. Generic methods and types defined on structs are JITted separately, so the dispatching overhead is low. I exploit this to create a very efficient hash array mapped trie.

[1] https://github.com/naasking/Dapper.Compose/blob/master/Dappe...

[2] https://sourceforge.net/p/sasa/code/ci/default/tree/Sasa.Col...

There are no comments on this comment yet.