Where’s My Compiler?OutlineWhat Is A Compiler?A CompilerFigures of MeritSlide 61950s: Just a Compiler, PleaseInside the Compiler (in concept)Slide 9Slide 101960s: LinkersTools: Compiler + Linker1970s: Symbolic DebuggerCompiler, Linker, Debugger1980s: Dynamic Loading, ThreadingOS Dynamic Loader1990s: JITs and Managed RuntimesOS Dynamic Loader (repeat)Slide 19Managed RuntimeSlide 212000s: Reflection-based ComputationRuntime ReflectionSlide 241970: NumblesSlide 26Special-Purpose CompilersMark-up CompilersSlide 29Modern Hardware: CPUModern Hardware: GraphicsSlide 32DatabasesHardware EmulatorsCode Analysis Tools“Tree Shakers”Slide 37A Modern Interactive Development Environment (IDE)Compilers in the IDE (I)Compilers In the IDE (II)Compilers in the LinkerProfile-Guided OptimizationSlide 43For the DeveloperFor the Compiler WriterQuestions?Where’s My Compiler?Developer tools: past, present, and futureJim MillerSoftware Architect, Developer FrameworksMicrosoft Corporation(with help from Carol Eidt, Phoenix Project, Microsoft Corporation)Jan 14, 2019 Where's My Compiler? 2OutlineWhat Is A Compiler?What Is A Compiler?A Brief History of Developer ToolsMy First CompilerCompilers, compilers, everywhereJan 14, 2019 Where's My Compiler? 3What Is A Compiler?A converter from one representation (source code) to another (executable code)Preserves (most of) the meaning of the sourceOne part of a modern “tool chain” used to produce executable artifacts (applications)Jan 14, 2019 Where's My Compiler? 4A CompilerCompilerSource CodeDescribes desired behaviorExecutableCodeHas desired behavior, but• May have different internal structure• May execute in different (unobservable) orderJan 14, 2019 Where's My Compiler? 5Figures of MeritCode Quality: how efficient is the generated code?Speed and Space: these aren’t independent, but they aren’t the same eitherThroughput: how fast is the code generated?Footprint: how large is the compiler?Jan 14, 2019 Where's My Compiler? 6OutlineWhat Is A Compiler?A Brief History of Developer A Brief History of Developer ToolsToolsMy First CompilerCompilers, compilers, everywhereJan 14, 2019 Where's My Compiler? 71950s: Just a Compiler, PleaseThe compiler references a runtime, but the runtime is supplied by the OS at a fixed location in memoryFORTRAN runtime: input/output formattingCOBOL runtime: also search and sortOS loader loads the compiler output into memory, transfers controlAddress space is small (< 8K word), CPU is slow (< 1,000 instructions/sec.)Figure of merit: Code QualityCompiler must optimize code for spaceCompiler must optimize code for speedJan 14, 2019 Where's My Compiler? 8Inside the Compiler (in concept)Source CodeFront EndBack EndExecutableCodeCompilerJan 14, 2019 Where's My Compiler? 9Inside the Compiler (in concept)Source CodeBack EndExecutableCodeCompilerFront End• Parse source code• Produce abstract syntax tree (AST)• Produce symbol table• Generate errors• Syntax errors• Type errors• Unbound referencesJan 14, 2019 Where's My Compiler? 10Inside the Compiler (in concept)Source CodeExecutableCodeCompiler• Linearize parse tree• Code Analysis• Basic block analysis• Control- and data-flow graph analysis• Optimize (machine-independent)• Redundant and dead code elimination• Code restructuring• Convert to executable code• Register allocation• Peephole optimization• Branch prediction and tensioningBack EndFront EndJan 14, 2019 Where's My Compiler? 111960s: LinkersPrograms are growing in sizePrograms are built with librariesLibraries provide reusable code fragmentsVirtual memory systems are inventedTool chain is in two stagesCompile independent modulesCombine the modules using a linkerFigure of merit: Code quality (speed)Jan 14, 2019 Where's My Compiler? 12Includes external referencesTools: Compiler + LinkerSource CodeFront EndBack EndObject CodeCompilerSource CodeFront EndBack EndObject CodeSource CodeFront EndBack EndObject CodeLinkerExecutable CodeJan 14, 2019 Where's My Compiler? 131970s: Symbolic DebuggerOS written in high-level languageCompilers provide sufficient code performance and low-level accessHigh-level languages provide large runtime libraries in multiple unitsStatic linker pulls only required units into a given program imageCompiler exports symbol table for use by debugger, not just internal to front-/back-endFigure of merit: Code quality (speed)Jan 14, 2019 Where's My Compiler? 14Compiler, Linker, DebuggerSource CodeFront EndBack EndObject CodeCompilerSource CodeFront EndBack EndObject CodeSource CodeFront EndBack EndObject CodeLinkerRunning ProgramSymbol table(s)DebuggerJan 14, 2019 Where's My Compiler? 151980s: Dynamic Loading, ThreadingTo improve OS performance, by reducing physical memory pressure, read/only parts of libraries are shared between applicationsLoaded on first referenceOS loader fixes up references to shared libraries – just like the static linkersNot all libraries are loaded into the same virtual addressConcurrency issues addressed in programming languagesLocks, monitors, events, pollingOrder of operations visible across thread boundariesMemory model semantics become an issueAda™ introduces rendez-vous, other languages have other constructsTool chainCompiler(s)LinkerLoaderSymbolic debuggerFigure of merit: Code quality (speed, but this is related to space)Jan 14, 2019 Where's My Compiler? 16OS Dynamic LoaderSource CodeFront EndBack EndObject CodeCompilerSource CodeFront EndBack EndObject CodeSource CodeFront EndBack EndObject CodeStatic LinkerOS LoaderRunning ProgramSymbol table(s)DebuggerIncludes fixups for shared codeImage FileImage File Image FileJan 14, 2019 Where's My Compiler? 171990s: JITs and Managed RuntimesGarbage Collection goes mainstreamPreviously: LISP, APL, SmallTalk1990s: Java, Jscript, C#, VBVerification requires runtime to analyze codeVerification is similar to front-end compiler workCan be done to native code, but much simpler with an intermediate languageJust-in-time (JIT) compilation increases performance over pure interpretationTypically by a factor of 5 to 15Tool chain: split the compiler in two!Linearize the AST to create Intermediate Language (IL)Save symbol table as “metadata”Reorder the chainFigures of merit: Throughput first, code quality secondJan
View Full Document