Can I take advantage of JIT compiler optimizations such as method inlining and enrigistation?
Yes you can, although it may not be obvious and it’s hard to do in many cases. Please keep in mind that any attempt to take advantage of JIT optimizations should not be a motivation or excuse for a code which is poorly architected and hard to maintain. Method Inlining The .NET Compact Framework JIT compiler will inline simple methods to eliminate the cost associated with a method call. Inlining involves replacing the method’s argumenets with the values passed at call time, and eliminating the call completely. The inlining rules differ from version to version of the Compact Framework. In version 1.0, only very simple functions that returned a field from their “this” argument or a constant value could be inlined. In version 2.0, the rules are more generous but are still severely limited. In order to be inlined, a method must have: – 16 bytes of IL or less – No branching (typically an “if”) – No local variables – No exception handlers – No 32-bit floating point arguments or return value –