Just-in-time (JIT) compilation, also known as dynamic translation is compilation done during execution of a program. JIT compilation is a combination of the two traditional approaches to translation to machine code — ahead-of-time compilation (AOT), and interpretation — and combines some advantages and drawbacks of both. JIT compilation combines the speed of compiled code with the flexibility of interpretation, with the overhead of an interpreter and the additional overhead of compiling (not just interpreting).
The runtime topic of the .NET platform has been discussed for many times, while JIT itself, as well as a resulting code and interoperability with the execution environment, have not. Have you ever tried to explore a rationale for the lack of inheritance in structs, unbound delegate roots, as well as a technique of invoking any method without reflection?
Structs in the .NET framework are plain old structures (in terms of layout, mutability, etc.). They support OOP and .NET, the inheritance from System.ValueType, which is derived from System.Object, etc.).
To better understand why structs cannot be derived from other types, it is necessary to dig into CLR’s method organization, what is described in the following article:
As we see, we work with hardware. Variables of reference types are just addresses in memory — DWORD. Casting types is nothing more than abstraction and protection at the compile time. The CPU works with memory addresses only. CLR provides these addresses while JIT compiles code using them.
In order to understand CLR deeper, do not miss these articles as well:
In this article you will explore method dispatch of interfaces and generics (both for classes and separate methods along with real signatures), as well as how to debug release-mode assemblies with optimization. In addition, you’ll figure out the true purpose of System.__Canon. Also you will find the answers to the following questions:
- How many bytes does an object instance take in managed code?
- What’s the limit for a CLR object?
- Are there any differences between 32-bit and 64-bit systems for memory allocation?
Thanks for reading and for your attention!