liveBook · Manning

Machine language

As explained in .NET in Action, Second Edition

Machine code is processor-executable instructions encoded in a form that a computer's hardware can directly execute.

Machine code is a processor-executable form of instructions. It must match a processor instruction set, such as x86 or ARM, and may also depend on the operating system. .NET takes a different route: language compilers produce CIL, which the .NET runtime translates into machine code. section 1.5.1 section 1.5.2

The compilation route determines when platform-specific machine code is produced:

  • A native build targets a specific processor and operating system; other targets may require different compilers or builds. section 1.5.1
  • .NET compilers put CIL in a DLL. The runtime JIT-compiles only code about to be used, producing machine code for the current processor. section 1.5.1 section 1.5.2

Ahead-of-time compilation

When the deployment processor and operating system are known, AOT can compile code ahead of time and reduce startup waiting; unused-code trimming should be tested because it can remove too much. section 1.5.2

Figure 1.4 .NET languages compile to CIL in a DLL file that can be run on any machine with a .NET runtime.

Use the diagram to follow the path from .NET language compilation to a CIL DLL and runtime conversion into machine code. section 1.5.1

How .NET in Action, Second Edition covers it

How deep it goes
Explains processor and operating-system constraints, runtime JIT compilation, and code compiled as needed; mentions AOT without detailing its use.
Examples
Uses x86 and ARM instruction sets, Android-versus-Windows compatibility, and AOT deployment when the target is known.
What you can do after
Understand how processor and operating-system targets shape machine-code builds and how .NET produces machine code at runtime.
How it connects
Connects machine code to instruction sets, CIL, JIT compilation, AOT compilation, and the .NET runtime.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.