JIT compiler and type constructors (.cctors)

I get this question a lot ‘When do class constructors (.cctor) get run’ My answer is usually: ‘It depends’ From Partition 1 of the ECMA spec (http://msdn.microsoft.com/netframework/programming/clr/default.aspx) The semantics of when, and what triggers execution of such type initialization methods, is as follows: 1.             A type may have a type-initializer method, or not. 2.              A…

9

The world is a better place if you generate verifiable IL

If you are writing a compiler that targets IL or just emitting IL, you may find this an interesting read:   The JIT compiler will always try to generate code, even if the IL is bad. From the JIT’s point of view, IL code falls in 3 categories:   1)       Verifiable IL. Most of the…

14