Language Levels and Translation

  • Published on
    03-Jan-2016

  • View
    28

  • Download
    2

DESCRIPTION

Language Levels and Translation. http://www.pds.ewi.tudelft.nl/~iosup/Courses/2012_ti1400_Reader.ppt. See also: Blackboard >> Course Material >> Reader (Dictaat) http://www.pds.ewi.tudelft.nl/vakken/in1705/cos2007.pdf. IT Industry Competitiveness. Q: Good/Bad news for you ?. - PowerPoint PPT Presentation

Transcript

  • *Language Levelsand Translationhttp://www.pds.ewi.tudelft.nl/~iosup/Courses/2012_ti1400_Reader.ppt

    See also: Blackboard >> Course Material >> Reader (Dictaat)http://www.pds.ewi.tudelft.nl/vakken/in1705/cos2007.pdf

    TU-DelftTI1400/12-PDS

    *IT Industry CompetitivenessSource: The Economist, Benchmarking IT industry competitiveness 2009 http://portal.bsa.org/2009eiu/study/2009_eiu_global.pdf NL only Top-20, see 2011 indexQ: Good/Bad news for you?

    TU-DelftTI1400/12-PDS

    *The Netherlands: A Top IT IndustrySource: The Economist, Benchmarking IT industry competitiveness 2009 http://portal.bsa.org/2009eiu/study/2009_eiu_global.pdf

    TU-DelftTI1400/12-PDS

    *But Wheres the Human Capital?A longer-term challenge for some European countries is encouraging more graduates to choose science-related subjects.NL is 27th in HCSource: The Economist, Benchmarking IT industry competitiveness 2009Q: Good/Bad news for you?

    TU-DelftTI1400/12-PDS

    *The Simplest(?) Problem: How to Program Computers?So farDesign them from scratch AssemblyThis lectureLanguage levelsTranslationThe compiler sequence

    TU-DelftTI1400/12-PDS

    *Language levelsA computer has several language levels:machine languageassembler 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-DelftTI1400/12-PDS

    *Program transformationsNeed for program transformationsSemantics of programs must remain the sameTwo ways of transformation:compilation: first translate, then executeinterpretation: interleave translation and execution

    TU-DelftTI1400/12-PDS

    *Type of translatorsJavamachineinstructionsJavaIA-32assemblermachineinstructionsJavaIA-32assemblermachineinstructionsJVMcompile tomachinelanguageinterpretbyte codecompile toassemblercompileassembleassemble

    TU-DelftTI1400/12-PDS

    *Types of interpretersprogram

    PCprogram

    inter-preter

    IPCPCprogram

    run-timesystem/OS

    (I)PCPCmany steps of PC for one step of IPCCombination: interpret system callsHW InterpreterSW InterpreterHW/SW InterpreterQ: How can you create a SW interpreter?

    TU-DelftTI1400/12-PDS

    *Compilation vs. Interpretation vs. Just-in-Time CompilationAdvantages interpretationDirect edit/execute cycle (5-10x)Debugging on the level of interpreted languageLess memory requirements for programsAdvantage compilationFaster execution (50-100x)Semantic checks during compilation process

    Q: Example when interpretation is better than compilation? Vice-versa?

    TU-DelftTI1400/12-PDS

    *Simulation versus EmulationMimicking of hardware or softwareThrough program: simulationThrough hardware: emulationExample:PowerPC simulation on Intel PentiumVirtual machines such as KVM and VMwareQ: How can you create an NVIDIA Tesla simulator?

    TU-DelftTI1400/12-PDS

    *Programs and machinesIn exchanging programs and machines three notions are relevant:CompatibilityPortabilityConversion

    TU-DelftTI1400/12-PDS

    *CompatibilityCompatibility is functional independence of implem. machine versions with same instruction setDownward (BWD): new sys accepts input generated for/incorporates functionality of old sysCode compiled on old system will run on new systemDVD readers are backwards-compatible with CDsUpward (FWD) compatibility:Code compiled on new system will run on old systemCDs are FWD-compatible with DVD readers

    TU-DelftTI1400/12-PDS

    *Portability (1)Portability is the ease of transferring a program to different machines and operating systems. Problems:Different machine instructionsDifferent OS callsOther compiler with deviating conventions

    TU-DelftTI1400/12-PDS

    *Portability (3)Steps:making readable on new systemadapt to new OSrecompilePerformance characteristics can change

    TU-DelftTI1400/12-PDS

    *ConversionConversion is adaptation of applications to a different language or (operating) systemFaster code executionConversion problems:expressiveness of new languagedifferent operating systemsdifferent network environmentdifferent machine precision

    TU-DelftTI1400/12-PDS

    *Portability/Conversion CostAn exampleMid-size game studio has 25+ game titles4 languages, 25 x 4 = 100 releases100 platforms (mobiles etc.)$1,000/release x 100 x 100 = $10,000,000 all

    Q: How would you address this situation?

    TU-DelftTI1400/12-PDS

    *Outsourcing: The Dutch Market StorySource: European IT Outsourcing Intelligence Report 2011: The Netherlands http://www.itsourcing-europe.com/uploads/Dutch_ITO_Intelligence_Report_2011.pdfQ: Good/Bad news for you?

    TU-DelftTI1400/12-PDS

    *Levels of abstractionLanguage levelMachine-program levelMicroprogram levelAssembler levelDigital logic levelOperating System.......interprettranslate

    TU-DelftTI1400/12-PDS

    *Virtual machines (1)Virtual machine Mn with machine language Ln Virtual machine M3 with machine language L3Virtual machine M2 with machine language L2 Real machine M1 with machine language L1

    TU-DelftTI1400/12-PDS

    *Virtual machines (2)A language defines a virtual machineThe machines M2,...,Mn are virtualMachine M1 is realAt Mi we need an interpreter or a compiler to translate programs written in Li+1 to LiHardware and software are equivalent

    TU-DelftTI1400/12-PDS

    *Compiler structureSource programLexicographical analysisSyntactic analysisSemantic analysisIntermediate-codegenerationCode optimizationCode generationTarget program

    TU-DelftTI1400/12-PDS

    *Lexicographical analysis (1)Goal: reading program text and group characters into tokensintSUM = 0;int SUM=0;intSUM=0;10 characters5 tokens

    TU-DelftTI1400/12-PDS

    *Lexicographical analysis (2)Tokens are classified:Keywords (for, if,....)Identifiers (SUM, ...)Constants (0, 3.14, char)Delimiters ({,;)Operators (+, =, ...)

    TU-DelftTI1400/12-PDS

    *Lexicographical analysis (3)Identifiers and constants are stored in the symbol table:entrynamekindtypevalue..........100SUMidentint............200PIconstreal3.1415

    TU-DelftTI1400/12-PDS

    *Syntactic analysisCheck of correctness of program with respect to the grammar of the languageAlso called parsingBuilding of so called parse treetotal = 3 + (2*5)=+*523total

    TU-DelftTI1400/12-PDS

    *Semantic analysisStatic semantics(part of) type checkingillegal statementsDynamic semanticsdone at run-timeremainder of type checkingoperator exceptions (e.g., division by 0)

    TU-DelftTI1400/12-PDS

    *Intermediate code (1)Reasons for intermediate code level:simplify compilation processreuse parts of compiler for different architecturesIn intermediate code:a single operation at a timetest on only one condition at a timewhile loops replaced by test and branch instructions, and labels

    TU-DelftTI1400/12-PDS

    *Intermediate code (2): Examplewhile ( (a>b) && (a b) goto L2 goto L3L2:h1 = c+dif (a

Recommended

View more >