Summary

Assemblies are loaded on demand, using the techniques outlined in Chapter 4. As new components are called for by application domains in the execution engine, runtime specifications are built from their metadata for in-memory layout. This information includes specifications for static and per-instance data, as well as method-dispatching tables. The dispatch tables are constructed to initially contain thunks that will trigger code compilation, rather than the method code for class behaviors that will eventually populate them. By using thunks in this way, compilation is deferred until the last possible moment, reducing startup costs.

The combination of on-demand loading and deferred compilation is called JIT compilation. Class loaders and the SSCLI JIT compiler work in conjunction with high-level language compilers to create component types. Source languages are parsed and converted into a combination of metadata and language-agnostic CIL opcodes rather than being converted directly into native microprocessor instructions, and this combination of metadata and CIL is transformed at runtime into in-memory layouts, native microprocessor instructions, and tables for the CLI’s garbage collector and exception-handling facility. The facilities of the runtime that do layout and compilation are also available to programmers in the CLI’s reflection facility.

From the perspective of the CLI component model, the stage of a component’s lifecycle during which it is loaded and compiled is a ...

Get Shared Source CLI Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.