Generate tail call opcode

C# compiler does not give you any guarantees about tail-call optimizations because C# programs usually use loops and so they do not rely on the tail-call optimizations. So, in C#, this is simply a JIT optimization that may or may not happen (and you cannot rely on it). F# compiler is designed to handle functional … Read more

Why is it necessary to call :this() on a struct to use automatic properties in c#?

Note: as of C# 6, this isn’t required – but you should be using read-only automatically-implemented properties with C# 6 anyway… this() makes sure that the fields are definitely assigned as far as the compiler is concerned – it sets all fields to their default values. You have to have a fully constructed struct before … Read more

Profiling a dynamic pinvoke

The profiler APIs are returning metadata specified in the managed code, normally via the DllImportAttribute. In the case of the ‘dynamic pinvoke’ which uses the Marshal.GetDelegateForFunctionPointer method, the module and function names were never specified as metadata and not available. An alternative approach to dynamic pinvoke declarations that includes the required metadata will probably avoid … Read more

Call and Callvirt

When the runtime executes a call instruction it’s making a call to an exact piece of code (method). There’s no question about where it exists. Once the IL has been JITted, the resulting machine code at the call site is an unconditional jmp instruction. By contrast, the callvirt instruction is used to call virtual methods … Read more