29

Silverlight 1.1 CoreCLR 内部揭秘

  • Upload
    eadoin

  • View
    98

  • Download
    0

Embed Size (px)

DESCRIPTION

Silverlight 1.1 CoreCLR 内部揭秘. Andrew Pardoe Program Manager 微软公共语言运行时 [email protected]. demo. Silverlight 1.0. Why Silverlight?. Why are applications on the internet important? Rich, interactive internet applications WPF is a powerful and expressive - PowerPoint PPT Presentation

Citation preview

Page 1: Silverlight 1.1 CoreCLR  内部揭秘
Page 2: Silverlight 1.1 CoreCLR  内部揭秘

Silverlight 1.1 CoreCLR 内部揭秘

Andrew PardoeProgram Manager微软公共语言运行时[email protected]

Page 3: Silverlight 1.1 CoreCLR  内部揭秘

Silverlight 1.0

DEMO

Page 4: Silverlight 1.1 CoreCLR  内部揭秘

Why Silverlight?Why are applications on the internet important?Rich, interactive internet applicationsWPF is a powerful and expressive

Clear separation between graphics and business logicPowerful designer tools for graphics and code

Expression Blend integrates designers into projectSilverlight cross-platform on most browsersServe Silverlight applications from any web serverWMV is the best video format on the web

Page 5: Silverlight 1.1 CoreCLR  内部揭秘

From XAML to Silverlight<Ellipse Width="104" Height="90" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="87" Canvas.Top="8"/><Ellipse Width="28" Height="28" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="69" Canvas.Top="8"/><Ellipse Width="28" Height="28" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="179" Canvas.Top="8"/><Ellipse Width="21" Height="13" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="108" Canvas.Top="36"/><Ellipse Width="21" Height="13" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="146" Canvas.Top="36"/><Ellipse Width="104" Height="49" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="87" Canvas.Top="63"/><Path Width="65" Height="10.5" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" Canvas.Left="107.5" Canvas.Top="87.5”/>...

Page 6: Silverlight 1.1 CoreCLR  内部揭秘

Why use a desktop technology for the web?Developers, developers, developers!

Performance, expressiveness and reuse of knowledge

Silverlight lets you use what you already knowC#, VB, JScript—Silverlight supports all .NET languagesPopular dynamic languages like IronPython and IronRuby

CoreCLR built from same source as desktop CLR100% compatible but much smaller install package

What’s different in CoreCLR? We’ll look at the desktop CLR and compare it to CoreCLR

Why CoreCLR?

Page 7: Silverlight 1.1 CoreCLR  内部揭秘

Overview of Silverlight 1.1

SL 1.1 Canvas hosted in IE by ActiveX control.HTML DOM fully exposed to WPF/E and .NET.

Windows Presentation Foundation / Everywhere

Animation Vector Graphics

Video Playback

CoreCLR Execution Engine

Base Class Library

User Input

Dynamic Language Runtime

Page 8: Silverlight 1.1 CoreCLR  内部揭秘

The CLR is simple, right?

MSIL + Metadata

Your code + .NET Framework

Write a program with any .NET languageC# source code

Your code uses the Base Class Library

Running the program loads the CLR in the process

Managed execution CLR manages execution in protected environment

Compile it to an MSIL executable

Class loader creates in-memory managed objects

JIT produces native x86 (or 64-bit) code

Page 9: Silverlight 1.1 CoreCLR  内部揭秘

What's different in CoreCLR?Small size allows on-demand installNew languages in Dynamic Language Runtime Fewer scenarios than desktop CLR

Sandboxed code can’t access system resourcesBase Class Library is targeted for the webOnly hosted by ActiveX controls

Supported on Intel Apple Mac OS XExecution engine is the same as the desktop CLR

Same JIT, Garbage Collector and virtual machineNew security model

Security Transparency replaces Code Access Security

Page 10: Silverlight 1.1 CoreCLR  内部揭秘

Not just C# and VB (or C++/CLI or even F#)Ada, APL, Cobol, Eiffel, Forth, Fortran, Lisp, Perl, Pascal, and more

All of these languages are statically compiled

Program in any .NET language

Page 11: Silverlight 1.1 CoreCLR  内部揭秘

DLR Console

DEMO

Page 12: Silverlight 1.1 CoreCLR  内部揭秘

DLR adds popular web languages to SilverlightDLR creates MSIL code at runtime and executes itBuilt on a message-passing system

Objects respond to messages based on language semanticsMessages are converted to MSIL and executed

Dynamic method dispatch, dynamic type systemMessages are bound to methods at runtimeDynamic types are CLR types—no marshalling to C#

Dynamic Languages

Page 13: Silverlight 1.1 CoreCLR  内部揭秘

Limited file system access

IsolatedStorageFile abstracts virtual file system1 MB allocated per-user, per applicationDefine the scope with a using directive

File objects are disposed when scope is destroyed

using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())

{using (StreamWriter writer = new StreamWriter(isoStore)) {

writer.Write("This is isolated storage file."); }

}

Page 14: Silverlight 1.1 CoreCLR  内部揭秘

Simplified Base Class Library

Web-hosting CoreCLR reduces scenariosNeed to reduce size for click-time installSimplified BCL is based on .NET CFNon-generic collections have been removedLocalization culture information from base OSBackgroundWorker is primary threading mechanismSee BCL team blog for more details

Guidance available to help port existing .NET code

Page 15: Silverlight 1.1 CoreCLR  内部揭秘

Appdomains and processesEach box represents a separateappdomain running in CoreCLR.

Silverlight 1.1 application in its

own CoreCLR

Silverlight 1.0 application uses XAML

and Javascript

Different browser runs indifferent process so it getsits own copy of CoreCLR.

Silverlight 1.1 application with shared CoreCLR

Another Silverlight 1.1 application

Browser tabs share a single process and share one copy of CoreCLR.

Page 16: Silverlight 1.1 CoreCLR  内部揭秘

ActiveX host handles all versioning

Versioning and binding transparent to the userActiveX host loads the CLR, creates appdomain and applies policies for that appdomainDLL has access to the XAML and HTML DOMs

XAML can be written dynamically from managed codeEach Silverlight canvas runs in its own appdomain

Platform code can be shared between appdomainsAppdomain gets unloaded when web page unloads

Page 17: Silverlight 1.1 CoreCLR  内部揭秘

Running a managed program means loading CLRCould use the desktop CLR on Windows……but different CLRs can have different behaviorCoreCLR runs in the same process as other CLRs

Even with a CLR in-process we can still load CoreCLRManaged browser can still host Silverlight with CoreCLRCan have multiple CoreCLRs in one process100% compatibility no matter what CLR is on your machine

Which CLR runs my code?

Page 18: Silverlight 1.1 CoreCLR  内部揭秘

CoreCLR and CLR side-by-side

DEMO

Page 19: Silverlight 1.1 CoreCLR  内部揭秘

Native code generation

Same JIT runs on Silverlight and desktop CLRSame code generated on Mac, Windows and desktop

No NGen for Silverlight

Page 20: Silverlight 1.1 CoreCLR  内部揭秘

Intel Mac support

CoreCLR runs on Intel Mac or Windows machinesPlatform Adaptation Layer adapts system APIs

CoreCLR, Base Class Libraries

and other platform

assemblies

Mac OS X 10.4+Intel machines

WindowsIntel x86

machines

PAL

Page 21: Silverlight 1.1 CoreCLR  内部揭秘

Execution engine is the same

CoreCLR uses the same execution engine as CLRSame JIT, same GC, same virtual machineSimplified security model—CAS is gone!Transparent, Safe Critical and Critical codeAll user code is transparent

May not access critical code or dataMay not call native code through P/Invoke or Interop

Page 22: Silverlight 1.1 CoreCLR  内部揭秘

Security Transparency example

WINAPI CreateFile (Critical code) creates the file on the user’s

disk without any validation

Silverlight application (Transparent code)wants to write a file

System.IO.IsolatedStorageFile StreamWriter (SafeCritical code)

verifies the request and calls Windows API

Page 23: Silverlight 1.1 CoreCLR  内部揭秘

Security Transparency Model

No more evidence, no more permissions, no more policy levels, no more code groupsNo more complicated MSDN documentationNo more stackwalks for code access demandsTransparent code can call public methods, use public types and override methods…

if they are exposed by the platform assemblies or by other application codeif they are Safe Critical or Transparent security

Page 24: Silverlight 1.1 CoreCLR  内部揭秘

Silverlight is simple, right?

MSIL + Metadata

Your code + .NET Framework

Use the .NET programming skills you already haveC# source code

Running in a web browser simplifies scenarios

Your code uses the simplified Base Class Library

Managed execution Same JIT, execution engine means no surprises

Dynamic language runtime adds new languages

Same CoreCLR runs under any ActiveX host

Security Transparency Model is easier to use

Page 25: Silverlight 1.1 CoreCLR  内部揭秘

Chess: Javascriptvs. CoreCLR

DEMO

Page 26: Silverlight 1.1 CoreCLR  内部揭秘

Questions?

Q&A

Page 27: Silverlight 1.1 CoreCLR  内部揭秘

Shawn Farkas’ blog posts about Silverlight Securityhttp://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx

Silverlight – Get Startedhttp://silverlight.net/GetStarted

Jim Hugunin’s blog about the DLRhttp://blogs.msdn.com/hugunin

BCL team blog posts about Silverlight http://blogs.msdn.com/bclteam/archive/tags/Silverlight/default.aspx

Resources

Where to find these slides (and not much else)http://blogs.msdn.com/apardoe

Silverlight Shanghai team bloghttp://blogs.csdn.net/SilverlightShanghai

Page 28: Silverlight 1.1 CoreCLR  内部揭秘

Thank you for attending this session with us!

Your suggestions and comments are very important to us. Please help us to complete an evaluation.

Page 29: Silverlight 1.1 CoreCLR  内部揭秘

© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.