Docsity

Optimizations - Compiler Design - Lecture Slides, Slides of Compiler Design

Partial preview of the text

Download Optimizations - Compiler Design - Lecture Slides and more Slides Compiler Design in PDF only on Docsity!

Just-In-Time Compilation and

Optimizations for .NET CLR

Introduction

„ Software application development and maintenanceare time and resource intensive ƒ Lack of standardization among platforms ƒ Porting is cumbersome, requires substantial rewriting ofprograms „ Need for a development environment enabling fasterand easier development „ Two paradigms ƒ Component software ƒ Virtual machine based execution

Virtual Machine Based Execution

„

A

VM is a layer over the host hardware

„ Simulated in software „ Provides developers with useful run-timeservices independent of host hardware ƒ Absolves developers from dealing with platform-specific issues while porting applications ƒ This model enables increased developer efficiency,shorter development cycles, and higher levels ofscalabilitity and extensibility

Virtual Machines -- Facilities

„ Checks security violations by components „ Components can be dynamically loaded andlinked „ Provides automatic memory management andgarbage collection „ Provides architecture-independent interfacefor exception handling

Virtual Machines -- Disadvantages

„ Run-time overheads due to extra layer ofsoftware „ Dynamic loading, garbage collection, securitychecks, are all expensive „ Instruction interpretation overheads are thehighest „ Unacceptably slow in high-performanceenvironments „ Just-In-Time Compilation is a good solution

Just-In-Time Compilation

„ Intermediate code is converted to native codeon the fly „ Units are compiled just before their first use „ Compiled code is cached and reused for lateruses „

A

method is a unit of compilation

„ Code generation time adds to executionoverheads

Multi-Level Optimization Framework

„ Lowest level – simplest optimizations „ Highest level – most expensive optimizations „ Hotness of a method determines the level „ Very hot methods being very few, overheadsof expensive optimizations are not felt andexecution speed improves for futureinvocations „ Hot methods are found by on-line profiling

Multi-Level Optimization Framework

„ The VM controls profiling and optimizations „ Profiles drive the optimizations ƒ No more the developer’s burden „ Profiling adds its own overheads ƒ May negate benefits of optimization ƒ Accuracy of profiling can be reduced resulting inreduced overheads ƒ This may also reduce the effectiveness ofoptimizations ƒ Tradeoff (accuracy v/s overheads)

Common Language Infrastructure (CLI) „ Standardized specification of a virtualexecution environment „ Defines an environment where componentscreated in several HLLs can interact in asecure and well-defined manner, irrespectiveof the platform on which the environmentruns „ CLI-consistent compilers generate a

common

intermediate language (CIL)

Common Language Infrastructure (CLI) „ CIL is a platform independent stack-based instructionset ƒ incorporates features from both object-oriented andprocedural programming domains „ At the heart of any implementation of CLI is thecommon language runtime (CLR) ƒ CLR is responsible for loading components and managingtheir execution ƒ CLR provides exeception handling, garbage collection,thread management, remoting and type safety services

ROTOR JIT Framework

Exec Mgr JIT Cmplr 1 JIT Mgr 1^ Code Mgr 1 JIT Mgr 2 JIT Cmplr 2 Code Mgr 2 Baseline JIT Our JIT

ROTOR and Baseline JIT Compiler

„ ROTOR has a baseline JIT compiler „ Performs JIT compilation and IL code typeverification „ Each incorporates a JIT manager, a codemanager and a JIT code generator „ Several such JIT compilers can be included inROTOR „ Execution manager controls JIT compilers

Multi-level adaptive optimization

framework for Rotor

„ We extend the CLR with an optimizing JIT compiler „ Two levels of profile-guided recompilation „ First level based on a sampling profiler „ Second level based on edge and call-graph profiling „ Profiler interface available

Extended ROTOR Architecture

with Profiler and Optimizer

Profilers Recompilation Controller Optimizing JIT Compiler Subsystem Profile Database Baseline JIT Compiler Native Code Extended CLR