1 Language Levels and Translation See also: Blackboard >> Course Material >> Reader (Dictaat)

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
1 CIS 461 Compiler Design and Construction Fall 2014 Instructor: Hugh McGuire slides derived from Tevfik Bultan, Keith Cooper, and Linda Torczon Lecture-Module.
Software & Services Group, Developer Products Division Copyright© 2010, Intel Corporation. All rights reserved. *Other brands and names are the property.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Lecture 01 - Introduction Eran Yahav 1. 2 Who? Eran Yahav Taub 734 Tel: Monday 13:30-14:30
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Programming Languages Structure
Overview of Compiler Design CIS 631, CSE 691, CIS400, CSE 400 Compiler Design Dr. Nancy McCracken January 15, 2008.
X86 ISA Compiler Baojian Hua Front End source code abstract syntax tree lexical analyzer parser tokens IR semantic analyzer.
CS 153: Concepts of Compiler Design August 25 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Processor Types And Instruction Sets Barak Perelman CS147 Prof. Lee.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Compiled by Benjamin Muganzi 3.2 Functions and Purposes of Translators Computing 9691 Paper 3 1.
CPSC 388 – Compiler Design and Construction Lecture: MWF 11:00am-12:20pm, Room 106 Colton.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
Programming Languages Generations
Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and copy this slide show for your personal use, or for.
ITEC 352 Lecture 11 ISA - CPU. ISA (2) Review Questions? HW 2 due on Friday ISA –Machine language –Buses –Memory.
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
LANGUAGE TRANSLATORS: WEEK 24 TRANSLATION TO ‘INTERMEDIATE’ CODE (overview) Labs this week: Tutorial Exercises on Code Generation.
Java Programming Introduction & Concepts. Introduction to Java Developed at Sun Microsystems by James Gosling in 1991 Object Oriented Free Compiled and.
CSC 310 – Imperative Programming Languages, Spring, 2009 Virtual Machines and Threaded Intermediate Code (instead of PR Chapter 5 on Target Machine Architecture)
CSC 338: Compiler design and implementation
Cosc 2150: Computer Organization
Language processors (Chapter 2) 1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
Virtual Machines, Interpretation Techniques, and Just-In-Time Compilers Kostis Sagonas
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
M. Mateen Yaqoob The University of Lahore Spring 2014.
Programming Languages
ECEG-3202 Computer Architecture and Organization Chapter 7 Reduced Instruction Set Computers.
Compiler Design Introduction 1. 2 Course Outline Introduction to Compiling Lexical Analysis Syntax Analysis –Context Free Grammars –Top-Down Parsing –Bottom-Up.
Winter Compilers Software Eng. Dept. – Ort Braude Compiling Assignments and Expressions Lecturer: Esti Stein brd4.ort.org.il/~esti2.
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
1 Compiler & its Phases Krishan Kumar Asstt. Prof. (CSE) BPRCE, Gohana.
Sahar Mosleh California State University San MarcosPage 1 Assembly language and Digital Circuit By Sahar Mosleh California State University San Marcos.
Code Generation CPSC 388 Ellen Walker Hiram College.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
CSC 4181 Compiler Construction
Language Implementation Overview John Keyser Spring 2016.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
CSC 8505 Compiler Construction
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Prologue Sung-Dong Kim, Dept. of Computer Engineering, Hansung University.
Component 1.6.
Compiler Design (40-414) Main Text Book:
Overview of Compilers and Language Translation
Chapter 1 Introduction.
Computational Thinking, Problem-solving and Programming: General Principals IB Computer Science.
CS 326 Programming Languages, Concepts and Implementation
PROGRAMMING LANGUAGES
Programming Language Hierarchy, Phases of a Java Program
Chapter 1 Introduction.
Java programming lecture one
Assembler, Compiler, Interpreter
CSE401 Introduction to Compiler Construction
Assembler, Compiler, Interpreter
A Level Computer Science Topic 5: Computer Architecture and Assembly
Programming language translators
Presentation transcript:

1 Language Levels and Translation See also: Blackboard >> Course Material >> Reader (Dictaat)

TU-Delft TI1400/11-PDS 2 IT Industry Competitiveness Source: The Economist, Benchmarking IT industry competitiveness

TU-Delft TI1400/11-PDS 3 The Netherlands: A Top IT Industry Source: The Economist, Benchmarking IT industry competitiveness /study/2009_eiu_global.pdf /study/2009_eiu_global.pdf

TU-Delft TI1400/11-PDS 4 But … Where’s the Human Capital? “A longer-term challenge for some European countries is encouraging more graduates to choose science-related subjects.” -NL is 27 th in HC Source: The Economist, Benchmarking IT industry competitiveness 2009 Q: Good/Bad news for you?

TU-Delft TI1400/11-PDS 5 The Simplest(?) Problem: How to Program Computers? So far -Design them from scratch -Assembly This lecture -Language levels -Translation -The compiler sequence

TU-Delft TI1400/11-PDS 6 Language levels A computer has several language levels: -machine language -assembler language (e.g., Intel/Pentium assembler) -higher-level language (e.g., Java) -application-specific language (e.g., MatLab) Close the gap between problem description and machine program

TU-Delft TI1400/11-PDS 7 Program transformations Need for program transformations Semantics of programs must remain the same Two ways of transformation: 1.compilation: first translate, then execute 2.interpretation: interleave translation and execution

TU-Delft TI1400/11-PDS 8 Type of translators Java machine instructions Java IA-32 assembler machine instructions Java IA-32 assembler machine instructions JVM compile to machine language interpret byte code compile to assembler compile assemble

TU-Delft TI1400/11-PDS 9 Types of interpreters program PC program inter- preter IPC PC program run-time system/ OS (I)PC PC many steps of PC for one step of IPC combination: interpret system calls

TU-Delft TI1400/11-PDS 10 Compilation versus Interpretation Advantages interpretation -Direct edit/execution cycle -Debugging on the level of interpreted language -Less memory requirements for programs Advantage compilation -Faster execution (factor of ) -Semantic checks during compilation process

TU-Delft TI1400/11-PDS 11 Simulation versus Emulation Mimicking of hardware or software Through program: simulation Through hardware: emulation Example: -PowerPC simulation on Intel Pentium -Virtual machines such as KVM and VMware

TU-Delft TI1400/11-PDS 12 Programs and machines In exchanging programs and machines three notions are relevant: 1.Compatibility 2.Portability 3.Conversion

TU-Delft TI1400/11-PDS 13 Compatibility Compatibility: functionality of system is independent of implementation -machine versions with same instruction set Upward (FWD) compatibility: new version of system incorporates functionality of old system -Code compiled on old system will run on new system -CDs are FWD-compatible with DVD readers -(DVD readers are backwards-compatible with CDs)

TU-Delft TI1400/11-PDS 14 Portability (1) Portability is the ease of transferring a program to different machines and operating systems. Problems: -Different machine instructions -Different OS calls -Other compiler with deviating conventions

TU-Delft TI1400/11-PDS 15 Portability (3) Steps: -making readable on new system -adapt to new OS -recompile Performance characteristics can change

TU-Delft TI1400/11-PDS 16 Conversion Conversion is adaptation of applications to a different language or (operating) system -Faster code execution Conversion problems: -expressiveness of new language -different operating systems -different network environment -different machine precision

TU-Delft TI1400/11-PDS 17 Portability/Conversion Cost An example -Mid-size game studio has 25+ game titles -4 languages, 25 x 4 = 100 releases -100 platforms (mobiles etc.) -$1,000/release x 100 x 100 = $10,000,000 all Q: How would you address this situation?

TU-Delft TI1400/11-PDS 18 Outsourcing: The Dutch Market Story 0-49k k k 500k+ Outsourcing Web Java Ent. Mobile Services Embedded Stop 0-1yr 1-2yr 2+yr Source: European IT Outsourcing Intelligence Report 2011: The Netherlands Q: Good/Bad news for you?

TU-Delft TI1400/11-PDS 19 Levels of abstraction Language level Machine-program level Microprogram level Assembler level Digital logic level Operating System interpret translate

TU-Delft TI1400/11-PDS 20 Virtual machines (1) Virtual machine M n with machine language L n Virtual machine M 3 with machine language L 3 Virtual machine M 2 with machine language L 2 Real machine M 1 with machine language L 1

TU-Delft TI1400/11-PDS 21 Virtual machines (2) A language defines a virtual machine The machines M 2,...,M n are virtual Machine M 1 is real At M i we need an interpreter or a compiler to translate programs written in L i+1 to L i Hardware and software are equivalent

TU-Delft TI1400/11-PDS 22 Compiler structure Source program Lexicographical analysis Syntactic analysis Semantic analysis Intermediate-code generation Code optimization Code generation Target program

TU-Delft TI1400/11-PDS 23 Lexicographical analysis (1) Goal: reading program text and group characters into tokens intSUM = 0; int SUM=0; intSUM = 0; 10 characters 5 tokens

TU-Delft TI1400/11-PDS 24 Lexicographical analysis (2) Tokens are classified: Keywords (for, if,....) Identifiers (SUM,...) Constants (0, 3.14, “char”) Delimiters ({,;) Operators (+, =,...)

TU-Delft TI1400/11-PDS 25 Lexicographical analysis (3) Identifiers and constants are stored in the symbol table: entrynamekindtypevalue SUMidentint PIconstreal3.1415

TU-Delft TI1400/11-PDS 26 Syntactic analysis Check of correctness of program with respect to the grammar of the language Also called parsing Building of so called parse tree total = 3 + (2*5) = + * 52 3 total

TU-Delft TI1400/11-PDS 27 Semantic analysis Static semantics -(part of) type checking -illegal statements Dynamic semantics -done at run-time -remainder of type checking -operator exceptions (e.g., division by 0)

TU-Delft TI1400/11-PDS 28 Intermediate code (1) Reasons for intermediate code level: 1.simplify compilation process 2.reuse parts of compiler for different architectures In intermediate code: -a single operation at a time -test on only one condition at a time -while loops replaced by test and branch instructions, and labels

TU-Delft TI1400/11-PDS 29 Intermediate code (2): Example while ( (a>b) && (a <= c+d) ) a = a*b; translated into: L1:if (a>b) goto L2 goto L3 L2:h1 = c+d if (a <= h1) goto L4 goto L3 L4:a = a*b goto L1 L3:

TU-Delft TI1400/11-PDS 30 Code generation (1) MOVEAX, (0) MOV, EAX MOVEAX, 3 ADDEAX, MOVEAX, 2 MOV EBX, 5 IMULEAX, EBX = 3 + 2*5 = “total”

TU-Delft TI1400/11-PDS 31 Code generation (2) MOVEAX, 2 load 2 in EAX MOVEBX, 5 load 5 in EBX IMULEAX,EBXmultiply PUSHEAXpush result on stack MOVEAX, 3 load 3 in EAX POPEBXpop from stack ADDEAX,EBXaddition PUSHEAXpush result on stack POPEAXpop from stack MOVtotal(0),EAXdo final assignment communication via stack

TU-Delft TI1400/11-PDS 32 Code optimization MOVEAX, 2load 2 in EAX MOV EBX, 5load 5 in EBX IMULEAX,EBXmultiply MOVEBX, 3load 3 in EBX ADDEAX, EBXaddition STWtotal(0), EAXdo final assignment omit communication via stack