1 / 29

Silverlight 1.1 CoreCLR 内部揭秘

Silverlight 1.1 CoreCLR 内部揭秘. Andrew Pardoe Program Manager 微软公共语言运行时 Andrew.Pardoe@microsoft.com. demo. Silverlight 1.0. Why Silverlight?. Why are applications on the internet important? Rich, interactive internet applications WPF is a powerful and expressive

eadoin
Télécharger la présentation

Silverlight 1.1 CoreCLR 内部揭秘

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Silverlight 1.1 CoreCLR 内部揭秘 Andrew Pardoe Program Manager 微软公共语言运行时 Andrew.Pardoe@microsoft.com

  2. demo Silverlight 1.0

  3. Why Silverlight? • Why are applications on the internet important? • Rich, interactive internet applications • WPF is a powerful and expressive • Clear separation between graphics and business logic • Powerful designer tools for graphics and code • Expression Blend integrates designers into project • Silverlight cross-platform on most browsers • Serve Silverlight applications from any web server • WMV is the best video format on the web

  4. 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”/> ...

  5. Why 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 know • C#, VB, JScript—Silverlight supports all .NET languages • Popular dynamic languages like IronPython and IronRuby • CoreCLR built from same source as desktop CLR • 100% compatible but much smaller install package • What’s different in CoreCLR? • We’ll look at the desktop CLR and compare it to CoreCLR

  6. 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 CoreCLR Execution Engine Animation Vector Graphics Dynamic Language Runtime Video Playback User Input Base Class Library

  7. The CLR is simple, right? Write a program with any .NET language C# source code Compile it to an MSIL executable Your code uses the Base Class Library MSIL + Metadata Running the program loads the CLR in the process Class loader creates in-memory managed objects Your code + .NET Framework JIT produces native x86 (or 64-bit) code CLR manages execution in protected environment Managed execution

  8. What's different in CoreCLR? • Small size allows on-demand install • New languages in Dynamic Language Runtime • Fewer scenarios than desktop CLR • Sandboxed code can’t access system resources • Base Class Library is targeted for the web • Only hosted by ActiveX controls • Supported on Intel Apple Mac OS X • Execution engine is the same as the desktop CLR • Same JIT, Garbage Collector and virtual machine • New security model • Security Transparency replaces Code Access Security

  9. Program in any .NET language • 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

  10. demo DLRConsole

  11. Dynamic Languages • DLR adds popular web languages to Silverlight • DLR creates MSIL code at runtime and executes it • Built on a message-passing system • Objects respond to messages based on language semantics • Messages are converted to MSIL and executed • Dynamic method dispatch, dynamic type system • Messages are bound to methods at runtime • Dynamic types are CLR types—no marshalling to C#

  12. Limited file system access • IsolatedStorageFile abstracts virtual file system • 1 MB allocated per-user, per application • Define the scope with a using directive • File objects are disposed when scope is destroyed using (IsolatedStorageFileisoStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (StreamWriter writer = new StreamWriter(isoStore)) { writer.Write("This is isolated storage file."); } }

  13. Simplified Base Class Library • Web-hosting CoreCLR reduces scenarios • Need to reduce size for click-time install • Simplified BCL is based on .NET CF • Non-generic collections have been removed • Localization culture information from base OS • BackgroundWorker is primary threading mechanism • See BCL team blog for more details • Guidance available to help port existing .NET code

  14. Appdomains and processes Each box represents a separateappdomain running in CoreCLR. Silverlight 1.0 application uses XAML and Javascript Silverlight 1.1 application with shared CoreCLR Silverlight 1.1 application in itsown CoreCLR Another Silverlight 1.1 application Different browser runs indifferent process so it getsits own copy of CoreCLR. Browser tabs share a single process and share one copy of CoreCLR.

  15. ActiveX host handles all versioning • Versioning and binding transparent to the user • ActiveX host loads the CLR, creates appdomain and applies policies for that appdomain • DLL has access to the XAML and HTML DOMs • XAML can be written dynamically from managed code • Each Silverlight canvas runs in its own appdomain • Platform code can be shared between appdomains • Appdomain gets unloaded when web page unloads

  16. Which CLR runs my code? • Running a managed program means loading CLR • Could use the desktop CLR on Windows… • …but different CLRs can have different behavior • CoreCLR runs in the same process as other CLRs • Even with a CLR in-process we can still load CoreCLR • Managed browser can still host Silverlight with CoreCLR • Can have multiple CoreCLRs in one process • 100% compatibility no matter what CLR is on your machine

  17. demo CoreCLRand CLRside-by-side

  18. Native code generation • Same JIT runs on Silverlight and desktop CLR • Same code generated on Mac, Windows and desktop • No NGen for Silverlight

  19. Intel Mac support • CoreCLR runs on Intel Mac or Windows machines • Platform Adaptation Layer adapts system APIs CoreCLR, Base Class Libraries and other platform assemblies PAL Mac OS X 10.4+Intel machines WindowsIntel x86 machines

  20. Execution engine is the same • CoreCLR uses the same execution engine as CLR • Same JIT, same GC, same virtual machine • Simplified security model—CAS is gone! • Transparent, Safe Critical and Critical code • All user code is transparent • May not access critical code or data • May not call native code through P/Invoke or Interop

  21. 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.IsolatedStorageFileStreamWriter (SafeCritical code) verifies the request and calls Windows API

  22. Security Transparency Model • No more evidence, no more permissions, no more policy levels, no more code groups • No more complicated MSDN documentation • No more stackwalks for code access demands • Transparent code can call public methods, use public types and override methods… • if they are exposed by the platform assemblies or by other application code • if they are Safe Critical or Transparent security

  23. Silverlight is simple, right? Use the .NET programming skills you already have C# source code Dynamic language runtime adds new languages Running in a web browser simplifies scenarios MSIL + Metadata Your code uses the simplified Base Class Library Same CoreCLR runs under any ActiveX host Your code + .NET Framework Security Transparency Model is easier to use Same JIT, execution engine means no surprises Managed execution

  24. demo Chess: Javascript vs. CoreCLR

  25. Q&A Questions?

  26. Shawn Farkas’ blog posts about Silverlight Security http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx BCL team blog posts about Silverlight http://blogs.msdn.com/bclteam/archive/tags/Silverlight/default.aspx Silverlight – Get Started http://silverlight.net/GetStarted Jim Hugunin’s blog about the DLR http://blogs.msdn.com/hugunin Where to find these slides (and not much else) http://blogs.msdn.com/apardoe Silverlight Shanghai team blog http://blogs.csdn.net/SilverlightShanghai Resources

  27. Thank you for attending this session with us! Your suggestions and comments are very important to us. Please help us to complete an evaluation.

More Related