Health Warning



Yüklə 0,51 Mb.
tarix07.11.2018
ölçüsü0,51 Mb.
#78938



Health Warning

  • This talk dives deep!

  • Examines internal data structures

  • They will change!

  • Internals knowledge not needed to write .NET apps



Quick Refresher: The Unmanaged World



Quick Refresher: The CLR



Agenda



1. Compilation



Agenda



2. Packaging: Assemblies



2. Metadata IL – Intermediate Language

  • IL – The language for execution

  • Independent of CPU and platform

    • Created by Microsoft, external commercial and academic language/compiler writers
  • Stack based virtual machine:



2. Metadata IL – Intermediate Language

  • IL – The language for execution

  • Independent of CPU and platform

    • Created by Microsoft, external commercial and academic language/compiler writers
  • Stack based:



2. Metadata IL – Intermediate Language

  • IL – The language for execution

  • Independent of CPU and platform

    • Created by Microsoft, external commercial and academic language/compiler writers
  • Stack based:



2. Metadata IL – Intermediate Language

  • IL – The language for execution

  • Independent of CPU and platform

    • Created by Microsoft, external commercial and academic language/compiler writers
  • Stack based:



2. Metadata IL – Intermediate Language

  • IL – The language for execution

  • Independent of CPU and platform

    • Created by Microsoft, external commercial and academic language/compiler writers
  • Stack based:



2. Metadata IL – Intermediate Language

  • IL – The language for execution

  • Independent of CPU and platform

    • Created by Microsoft, external commercial and academic language/compiler writers
  • Stack based:



2. Metadata IL – Intermediate Language

  • IL – The language for execution

  • Independent of CPU and platform

    • Created by Microsoft, external commercial and academic language/compiler writers
  • Stack based:



2. Metadata IL – Intermediate Language

  • IL – The language for execution

  • Independent of CPU and platform

    • Created by Microsoft, external commercial and academic language/compiler writers
  • Stack based:



2. Metadata IL – Verification

  • When processing IL, runtime verifies the IL to make sure it’s “safe”

    • Every IL construct is called with the correct amount of stack parameters
    • Every method is called with the correct type and number of parameters
  • Helps prevents buffer overflows, underruns

  • Helps prevent security holes

  • Safety allows multiple managed applications in the same process



Agenda



3. Loading and Layout Startup logic

  • OS hands the image to a CLR shim (mscoree.dll)

  • Which starts the runtime

  • Runtime performs the following:

    • Loads assembly in to memory and sets up the MD reader
    • Resolves immediate dependencies
    • Slurps metadata, creates internal data structures
    • Starts execution at Assembly entry point


Agenda



4. Execution Invocation



4. Execution Invocation – JIT output



4. Execution JIT Optimizations

  • Register Allocation

    • locals, temps, evaluation stack
  • Loop unroll

  • Dead code elimination

  • #define SOMETHING 0 if (SOMETHING > 10) a = x; // dead code statement

  • Constant and Copy propagation

  • Processor specific code generation



4. Execution JIT Optimizations

  • Range check elimination



Agenda



5. Runtime services A look at the Garbage Collector

  • Reference tracking (tracing) GC

  • Large object heap – objects over 80k

  • Generational (three gen)

  • Mark sweep and compact



Agenda



More Information

  • My Blog: http://blogs.msdn.com/brada



Questions?



BACKUP



New runtime features for V2.0

  • Generics

  • 64 bit (Itanium and x86-64)

  • ReflectionOnly context

  • Delegate Relaxation

  • Lightweight Code Generation

  • NGen/NGen services

  • Stub based dispatch

  • MDbg

  • Edit and Continue

  • BCL Enhancements



Generational GC



Generational GC

  • Generations Dynamically Tuned

  • Older Generations are Larger / More Stable

    • Require Collection Less Often
    • Are More Expensive to Collect
    • Can Have References to Newer Objects


What is Generics?

  • Type checking, no boxing, no downcasts

  • Increased sharing (typed collections)

  • Instantiated at run-time, not compile-time

  • Work for both reference and value types

  • Code shared for reference types

  • Exact run-time type information



What is Generics?



C# Generics



Bits & bytes under the hood

  • New metadata tables

  • Flags defines variance and special constraints

  • GenericParamConstraint defines type constraints



Implementation choices

  • Code sharing

  • Code specialization

    • C++ templates uses specialization
    • Code bloat can be a problem


4. Execution JIT Optimizations

  • JIT Inlining (method example)



4. Execution JIT No inline == SLOW



4. Execution NextFib() method



4. Execution JIT Inlining == FAST!



Yüklə 0,51 Mb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə