sscli (shared source common language infrastructure)

21
SSCLI (Shared Source Common Language Infrastructure) (code name: Rotor)

Upload: dysis

Post on 13-Jan-2016

38 views

Category:

Documents


1 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: SSCLI (Shared Source  Common Language Infrastructure)

SSCLI(Shared Source

Common Language Infrastructure)

(code name: Rotor)

Page 2: SSCLI (Shared Source  Common Language Infrastructure)

Terms, Abbreviations:

• CLI

• SSCLI

• CLR = Common Language Runtime

• ECMA = European Computer Manufacturers Association

Page 3: SSCLI (Shared Source  Common Language Infrastructure)

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

Page 4: SSCLI (Shared Source  Common Language Infrastructure)

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;

Page 5: SSCLI (Shared Source  Common Language Infrastructure)

SSCLI and CLRVS.NETVS.NET

Common Language RuntimeCommon Language Runtime

System System

System.Data (ADO.NET) System.Xml

Design

ADO

Adapters

SQL

Globalization

Diagnostics

Configuration

Collections

Resources

Reflection

Net

IO

Threading

Text

ServiceProcess

Security RuntimeInteropServices

Remoting

Serialization

XPath

XSLTSerialization

System.Drawing

JITGC

MSIL

App Domain Loader

Common Type System Class Loader

System.Web

Configuration

SessionStateCachingSecurity

System.Web.Services

DescriptionProtocols

UIHtmlControls

WebControls

Discovery

C#

VC/MC++ Imaging

Drawing2D

Text

Printing

JScript

VB

Operating System or Platform Abstraction LayerOperating System or Platform Abstraction LayerBoot Loader

SyncThreads

Networking

Timers Filesystem

System.WinForms

Design ComponentModel

Debugger

Designers

SDK ToolsSDK Tools

CorDBG

ILAsm

ILDbDump

SN

ILDAsm

MetaInfo

PEVerify

EC

MA

-335

Page 6: SSCLI (Shared Source  Common Language Infrastructure)

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

Page 7: SSCLI (Shared Source  Common Language Infrastructure)

What is CLI? (second view)

1. A common type system• different types in different components are

represented in a unique way• enables language integration

2. Execution engine virtual machine with garbage collection

and exception handling• execution is assisted by code that runs with

your own code

Page 8: SSCLI (Shared Source  Common Language Infrastructure)

3. Integral security system with verification• malicious component cannot run• ! cannot hurt other components

4. File format• PE/COFF format with extensions (executable

format)• an extensible metadata system – file

implementing a type is saved

5. Intermediate language• CLI – a way independent of processor to

represent behavior

Page 9: SSCLI (Shared Source  Common Language Infrastructure)

6. A factored class library• a “modern” equivalent to C runtime

7. Access to underlying platform• PAL = Platform Adaptation Layer• interoperability between languages

Page 10: SSCLI (Shared Source  Common Language Infrastructure)

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

Page 11: SSCLI (Shared Source  Common Language Infrastructure)

CLI is: – a standard specification for a virtual execution

environment– a data-driven architecture

• data are called metadata – 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

Page 12: SSCLI (Shared Source  Common Language Infrastructure)

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

Page 13: SSCLI (Shared Source  Common Language Infrastructure)

Conclusion:

CLI resembles the traditional toolchain of compiler, linker and loader as it performs in-memory layout, compilation, symbolic resolution

Page 14: SSCLI (Shared Source  Common Language Infrastructure)

Execution scheme of .NET

CompilerSource code

IL & Metadata

Class LoaderClass Libraries(IL & Metadata)

JIT Compilerwith optional verification

Managed Native Code

Trusted,pre-JITedcode only

Execution

Call to anuncompiled

method

RuntimeEngine

Page 15: SSCLI (Shared Source  Common Language Infrastructure)

Fudamentals Concepts in CLI Specification

1. 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

Page 16: SSCLI (Shared Source  Common Language Infrastructure)

.NET common type system

Page 17: SSCLI (Shared Source  Common Language Infrastructure)

• 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.

Page 18: SSCLI (Shared Source  Common Language Infrastructure)

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

Page 19: SSCLI (Shared Source  Common Language Infrastructure)

• 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)

Page 20: SSCLI (Shared Source  Common Language Infrastructure)

Example:

#using <mscorlib.dll>using namespace System;_value public class VTPoint{public: int m_x, m_y;};int main(void){

VTPoint a; // on stackVTPoint *ptr = new VTPoint(); // on heap – illegal!_box VTPoint *VTptr = _box(a) // boxVTptr->m_x = 42;VTPoint b = *dynamic_cast<VTPoint*>(VTptr); // unboxb.m_y = 42;Console::Writeline(b.m_x);Console::Writeline(b.m_y);

}

Page 21: SSCLI (Shared Source  Common Language Infrastructure)

• Shared source CLI:http://msdn.microsoft.com/net/sscli

• ECMA specs:http://msdn.microsoft.com/net/ecma

• Microsoft commercial C# and CLR SDKhttp://msdn.microsoft.com/downloads

• Shared source info:http://www.microsoft.com/sharedsource

http://www.microsoft.com/windows/embedded/ce