JustInTime(JIT) * JRE * JVM * .NET Framework

Kaan Özkordağ/ January 6, 2014

Today I will tell about JIT ( JustInTime ) ,  JRE , JVM , .Net framework and what they are and how they work … and what are the terminologies like CIL and bytecode are … what about compiling terminologies and compiling techniques.

What is JIT  ( JustInTime Compiler )

Generally what does Just In Time (JIT) compiler do? To understand well if we would explain it very superficially and basically  ; when you compile the  program that you wrote with a high level language like C# , Java, VB or Python , first the code is converted into an Intermediate Language that called  CIL (Common Intermediate Language) in .NET(C#) and  byteCode in Java . When you run your compiled program in somewhere, then JIT takes that intermediate language or bytecode and make a last and very fast compilation for representation.

so let’s see what we learned ;

CIL : Common Intermediate Language is a language in a lower level from C# , or Java like languages.

ByteCode : In java , if we compile a program it returns into an intermediate language that called ByteCode for Java programmers.

So let’s talk about what is .NET and what is the provision of .Net in JAVA ;

What is .NET Framework

.NET framework  is an engine that includes the knowledge and needed libraries of  variety of languages for compile that .Net compatible like  C# , J# , Visual basic and… understands what to do with the compiled code on run-time to provide a language independent environment for programmer . Don’t be confused ; this is not for the first compilation. First compilation is always made by C# or VB  Compiler (or what the code has been written with) and the Intermediate Code compiled from that high level code will be converted into machine code by JIT  in .net Framework for presentation  when you run the program. So we must understand that when you run the program (that has been compiled -to the intermediate language that fits your machine architecture-) before execution Just In Time Compilation occurs for presentation.   dotNET has a common library at the Common Language Infrastructure Level for all dotNet compatible Languages.  So after all ,  a question may come : ” What is the  difference between CLR(Common Language Runtime) and JIT(Just in Time compiler)”

How does JustInTime works !

  1. The boot straper initializes the CLR (mainly by loading the mscorlib assembly) and instructs it to execute your assembly.
  2. The CLR executes your main entry.
  3. Now, classes have a vector table which hold the addresses of the method functions, so that when you call  MyMethod, this table is searched and then a corresponding call to the address is made. Upon start ALL entries for all tables have the address of the JustInTime compiler.
  4. When a call to one of such method is made, the JustInTime is invoked instead of the actual method and takes control. The JIT then compiles the CIL code into actual assembly code for the appropiate architecture.
  5. Once the code is compiled the JustInTime goes into the method vector table and replaces the address with the one of the compiled code, so that every subsequent call no longer invokes the JIT.
  6. Finally, the JIT handles the execution to the compiled code.
  7. If you call another method which haven’t yet being compiled then go back to 4… and so on…

Finally …

We can say .NET has the JustInTime inside and the provision .NET in Java is JRE or JVM . But mainly JVM  and indirectly JRE. Because JRE includes JVM and JVM includes JustInTime inside. JVM (Java Virtual Machine) is an instance that created by JRE(Java runtime Engine)

And again finally , what is .NET is for and what is JRE is for ;  .NET provides language independent platform for programmer , Because in .NET environment what language you use is not important all of them can communicate with each other in Common Language Infrastructure level.  And JRE – JVM provides operating system independent  platform so if you can find JRE package for your platform every Java program works on your platform.. Aaa? may be not every program because the programmer must think if the program will be platform independent . Basically lets give an  example; if you write a program that controls windows’ system files it won’t work in linux , unix or mac  of course 🙂

Now take a pain killer and sleep a little , after you get up may be you read again 😉

See you next article …

Today , I have talked a little poetic , haven’t I  :))

Please follow and like us:

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>