Early Dynamic Interpretation.


33 views
Uploaded on:
Category: Music / Dance
Description
2. Dynamic Translation. What is it?
Transcripts
Slide 1

Early Dynamic Translation PreJit/NGEN by whatever other name George Bosworth Microsoft MRE\'04 March 21, 2004

Slide 2

Dynamic Translation What is it? – a compiler (not) What does it do? – deliver great quick code (ideally) When does it run? – Before the code is executed. i.e early. How much before is the subject of this discussion

Slide 3

Outline Code Generation and execution in the Common Language Runtime (CLR) PreJit What is it, why do it, at what cost What is it truly, and what is hard versus Simple case What the resultant code could resemble

Slide 4

Common Language Runtime Frameworks Common Language Runtime Base Classes Execution Support Security IL to local code compilers GC, stack walk, code director Class loader and design

Slide 5

Runtime Control Flow Just in Time Assembly Class Loader First reference to sort IL to local code compiler Execution Support Managed Native Code First call to strategy Code Managers Security System CPU

Slide 6

Execution Model VB VC ... Script Native Code PreJit time Code Gen IL Common Language Runtime "Econo"- JIT Compiler Standard JIT Compiler Native Code

Slide 7

Compiling IL To Native "Econo" JIT Generates unoptimized local Code can be disposed of and recovered "Standard" JIT Generates enhanced local code Includes confirmation of IL code PreJit code era Done at introduce time Reduces start-up time Native code has adaptation checks and returns to runtime JIT on the off chance that they fall flat

Slide 8

Assemblies Unit of sending One or more documents, autonomous of bundling Self-portraying by means of metadata ("show") Versioning Captured by compiler Policy per-application and also per-machine Security limit Assemblies are conceded authorizations Methods can request evidence that a consent has been allowed to whole call chain Mediate sort import and fare Types named in respect to get together

Slide 9

What Happens at Compile Time? Compiler peruses any foreign made metadata and manufactures interior image table Compiler determines strategy over-burdening utilizing dialect particular sort coordinating principles Compiler includes any required compulsions or throws Compiler chooses and records an exact part reference Compiler gives object design data through its decision of Layout procedure Non-static fields Virtual techniques, with "new space" versus "use existing opening" Compiler transmits metadata by consolidating approaching metadata with metadata it has created Compiler discharges IL with metadata tokens

Slide 10

What Happens at Class Load Time?, I A sort reference happens and is determined either to a current sort or to a get together reference. The gathering is stacked and some approval checks happen. The gathering is requested that resolve the sort reference and a module is found It is now that the security framework runs legacy consent checks

Slide 11

What Happens at Class Load Time?, II If no oversaw local code is accessible, the IL module is stacked and preparatory approval checks happen. The specific class is then approved and the CLR makes in-memory information structures speaking to the class, including thuds for use when a strategy is known as the first run through. At the point when a strategy on the class is known as the first run through, the code is JITted (and confirmed if necessary).

Slide 12

What Happens at JIT Time? On the off chance that a part reference shows up in the code, the sort is initially stacked (see underneath), which will likewise stack classes from which it acquires. On the off chance that the sort does not itself have the part, the legacy chain is sought to check whether it can be determined higher up in the class pecking order. The part get to check, including a conceivable security check, happens as of now. The JITter may embed calls to security code for explanatory security checks notwithstanding those predetermined utilizing the basic security component. The code runs.

Slide 13

DEVELOPMENT DEPLOYMENT Source code PE header + EH Table + Native code (incl. object format) open static void Main(String[] args ) { String usr; FileStream f; StreamWriter w; attempt { usr=Environment.GetEnvironmentVariable("USERNAME"); f=new FileStream("C:\\test.txt",FileMode.Create); w=new StreamWriter(f); w.WriteLine(usr); w.Close(); } get (Exception e){ Console.WriteLine("Exception:"+e.ToString()); } Compiler open static void Main(String[] args ) { String usr; FileStream f; StreamWriter w; attempt { usr=Environment.GetEnvironmentVariable("USERNAME"); f=new FileStream("C:\\test.txt",FileMode.Create); w=new StreamWriter(f); w.WriteLine(usr); w.Close(); } get (Exception e){ Console.WriteLine("Exception:"+e.ToString()); } application. registry, Win32 catalog Services Exception Native code EH table Unmanaged (Traditional) Code EXECUTION

Slide 14

DEVELOPMENT DEPLOYMENT Source code Assembly PE header + MSIL + Metadata + EH Table PEVerify open static void Main(String[] args ) { String usr; FileStream f; StreamWriter w; attempt { usr=Environment.GetEnvironmentVariable("USERNAME"); f=new FileStream("C:\\test.txt",FileMode.Create); w=new StreamWriter(f); w.WriteLine(usr); w.Close(); } get (Exception e){ Console.WriteLine("Exception:"+e.ToString()); } Compiler open static void Main(String[] args ) { String usr; FileStream f; StreamWriter w; attempt { usr=Environment.GetEnvironmentVariable("USERNAME"); f=new FileStream("C:\\test.txt",FileMode.Create); w=new StreamWriter(f); w.WriteLine(usr); w.Close(); } get (Exception e){ Console.WriteLine("Exception:"+e.ToString()); } NGEN Evidence EXECUTION Host Policy Manager Assembly data Module + Class list Assembly Loader GAC, application. index, download reserve 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 bunch allows no permissio ns and structures the foundation of the code bunch tree."> <IMembershipCondition clas s="AllMembershipCondition" version="1"/> <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Permission ask for Granted consents ( class ) (get together ) CLR Services GC Exception Class init Security ( strategy ) Class Loader JIT + check Vtable + Class information Native code + GC table Managed Code Execution

Slide 15

PreJit: What Is It? A MSIL-to-Native Compiler (Not) Pre-arrange, pre-load, pre-format Validate at execution time May calculate processor sort, other introduced gatherings, and so forth. In the event that invalid, utilize the typical execution way Goal: speedier start-up Because of littler start-up working set Usually as a component of gathering establishment ngen.exe, ships in Visual Studio ® .Net

Slide 16

What Happens at PreJit Time? Record rendition data about any wards Classes are laid out Internal runtime information structures apportioned Generate oversaw local code, checking as required Emit an uncommonly shaped PE document (.exe, .dll) in the code store and partner it with the information IL get together

Slide 17

DEVELOPMENT Source code Assembly PE header + MSIL + Metadata + EH Table open static void Main(String[] args ) { String usr; FileStream f; StreamWriter w; attempt { usr=Environment.GetEnvironmentVariable("USERNAME"); f=new FileStream("C:\\test.txt",FileMode.Create); w=new StreamWriter(f); w.WriteLine(usr); w.Close(); } get (Exception e){ Console.WriteLine("Exception:"+e.ToString()); } Compiler open static void Main(String[] args ) { String usr; FileStream f; StreamWriter w; attempt { usr=Environment.GetEnvironmentVariable("USERNAME"); f=new FileStream("C:\\test.txt",FileMode.Create); w=new StreamWriter(f); w.WriteLine(usr); w.Close(); } get (Exception e){ Console.WriteLine("Exception:"+e.ToString()); } Evidence EXECUTION Host Policy Manager Assembly information Module + Class list 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 bunch allows no permissio ns and structures the foundation of the code bunch tree."> <IMembershipCondition clas s="AllMembershipCondition" version="1"/> <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Permission ask for Granted consents ( class ) ( gathering ) CLR Services GC Exception Class init Security ( strategy ) Class Loader JIT + confirmation Vtable + Class information Native code + GC table NGen Code Creation DEPLOYMENT PEVerify NGEN Assembly Loader GAC, application. registry, download reserve

Slide 18

Host Policy Manager Assembly data Module + Class list Prebuilt (check Version) Assembly Loader Policy <?xml version="1.0" encoding="utf-8" ?> <configuration>

Recommended
View more...