1

When does the Just-In-Time (JIT) compiler convert your application methods and program blocks from Common Intermediate Language (CIL) to native machine code?

Sybs77
  • 19
  • 2
  • 1
    Some might suggest that the clue is in the name. – Damien_The_Unbeliever Mar 21 '18 at 11:35
  • 3
    The name "just in time" is more apt than you think -- it generally really does wait until the method is called for the very first time. – Jeroen Mostert Mar 21 '18 at 11:35
  • And later it can change it's mind over how the Function should be represented (dead code detection, array access optimisations, Inlining) and just do it again. – Christopher Mar 21 '18 at 11:48
  • @Christopher - the current JIT for desktop .NET does not, and that's the most commonly expected JIT in the context of C#. I believe the Java JIT compiler(s) and some javascript ones have multiple levels of optimization but these don't exist in .NET currently. – Damien_The_Unbeliever Mar 21 '18 at 11:52
  • @Damien_The_Unbeliever: Oh, the .NET JiT can inline. And as of 4.5, it even got a lot more agressive: http://blogs.microsoft.co.il/sasha/2012/01/20/aggressive-inlining-in-the-clr-45-jit/ – Christopher Mar 21 '18 at 12:01
  • @Christopher - I was more referring to the "change it's mind" part of your comment. .NET JIT doesn't re-compile currently, which is what I though you were referring to. – Damien_The_Unbeliever Mar 21 '18 at 12:07
  • It is too broad to describe (even in great books). Now .NET Core CLR is open source (along with Microsoft internal materials on how it works), so when you have time, read them https://github.com/dotnet/coreclr/tree/master/Documentation – Lex Li Mar 21 '18 at 14:08

0 Answers0