I'm working on a Json serialization solution.
I found out that the serialization based on emitting was much faster than direct operations on Reflection api after the emitted code had already been run once(each time with different data).
Obviously the problem is JIT. This can be verified if you check the implementation of Runtime.CompilerServices.RuntimeHelpers._CompileMethod
in DynamicMethod.CreateDelegate
, which is a QCall method. It only generates a Prestub for the MethodDescriptor of DynamicMethod.
So I wonder wether there is a way to force the compilation of DynamicMethod. The PreJIT feature,provided by Runtime.CompilerServices.RuntimeHelpers.PrepareMethod
, simply doesn‘t work because I have no direct access to RuntimeMethodHandle of DynamicMethod. So is there other (legal) way to achieve this goal?
Thanks in advance.