• No se han encontrado resultados

La máquina virtual de.net CLR, CLI y Rotor

N/A
N/A
Protected

Academic year: 2021

Share "La máquina virtual de.net CLR, CLI y Rotor"

Copied!
12
0
0

Texto completo

(1)

La

La

plataforma

plataforma

.NET

.NET

La máquina virtual

La máquina virtual

de .NET

de .NET

CLR, CLI y Rotor

CLR, CLI y Rotor

Juan Manuel Cueva Lovelle

Juan Manuel Cueva Lovelle

cueva

cueva

@

@

lsi

lsi

.

.

uniovi

uniovi

.

.

es

es

www.

(2)

CLR

CLR

Operating System

Operating System

Common Language Runtime

Common Language Runtime

Base Class Library

Base Class Library

ADO.NET and XML

ADO.NET and XML

ASP.NET

ASP.NET

Web Forms Web Services

Web Forms Web Services

Mobile Internet Toolkit

Mobile Internet Toolkit

Windows

Windows

Forms

Forms

Common Language Specification

Common Language Specification

VB

VB

C++

C++

C#

C#

JScript

JScript

J#

J#

(3)

Hola.exe

Hola.cs

Compilador C#

PE Header

Metadata

IL Binary

Table of Contents

assembly, classes, methods,

fields, properties, events,

attributes, marshallers,

references, etc

Method Bodies

ILDASM

ILDASM

Hola

Hola

.exe

.exe

Compilando

(4)

El

(5)

Manifesto:

Manifesto:

descripción

descripción

del assembly

del assembly

Nombre

Nombre

,

,

versión

versión

,

,

cultura

cultura

Propiedades

Propiedades

de

de

Securidad

Securidad

:

:

Permisos

Permisos

Clave

Clave

pública

pública

(Public Key)

(Public Key)

Dependencias

Dependencias

de

de

otros

otros

assemblies

assemblies

Lista

Lista

de

de

clases

clases

en el assembly

en el assembly

Para

Para

cada

cada

clase

clase

:

:

Las interfaces

Las interfaces

que implementa

que implementa

Lista

Lista

de methods, fields, properties, events

de methods, fields, properties, events

Signaturas

Signaturas

(

(

argumentos

argumentos

y

y

tipo

tipo

de

de

resultado

resultado

) de

) de

cada

cada

miembro

miembro

Atributos personalizados

Atributos personalizados

(Custom attributes )

(Custom attributes )

¿

(6)

El lenguaje intermedio IL

El lenguaje intermedio IL

Trabaja sobre una máquina abstracta de

Trabaja sobre una máquina abstracta de

pila

pila

Sus operaciones fundamentales son Load y

Sus operaciones fundamentales son Load y

Store

Store

Es un ensamblador totalmente orientado a

Es un ensamblador totalmente orientado a

objetos

objetos

Se especifica el código de todos los

Se especifica el código de todos los

(7)

PEVerify

PEVerify

DEPLOYMENT

DEPLOYMENT

GAC,

GAC,

app. directory

app. directory

public static void Main(String[]

public static void Main(String[] public static void Main(String[] public static void Main(String[] argsargsargsargs )))) { String

{ String { String

{ String usrusr; usrusr; ; ; FileStreamFileStreamFileStreamFileStream f; f; StreamWriterf; f; StreamWriterStreamWriter w;StreamWriterw;w;w; try { try { try { try { usr usr usr

usr =Environment.=Environment.=Environment.=Environment.GetEnvironmentVariableGetEnvironmentVariableGetEnvironmentVariableGetEnvironmentVariable("USERNAME");("USERNAME");("USERNAME");("USERNAME"); f=new

f=new f=new

f=new FileStreamFileStreamFileStreamFileStream(“C:(“C:(“C:(“C:\\\\\\\\test.txt",test.txt",test.txt",test.txt",FileModeFileModeFileModeFileMode.Create);.Create);.Create);.Create); w=new

w=new w=new w=new StreamWriterStreamWriterStreamWriterStreamWriter(f);(f);(f);(f); w. w. w. w.WriteLineWriteLineWriteLine((((usrWriteLineusrusrusr);););); w.Close(); w.Close(); w.Close(); w.Close(); } catch (Exception e){ } catch (Exception e){ } catch (Exception e){ } catch (Exception e){

Console. Console. Console.

Console.WriteLineWriteLineWriteLineWriteLine("Exception:"+e.("Exception:"+e.("Exception:"+e.("Exception:"+e.ToStringToStringToStringToString());());());()); }}}}

}}}}

Compiler

Compiler

DEVELOPMENT

DEVELOPMENT

public static void Main(String[] public static void Main(String[] public static void Main(String[] public static void Main(String[] argsargsargs ))))args { String

{ String { String

{ String usrusrusr; usr; ; ; FileStreamFileStreamFileStreamFileStream f; f; StreamWriterf; f; StreamWriterStreamWriterStreamWriter w;w;w;w; try { try { try { try { usr usr usr

usr =Environment.=Environment.=Environment.=Environment.GetEnvironmentVariableGetEnvironmentVariableGetEnvironmentVariableGetEnvironmentVariable("USERNAME");("USERNAME");("USERNAME");("USERNAME"); f=new

f=new f=new

f=new FileStreamFileStreamFileStreamFileStream(“C:(“C:(“C:(“C:\\\\\\\\test.txt",test.txt",test.txt",test.txt",FileModeFileModeFileModeFileMode.Create);.Create);.Create);.Create); w=new

w=new w=new w=new StreamWriterStreamWriterStreamWriterStreamWriter(f);(f);(f);(f); w. w. w. w.WriteLineWriteLineWriteLineWriteLine((((usrusrusr);usr););); w.Close(); w.Close(); w.Close(); w.Close(); } catch (Exception e){ } catch (Exception e){ } catch (Exception e){ } catch (Exception e){

Console. Console. Console.

Console.WriteLineWriteLineWriteLine("Exception:"+e.WriteLine("Exception:"+e.("Exception:"+e.("Exception:"+e.ToStringToStringToString());ToString());());()); }}}}

}}}}

Source code

Source code

Assembly

Assembly

PE header + MSIL +

PE header + MSIL +

Metadata + EH Table

Metadata + EH Table

EXECUTION

EXECUTION

Assembly info

Assembly info

Module

Module

+ Class list

+ Class list

Policy

Policy

Manager

Manager

Host

Host

Policy

<?xml version="1.0" encoding="utf-8" ?> <configuration> <mscorlib> <security> <policy> <PolicyLevel version="1"> <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="Nothing" Name="All_Code" Description="Code group grants no permissio ns and forms the root of the code group tree.">

<IMembershipCondition clas s="AllMembershipCondition" version="1"/> <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust"

Class

Class

Loader

Loader

Granted

Granted

permissions

permissions

Vtable

Vtable

+

+

Class info

Class info

JIT +

JIT +

verification

verification

Native code

Native code

+ GC table

+ GC table

CLR Services

CLR Services





GC

GC





Exception

Exception





Class init

Class init





Security

Security

(a

ss

em

b

ly

)

(a

ss

em

b

ly

)

(class)

(class)

(method)

(method)

Assembly

Assembly

Loader

Loader

Evidence

Evidence

Permission request

Permission request

Ejecución

(8)

Ejemplo

Ejemplo

de

de

implementación

implementación

completa

completa

de

de

los

los

estándares

estándares

ECMA

ECMA

334: C# language

334: C# language

335: Common Language Infrastructure (CLI)

335: Common Language Infrastructure (CLI)

http://msdn.microsoft.com/net/sscli

http://msdn.microsoft.com/net/sscli

download;

download;

comprobar env

comprobar env

;

;

buildall

buildall

;

;

tomar

tomar

un café

un café

No

No

comercial

comercial

, source code distribution

, source code distribution

Modificable

Modificable

redistribuible

redistribuible

Sin fines

Sin fines

comerciales

comerciales

Implementación

Implementación

en

en

distintas plataformas

distintas plataformas

FreeBSD & Windows™ XP

FreeBSD & Windows™ XP

Mac OS

Mac OS

-

-

X

X

(9)

11MB download (

11MB download (

comprimidas

comprimidas

)

)

1.9

1.9

millones

millones

de

de

líneas

líneas

de

de

código

código

( 33 meses para

( 33

meses para leer a 10

leer a 10 secs

secs/line)

/line)

1.15M de C y C++

1.15M de C y C++

625K de C#

625K de C#

125K de CIL (Intermediate Language)

125K de CIL (Intermediate Language)

Algo

Algo

de

de

código ensamblador

código ensamblador

9700

9700

ficheros fuente

ficheros fuente

(

(

incluyendo

incluyendo

~2900 tests)

~2900 tests)

Se

Se

generan

generan

1200

1200

clases

clases

Alrededor

Alrededor

de 20 DLLs

de 20 DLLs

Sobre

Sobre

22

22

EXEs

EXEs

40 MB de

40 MB de

documentos

documentos

(10)

Capas

Capas

Execution

Engine (C++)

Frameworks

(C#)

Compiladores

Herramientas

PAL (C)

C# JScript ALink CorDbg ILasm ILdasm

CasPol clix PEverify SOS MetaInfo

Collections Diagnostics Globalization IO Net

Reflection Regex Text Threading XML

Serialization

FJIT Fusion AppDomains Loader GC

Exceptions Threads Pinvoke Metadata

Debugging Profiling Locks Security Verification

CreateFile GetCurrentThread CreateProcess

VirtualAlloc FlushInstructionCache

GetEnvironmentVariable RaiseException

InterlockedIncrement

(242)

(11)

http://msdn.microsoft.com/net/ecma

http://msdn.microsoft.com/net/ecma

Un

Un

sistema

sistema

de

de

tipos comunes

tipos comunes

(Common Type System)

(Common Type System)

…y

…y

una

una

especificación

especificación

para

para

integración

integración

de

de

lenguajes

lenguajes

(

(

CLS

CLS

)

)

Máquina abstracta

Máquina abstracta

con

con

recolector

recolector

de

de

basura

basura

y

y

manejo

manejo

de

de

excepciones

excepciones

Sistema

Sistema

de

de

seguridad

seguridad

integral con

integral con

verificación

verificación

Un

Un

formato

formato

de

de

ficheros

ficheros

Formato

Formato

PE/COFF con

PE/COFF con

extensiones

extensiones

Un

Un

sistema

sistema

extensible de

extensible de

metadatos

metadatos

Un

Un

lenguaje intermedio

lenguaje intermedio

CIL: Common Intermediate Language

CIL: Common Intermediate Language

Una biblioteca

Una biblioteca

de

de

clases

clases

(Framework)

(Framework)

Una

Una

versión

versión

"

"

moderna

moderna

" del C runtime

" del C runtime

Aceso

Aceso

a la

a la

plataforma subyacente

plataforma subyacente

(12)

ECMA specs:

ECMA specs:

http://

http://

msdn

msdn

.

.

microsoft

microsoft

.com/net/

.com/net/

ecma

ecma

Microsoft .NET Framework SDK:

Microsoft .NET Framework SDK:

http://

http://

msdn

msdn

.

.

microsoft

microsoft

.com/downloads

.com/downloads

Shared source info:

Shared source info:

http://www.microsoft.com/

http://www.microsoft.com/

sharedsource

sharedsource

News group:

News group:

news:

news:

microsoft

microsoft

.public.shared_source.

.public.shared_source.

cli

cli

Research:

Research:

http://research.

http://research.

microsoft

microsoft

.com/programs/

.com/programs/

europe

europe

/rotor/Projects.asp

/rotor/Projects.asp

Referencias

Documento similar

Next, we are going to present the code generation strategy used in the implementation of the previous execution model in a well-known Windows95 environment, which opens up

Top intersections of psi classes and evaluation classes (integrated against the virtual fundamental class) are called gravitational descendants, or descendent Gromov-Witten

d) Instalar y configurar módulos y complementos, evaluando su funcionalidad, para gestionar entornos de desarrollo. e) Seleccionar y emplear lenguajes, herramientas y

Global agricultural green and blue water Global agricultural green and blue water consumptive uses and virtual water trade consumptive uses and virtual water trade.. in the

In the next section we will show as a hint of the consistency of the extended method the agreement of the conformal and chiral anomalies computed with the adiabatic scheme for

Proc. of SPIE Vol.. This etching procedure results in a thin film of SiO x with a random distribution of pinholes where Ga droplets can be preferentially formed. A thorough

Initially, the envelopes of instantaneous amplitude, energy and frequency are computed (Figs.. In a), events detected as sounds have been represented with dash lines over the 0

Las  aplicaciones Android están escritas en lenguaje Java.  Aunque  ya hemos