Shared Source CLI Essentials

Book description

Microsoft's Shared Source CLI (code-named "Rotor") is the publicly available implementation of the ECMA Common Language Infrastructure (CLI) and the ECMA C# language specification. Loaded with three million lines of source code, it presents a wealth of programming language technology that targets developers interested in the internal workings of the Microsoft .NET Framework, academics working with advanced compiler technology, and people developing their own CLI implementations. The CLI, at its heart, is an approach to building software that enables code from many independent sources to co-exist and interoperate safely. Shared Source CLI Essentials is a companion guide to Rotor's code. This concise and insightful volume provides a road map for anyone wishing to navigate, understand, or alter the Shared Source CLI code. This book illustrates the design principles used in the CLI standard and discusses the complexities involved when building virtual machines. Included with the book is a CD-ROM that contains all the source code and files. After introducing the CLI, its core concepts, and the Shared Source CLI implementation, Shared Source CLI Essentials covers these topics:

  • The CLI type system

  • Component packaging and assemblies

  • Type loading and JIT Compilation

  • Managed code and the execution engine

  • Garbage collection and memory management

  • The Platform Adaptation Layer (PAL): a portability layer for Win32®, Mac OS® X, and FreeBSD

Written by members of the core Microsoft® team that designed the .NET Framework, Shared Source CLI Essentials is for anyone who wants a deeper understanding of what goes on under the hood of the .NET runtime and the ECMA CLI. Advanced .NET programmers, researchers, the academic community, and CLI implementers who have asked hard questions about the .NET Framework will find that this behind-the-scenes look at the .NET nucleus provides them with excellent resources from which they can extract answers.

Table of contents

  1. Shared Source CLI Essentials
    1. Preface
      1. The Rotor Distribution
      2. Who Should Read This Book
      3. How This Book Is Structured
      4. Assumptions This Book Makes
      5. Online CLI Resources
      6. Conventions Used in This Book
      7. How to Contact Us
      8. Acknowledgments
        1. David Stutz
        2. Ted Neward
        3. Geoff Shilling
    2. 1. Introducing the CLI Component Model
      1. The CLI Virtual Execution Environment
        1. Fundamental Concepts in the CLI Specification
          1. Types
          2. A shared type system and intermediate language
          3. Portable packaging for types: assemblies
          4. Component isolation : application domains and remoting
          5. Naming conventions for version-flexible loading
          6. JIT compilation and typesafety
          7. Managed execution
          8. Enabling data-driven extensibility with metadata
      2. A CLI Implementation in Shared Source: Rotor
          1. The CLI execution engine
          2. Programming libraries in the CLI
          3. The Platform Adaptation Layera
          4. Tools, compilers, tests, documentation, and utilities
        1. Scoping This Book
        2. Summary
    3. 2. Getting Started with Rotor
      1. A Simple Component Assembly
        1. Configuring the Environment
        2. Creating an Echo Component
        3. Exercising the Echo Component
        4. Bootstrapping the Loading Process
        5. Debugging the Rotor Execution Engine
      2. Observing Managed Execution
      3. Looking Ahead
    4. 3. Using Types to Describe Components
      1. Types and Type Systems
        1. Type, Object, and Component
          1. Type
          2. Object
          3. Component
        2. Type Systems, More Formally Defined
        3. Types as Contracts
        4. Types and Their Behavior
        5. Type Evolution Through Versioning
        6. Component Self-Description
      2. More on Value Types
        1. Working with Values
          1. Coercion and conversion
          2. Boxing/unboxing
      3. More on Reference Types
        1. General Principles
        2. Interfaces
        3. Delegates and Managed Pointers
        4. Identity and Equality for Reference and Value Types
      4. Type Interoperability
        1. Built-in Types
        2. Wrapper Classes, Marshaling, and Interop
      5. Using Types in Data-Driven Code
      6. Summary
    5. 4. Extracting Types from Assemblies
      1. Type Packaging
        1. Assemblies Are Self-Describing
        2. Assemblies Are Location-Agnostic
        3. Loading Assemblies by Name
        4. Binding to Versioned Assemblies
        5. Key-Based Binding to Assemblies
        6. Sharing Assemblies on a Computer
        7. Binding Scenarios
          1. Step one: Baseline
          2. Step two: The GAC
          3. Step three: Versioning
          4. Step four: Side-by-side versioning
        8. Configuring How Assemblies Load
          1. Influencing binding policy
        9. Validating Assemblies for Consistency
      2. Application Domains
        1. Agile Components
      3. Bootstrapping the Assembly Load Process
      4. Securing Against Harmful Assemblies
      5. Summary
    6. 5. Synthesizing Components
      1. The Anatomy of a Component
        1. Component Instance Structure
        2. The Hierarchy of Runtime Metadata
          1. More about MethodTables
          2. EEClasses
        3. Viewing the Type, Method, and Interface Tables
          1. Using WinDbg and the SOS debugger extension
          2. Loading the executable for debugging
          3. Halting execution
          4. Viewing internal structures
        4. Laying Out Method and Interface Tables
          1. Method layout and interface maps
      2. Verifying and Compiling CIL
        1. Verification and JIT Compilation
      3. Calling Conventions in Managed Code
        1. The JIT Calling Convention
        2. x86 as a Native Calling Convention Example
        3. Other Calling Conventions
      4. Emitting Components Dynamically
          1. The API
          2. The implementation
      5. Summary
    7. 6. Regulating the Execution Engine
      1. Threads
        1. Setting Up a Managed Thread
      2. Traversing the Execution Engine Stack
        1. Annotating the Stack with Frames
        2. Categorizing Frames
          1. Annotating data
          2. Marking transitions
        3. Stackwalking
        4. Stackwalking Example: Enforcing Code Access Security
      3. Threading and Concurrency
        1. Managing Threads
          1. Thread states
        2. Scheduling Execution Using the Threadpool
      4. Synchronizing Concurrent Access to Components
      5. Handling Component Exceptions
        1. CLI Exception Model
        2. Throwing Exceptions
        3. Handling Exceptions
        4. Unwinding the Stack
      6. Summary
    8. 7. Managing Memory Within the Execution Engine
      1. Memory and Resource Management
      2. Organizing and Allocating Dynamic Memory
        1. Object Allocation by Generation
        2. Large Object Allocation
        3. The Write Barrier
      3. Reclaiming Memory
        1. Promoting Ephemeral Survivors
        2. Relocation Fix-Up
        3. Marking the Elder Generation
        4. Reclaiming Memory by Sweeping
      4. Structuring Metadata for Collection
      5. Scheduling Collection
      6. Finalization
      7. Summary
    9. 8. Interlude: Enabling Component Integration with Metadata
      1. Altering Metadata Representation
      2. Transforming Metadata in the CLI
        1. Serializing Components by Using Metadata
        2. Creating Proxies Using Metadata
      3. Metadata in Action
    10. 9. The Platform Adaptation Layer
      1. PAL Overview
      2. Common Infrastructure
        1. Sharing Memory Between Unix Processes
        2. The Handle Manager
      3. Processes and Threads
        1. PAL Processes
        2. Controlling PAL Processes
        3. Threads
        4. Thread Local Storage
      4. Synchronizing Processes and Threads
        1. Critical Sections
        2. The BlockingPipe and the ThreadWaitingList
        3. Semaphores
        4. Events
        5. Mutexes
      5. Implementing Signaling
      6. Suspending and Resuming PAL Threads
      7. Asynchronous Procedure Calls
      8. Handling Exceptions in the PAL
        1. Handling Signals with Exception Handlers
        2. Managing Exception State
        3. Raising Exceptions and Unwinding the Stack
      9. Managing Memory with the PAL
        1. Protecting Memory
        2. Reserving Versus Committing Memory
        3. Updating Memory with Interlocked Instructions
      10. Exploring the Rest of the PAL
        1. Locking File Regions in Multiple Processes
        2. Asynchronous Socket Operations
      11. Joining Components to the OS
    11. A. A Quick Tour of Rotor
    12. B. Building Rotor
        1. Build Mode
        2. Windows Prerequisites
        3. FreeBSD Prerequisites
        4. Mac OS X Prerequisites
      1. Building Rotor on Windows
      2. Building Rotor on Unix
      3. Tests
        1. PAL Test Suite
        2. SSCLI Quality Suites
      4. Build Scenarios
        1. Primary Bootstrap
        2. Secondary Bootstrap
        3. Core Elements
        4. FX Class Libraries
        5. Managed-Class Libraries
        6. Managed Compilers
      5. Troubleshooting
    13. C. Porting Rotor
    14. D. Rotor Macrology
      1. General Macros
      2. Execution Engine Macros
      3. JIT Compiler Macros
      4. PAL and Platform Macros
    15. Index
    16. Colophon

Product information

  • Title: Shared Source CLI Essentials
  • Author(s): David Stutz, Geoff Shilling, Ted Neward
  • Release date: March 2003
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596003517