270 likes | 478 Views
Session Code: ARC413. “Whidbey” CLR Internals. Jonathan Keljo jkeljo@microsoft.com Program Manager Microsoft Corporation. Tools. Client Application Model. Web & Service Application Model. Data Systems Application Model. Mobile PC & Devices Application Model. Command Line.
E N D
Session Code:ARC413 “Whidbey” CLR Internals Jonathan Keljo jkeljo@microsoft.com Program Manager Microsoft Corporation
Tools Client Application Model Web & Service Application Model Data Systems Application Model Mobile PC & Devices Application Model Command Line Compact Framework System.Console Win FS Yukon Mobile PC Optimized Avalon Windows Forms ASP.NET / Indigo NTService System.Data.SqlServer System.Windows.Forms System.Windows System.Storage System.Web System.Windows System.Windows.Forms System.ServiceProcess Communication Data Presentation System.Collaboration System.Search System.Discovery System.Data System.Windows System.Messaging SqlClient DataSet RealTimeEndpoint UI Element Explorer Media Annotations System.DirectoryServices ActiveDirectory TransientDataSession SqlTypes Mapping Documents Controls Animation System.Remoting Monitoring SignalingSession SqlXML ObjectSpaces Text Element Dialogs Controls System.Runtime.Remoting Logging Uddi Media OdbcClient ObjectSpace Shapes SideBar Control Relevance Activities OleDbClient Query Shape Notification Panel Navigation OracleClient Schema Ink Design System.Web.Services System.MessageBus Transport Queue Web.Service System.Storage Port PubSub System.Windows.Forms System.Web.UI Description Item Core Channel Router Forms Page WebControls Discovery Relationship Contact Service Policy Control Control Adaptors Protocols Media Location Peer Group Print Dialog HtmlControls Design Audio Message Design MobileControls Video Document System.Net System.Web Images Event HttpWebRequest NetworkInformation System.Help System.Speech Personalization System.Xml FtpWebListener Sockets System.Drawing Recognition Synthesis Caching Schema Xpath SslClientStream Cache SessionState System.NaturalLanguageServices Serialization Query WebClient Fundamentals Security Base & Application Services Configuration Deployment/Management System.Windows.TrustManagement System.Timers System.Text System.Web.Configuration System.Collections System.Web System.Security System.Globalization System.Design Generic System.MessageBus.Configuration Administration Permissions Authorization System.Web.Security System.Serialization System.IO System.Configuration Management System.ComponentModel Policy AccessControl System.Threading Ports System.Resources System.CodeDom Principal System.Management Credentials System.MessageBus.Security System.Runtime System.Reflection Token Cryptography System.Deployment Serialization InteropServices System.EnterpriseServices System.Diagnostics CompilerServices System.Transactions
The Big Picture IDE Debugger Editor Compiler Source Files Frameworks (BCL, WinFX, etc.) EXE (IL) CLR JIT Loader GC Metadata Exceptions Interop Threading Remoting Security Debugging
template <class T> class Stack { … T Pop() … } Stack <int> Stack <double> Template stack class C++ Compiler Stack <point> Stack<int> … … Stack <double> … … Stack <point> … … … Main program Main program source Executable (x86) C++ Templates
class Stack<T> { … T Pop() … } Stack <T> Template stack class .NET Compiler Main program Stack<int> … … Stack <double> … … Stack <point> … … Executable (IL) Main program source CLR Generics
IL Execution topOfStack topOfStack this._array[topOfStack] this this._array this._array this._array[topOfStack] this._array[topOfStack] this Evaluation Stack
Method (0x6) … Name Signature … Push 20 01 01 13 00 .ctor 20 01 01 08 Pop 20 00 13 00 Push 20 01 01 13 00 … Generic Signatures Param 1 Type is Generic Type Parameter Instance Method (has “this”/”Me”) With 1 Parameter Void Return void Push(T toPush); 01 13 00 20 01 Param 1 is of type T “Calling Convention” # Parameters Return Type Element Type Parameter Types Type Param Index
The Big Picture IDE Debugger Editor Compiler Source Files Frameworks (BCL, WinFX, etc.) EXE (IL) CLR JIT Loader GC Metadata Exceptions Interop Threading Remoting Security Debugging
EnC – Editing a Method (1)Delta IL & Delta Metadata Delta Metadata (Provided by debugger) Full Metadata (In Running Process) 2050 20a8 0 4 Delta IL 8940 8944
EnC – Editing a Method (2)Remap IL Virtual Execution System x86 Processor Original IL Variables Original x86 .locals init (int32, int32) . . . call Console.ReadLine pop nop ret . . . call FFFFD630 pop ebx pop esi pop edi . . . New IL New x86 .locals init (int32, int32, double) . . . call Console.ReadLine pop . . . call Console.ReadLine pop nop ret . . . call FFFFD630 fild dword … fstp dword … mov ecx, edi . . . call FFFFD630 pop ebx pop esi pop edi
EnC – Editing Within a Call IL Virtual Execution System x86 Processor Original IL Variables Original x86 .locals init (int32, int32) . . . call Console.ReadLine pop nop ret . . . call FFFFD630 pop ebx pop esi pop edi . . . New IL New x86 .locals init (int32, int32, double) . . . call Console.ReadLine pop . . . call Console.ReadLine pop nop ret . . . call FFFFD630 fild dword … fstp dword … mov ecx, edi . . . call FFFFD630 pop ebx pop esi pop edi
EnC – Editing a Class (1)Delta Metadata Delta Metadata (Provided by debugger) Full Metadata (In Running Process)
Keeping Things SaneRuntime Power vs. Language Legality • Can do all kinds of crazy things with CLR’s support • Left to the languages to decide what edits make sense • Lots of potential work here • EnC-friendly codegen • Exception handling • Managing cascading effects of edits
Shameless Plug • Language Implementers’ Lunch • Thursday 11:30-1:30 • Programming Languages & Tools Track Lounge
Community ResourcesGet Your Questions Answered! • Newsgroups: • microsoft.private.whidbey.clr • Architecture & Infrastructure Lounge: 309 Foyer • connect with Microsoft infrastructure product teams, and PDC 2003 Speakers • PDC Weblogs: • http://pdcbloggers.net
Resources • Books • The Common Language Infrastructure Annotated Standard. ISBN 0-3211-5493-2 • Inside Microsoft .NET IL Assembler. ISBN 0-7356-1547-0 • Essential .NET Volume 1. ISBN 0-201-73411-7 • Shared Source CLI Essentials. ISBN 0-596-00351-X
© 2003-2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.