210 likes | 402 Views
SSCLI (Shared Source Common Language Infrastructure). (code name: Rotor). Terms, Abbreviations:. CLI SSCLI CLR = Common Language Runtime ECMA = European Computer Manufacturers Association. History:. Initial goal : COM needed a companion runtime; a core set of modern services
E N D
SSCLI(Shared Source Common Language Infrastructure) (code name: Rotor)
Terms, Abbreviations: • CLI • SSCLI • CLR = Common Language Runtime • ECMA = European Computer Manufacturers Association
History: • Initial goal: COM needed a companion runtime; a core set of modern services • Final product:a complete, general-purpose virtual execution engine • Standardization effort: ECMA 5 years later
What is CLI? (first view) • approach to building software that enables code from many independent sources to coexist and interoperate safely; • a virtual computational model that can be brought up safely within existing host environments and can expose the native capabilities of these environments directly;
XSLT Serialization XPath SSCLI and CLR VS.NET System.Web System.WinForms UI SessionState C# Design ComponentModel HtmlControls Caching JScript Security WebControls System.Drawing Configuration VB System.Web.Services VC/MC++ Drawing2D Printing Protocols Imaging Text Debugger Discovery Description Designers System.Data (ADO.NET) System.Xml ADO SQL SDK Tools Design Adapters CorDBG System ECMA-335 ILAsm Collections IO Security Runtime InteropServices Configuration Net ServiceProcess ILDbDump Remoting Diagnostics Reflection Text SN Serialization Globalization Resources Threading ILDAsm Common Language Runtime MetaInfo JIT GC App Domain Loader PEVerify MSIL Common Type System Class Loader Operating System or Platform Abstraction Layer Networking Boot Loader Threads Sync Timers Filesystem
SSCLI vs .NET Framework (CLR) • JIT and garbage collector replaced with more portable, approachable implementations • Windows-specific features not included: COM interoperability, WinForms, other integration • also not included: ADO.NET, enterprise services, NGEN (JIT-ahead), ASP.NET
What is CLI? (second view) • A common type system • different types in different components are represented in a unique way • enables language integration • Execution engine • virtual machine with garbage collection and exception handling • execution is assisted by code that runs with your own code
Integral security system with verification • malicious component cannot run • ! cannot hurt other components • File format • PE/COFF format with extensions (executable format) • an extensible metadata system – file implementing a type is saved • Intermediate language • CLI – a way independent of processor to represent behavior
A factored class library • a “modern” equivalent to C runtime • Access to underlying platform • PAL = Platform Adaptation Layer • interoperability between languages
SSCLI include: • JScript compiler – shows dynamic techniques (in C#) • C# compiler – shows nearly all runtime features • IL Assembler – shows low-level API implementation and use
CLI is: • a standard specification for a virtual execution environment • a data-driven architecture • data are calledmetadata – used by developer tools to describe behavior of software, has in-memory characteristics • CLI execution engine uses metadata to enable components from different sources to be loaded together safely
Assemblies (abstract types + behavior) executables are loaded + validated comp. metadata is loaded in isolation comp. types are verified, laid out + compiled exec.engine uses data on stack + heap to maintain control of the code that has tailored for the local OS+processor
Conclusion: CLI resembles the traditional toolchain of compiler, linker and loader as it performs in-memory layout, compilation, symbolic resolution
Execution scheme of .NET Source code Compiler IL & Metadata Class Libraries (IL & Metadata) Class Loader JIT Compiler with optional verification Trusted, pre-JITed code only Call to an uncompiled method Managed Native Code Runtime Engine Execution
Fudamentals Concepts in CLI Specification • Types: • describe fields and properties that hold data + methods and events that describe behavior • strong typed = each variable, object a.s.o. has a type
Unique representation of data types must be adopted • CLR (CLI) type system is divided into two subsystems: • Value types • Reference types • Ma jor distinction: value types have no concept of identity; • Value type is a sequence of bits in memory • Reference type is a combination of a location, its identity, and a sequence of bits.
Value types • Many inbuilt data types are value types, but not limited to that; • Are often allocated on the run time stack, but can be allocated to headp also (data member of an object type) • User-defined structures and classes can be value types and can contain: • methods (both class and instance) • fields (both class and instance) • properties • events
not possible to have a value type inherit from another value type; in .NET Framework terminology, value type is sealed • for all value types, there exists a corresponding object type = boxed type. Values of any value type can be boxed and unboxed: • boxing a value type – copies the data from the value into an object with a corresponding boxed type, allocated on the garbage-collection heap; • unboxing a value type – copies the data from the boxed object into a value • why? : have benefits of object types (may support interface types)
Example: #using <mscorlib.dll> using namespace System; _value public class VTPoint {public: int m_x, m_y; }; int main(void) { VTPoint a; // on stack VTPoint *ptr = new VTPoint(); // on heap – illegal! _box VTPoint *VTptr = _box(a) // box VTptr->m_x = 42; VTPoint b = *dynamic_cast<VTPoint*>(VTptr); // unbox b.m_y = 42; Console::Writeline(b.m_x); Console::Writeline(b.m_y); }
Shared source CLI: http://msdn.microsoft.com/net/sscli • ECMA specs: http://msdn.microsoft.com/net/ecma • Microsoft commercial C# and CLR SDK http://msdn.microsoft.com/downloads • Shared source info: http://www.microsoft.com/sharedsource http://www.microsoft.com/windows/embedded/ce