Compilers

Compilers - COP4020 Programming Languages Compilers and...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
COP4020 Programming Languages Compilers and Interpreters Prof. Robert van Engelen
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP4020 Spring 2011 2 2/1/11 Overview ! Common compiler and interpreter configurations ! Virtual machines ! Integrated development environments ! Compiler phases " Lexical analysis " Syntax analysis " Semantic analysis " Intermediate (machine-independent) code generation " Intermediate code optimization " Target (machine-dependent) code generation " Target code optimization
Background image of page 2
COP4020 Spring 2011 3 2/1/11 Compilers versus Interpreters ! The compiler versus interpreter implementation is often fuzzy " One can view an interpreter as a virtual machine that executes high- level code " Java is compiled to bytecode " Java bytecode is interpreted by the Java virtual machine (JVM) or translated to machine code by a just-in-time compiler (JIT) " A processor (CPU) can be viewed as an implementation in hardware of a virtual machine (e.g. bytecode can be executed in hardware) ! Some programming languages cannot be purely compiled into machine code alone " Some languages allow programs to rewrite/add code to the code base dynamically " Some languages allow programs to translate data to code for execution (interpretation)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP4020 Spring 2011 4 2/1/11 Compilers versus Interpreters ! Compilers “try to be as smart as possible” to fix decisions that can be taken at compile time to avoid to generate code that makes this decision at run time " Type checking at compile time vs. runtime " Static allocation " Static linking " Code optimization ! Compilation leads to better performance in general " Allocation of variables without variable lookup at run time " Aggressive code optimization to exploit hardware features ! Interpretation facilitates interactive debugging and testing " Interpretation leads to better diagnostics of a programming problem " Procedures can be invoked from command line by a user " Variable values can be inspected and modified by a user
Background image of page 4
COP4020 Spring 2011 5 2/1/11 Compilation ! Compilation is the conceptual process of translating source code into a CPU-executable binary target code ! Compiler runs on the same platform X as the target code Target Program Compiler Source Program Program Input Output Run on X Compile on X Debug on X
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP4020 Spring 2011 6 2/1/11 Cross Compilation !
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 25

Compilers - COP4020 Programming Languages Compilers and...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online