SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
Compiler



Die unsichtbaren Diener – Der Compiler und
              seine Artgenossen


Laszlo Böszörmenyi      Compiler        1 / 22
Wozu Compiler?
• Eine der ältesten und grundlegendsten Technologien
• Compilertechnologie hat viele Anwendungsgebiete
      Übersetzung von Programmiersprachen
      Syntaxgetriebene Editoren, Kommandointerpreter
      Halbformale Datenbeschreibungen (z.B. XML)
• Wenn wir Compiler nicht verstehen, verstehen wir
  kaum, wie Programme am Rechner funktionieren
      Was geschieht aufgrund folgender Programmzeilen?
          for (i = 0; i < 10; i++) { a[i] = a[i+1]*x.y.z; print(a[i]); }
          o.addSalary(float sum);
          if (o instance of Student) student = o else person = o;
      Wie werden solche Anweisungen ausgeführt?

Laszlo Böszörmenyi                       Compiler                          2 / 22
Was ist ein Compiler?
• Transformiert Texte einer „höheren“ formalen
  Sprache auf eine “niedrigere” formale Sprache
                Quellecode   Compiler     Zielcode

• Der Quellcode ist üblicherweise lesbar für
  Menschen; der Zielcode für Maschinen
      C → Intel Assembler; Pascal → Motorola Maschinencode
• Ausführbarer Zielcode

                     Input   Zielcode     Output

Laszlo Böszörmenyi             Compiler               3 / 22
Interpretation, Front-end, Back-end
• Der Quellcode kann direkt interpretiert werden
      Kommandointerpreter, Syntaxgetriebene Editoren,
       Scriptsprachen
                      Quellecode
                                      Interpreter   Output
                           Input

• Sprachabhängiges front-end → Zwischensprache
      Z.B. Common Language Runtime (CLR in .NET)
• Zielabhängiges back-end
Quelle1          Front-end1                  Back-end1   Ziel1
                              Zwischenspr.
Quelle2          Front-end2                  Back-end2   Ziel2

Laszlo Böszörmenyi                Compiler                  4 / 22
Interpretierte Ausführung, JIT Compilation
• Der Zwischencode kann von einer virtuellen
  Maschine (z.B. Java VM) interpretiert werden
      Z.B. Java Byte Code – JVM läuft etwa im Browser

                     Zwischencode
                          Input        virtuelle M.   Output


• Zwischencode wird “just-in-time” (JIT) übersetzt
      Zur Laufzeit (z.B. Java); beim Laden (z.B. im .NET)

          Zwischencode        JIT Compiler       Zielcode      Output
                                    Input
Laszlo Böszörmenyi                  Compiler                      5 / 22
Formale Sprachen
• Eine formale Sprache wird definiert durch
      Ein endliches Alphabet, z.B. {0, 1} oder {a, … z, A, … Z}
      Eine Grammatik als eine Menge von Regeln (Syntax)
• Ein Wort (oder Satz) über das Alphabet Σ
      wj = xj1 xj2 … xjm,     wo Σ = {xi | 1 ≤ i ≤ n}
      |wj| = m ist die Länge von wj
      Σ+ : Menge der Wörter über Σ            – transitive Hülle
      Σ* : Σ + + {ε} – transitive und reflexive Hülle (|ε|=0)
      Z.B. Σ = {0, 1}; Σ* = {ε, 0, 1, 00, 01, 11, 000, 001, …}
• KEINE menschlichen Sprachen
      Ziel ist Eindeutigkeit – schlecht für Humor oder Dichtung
      Reife Theorie, relevant für viele Gebiete der Informatik
Laszlo Böszörmenyi               Compiler                           6 / 22
Grammatiken
• Grammatik G ist definiert als: G = (VN, VT, P, S)
      VN: Menge der Variablen (non-terminal Symbole )
      VT : Menge der Terminale (sind Teil der Sprache)
      P: Menge der Produktionen (Regel der Satzbildung,
                                     der Syntax)
      S: Start Symbol      (S ∊ VN)
      VN ∩ VT = Ø (die zwei Mengen sind disjunkt)
      VN ∪ VT = V   (die Vereinigung beider Mengen ist V)
• P enthält Ausdrücke der folgenden Form
     α → β            (α ∊ V+ and β ∊ V*)
      Wenn α → β ∊ P und γ, δ ∊ V* :
       γ α δ ⇒ γ β δ : γ β δ ist eine direkte Ableitung von γ α δ

Laszlo Böszörmenyi             Compiler                      7 / 22
Sprache, erzeugt durch eine Grammatik
•     Ableitung
      Wenn α1 ⇒ α2, α2 ⇒ α3, … αn-1 ⇒ αn dann
      α1 ⇒* αn d.h. αn ist eine Ableitung von α1
      ⇒* ist die reflexive und transitive Hülle von ⇒
             Ableitung in 0 oder mehr Schritten
      ⇒n Ableitung in n Schritten
•     Die Sprache L, generiert durch Grammatik G ist
      {w | w ∊ VT* ∧ S ⇒* w}
      Die Menge aller Wörter, die aus Terminalen bestehen
       und aus dem Startsymbol abgeleitet werden können
      Z.B.: G: VN = {S}, VT = {0, 1}, P = {S → 0S1, S → 01}
      L(G) = {0n1n | n ≥ 1}

Laszlo Böszörmenyi                   Compiler            8 / 22
Grammatik Typen (Noah Chomsky)
• Typ-3 (regulär)
      Wenn A ∊ VN, B ∊ {VN, ε}, w ∊ VT*; Form der Produktionen
       A → w B or A → B w (rechtslinear bzw. linkslinear)
• Typ-2 (kontextfrei)
      ∀ A → β ∊ P A ∊ VN (Einzelvariable) und β # ε (ε ∉ L(G))
      A kann in jedem Kontext durch β ersetzt werden
• Typ-1 (kontextsensitiv)
      A kann nur in einem bestimmten Kontext
       (wie zwischen α1 und α2) durch β ersetzt werden
       α1A α2 → α1βα2       (α1,α2,β ∊ V*; β # ε und A ∊ VN)
      ∀ α → β ∊ P gilt:    |β| ≥ |α|.
• Typ-0
Laszlo Böszörmenyi             Compiler                        9 / 22
Mächtigkeit der Grammatiken
• Regulär ⊂ kontextfrei ⊂ kontextsensitiv ⊂ Typ-0
      Typ-0 Grammatiken umfassen auch kontextsensitive
       Grammatiken, kontextsensitive umfassen kontextfreie
       und kontextfreie umfassen reguläre Grammatiken
• Reguläre Grammatiken erzeugen die gleiche
  Klasse von Sprachen wie endliche Automaten
• Kontextfreie Grammatiken erzeugen die gleiche
  Klasse von Sprachen wie Kellerautomaten
• Zwei Grammatiken sind äquivalent, gdw. (genau
  dann, wenn) sie die gleiche Sprache erzeugen
      G1 ≡ G2, gdw. L(G1) = L(G2)
Laszlo Böszörmenyi            Compiler                  10 / 22
Regulär vs. kontextfreie Grammatiken
                           Regulär                     Kontextfrei
Anwendung             Lexikale Analyse          Syntaktische Analyse
Erkannt      Endliche Automaten                 Kellerautomaten
durch        (Zustände +                        (Zustände + Übergänge +
             Übergänge)                         Keller)
Produktionen A → a | aB                         A→α
Grenzen               Z.B. Konstruktpaare       Z.B. Prüfung von
(was geht             (Verschachtelung,         Übereinstimmung von
NICHT)                Klammerung)               Typdeklaration und
                      (anbn [n1])              Verwendung von Typen)
                                                (anbmcndm [n1, m1])

 Laszlo Böszörmenyi                  Compiler                          11 / 22
Metasprachen
• Definieren andere – komplexere – formale Sprachen
• EBNF (Extended Backus-Naur Form)
      John Backus, Peter Naur, Niklaus Wirth
      Variablen: Namen für syntaktische Konstrukte
      Terminale: Elemente der Sprache, zwischen “ “

  A=xyz                  Sequenz:     A besteht aus x, gefolgt durch y und z

  A = x1 | x2 | ... xk   Alternative: A ist x1 oder x2 oder ... xk

  A = x [y] z            Option:      A ist xz oder xyz

  A = x {y} z            Wiederholung: A ist xz oder xyz oder xy...yz

  A = x {y}+ z           Wiederholung: y zumindest einmal (xz ist illegal)

Laszlo Böszörmenyi                    Compiler                          12 / 22
Syntaxdiagramme – EBNF graphisch

                                                               Terminale
Seq. (A = x y z)          A
                                  x        y           z


                                               x
Alternative (A = x | y | z ) A
                                               y
                                                                Variablen
                                               z

 Wiederholung (A = x {y} z)             Option (A = x [y] z)
A                                        A
        x                     z                    x                 z
                      y                                    y
 Laszlo Böszörmenyi                   Compiler                           13 / 22
EBNF Beispiel

•     Ziffer = “0“|“1“|“2“|“3“|“4“|“5“|“6“|“7“|“8“|“9“
•     Zahl = Ziffer { Ziffer }
•     Buchstabe = “a“ | “b“ | ... | “z“ | “A“ | “B“ | ... | “Z“
•     Name = Buchstabe { Buchstabe | Ziffer }
•     Zahl = Ziffer | Ziffer Zahl (rekursive Definition von Zahl)

                Name

                         Buchstabe
•     Diagramme sind leichter                Ziffer
      zu lesen
•     EBNF ist sehr kompakt                  Buchstabe

Laszlo Böszörmenyi               Compiler                     14 / 22
Grammatik Beispiel (in EBNF)
1.    sentence           = noun-phrase verb-phrase
2.    noun-phrase        = adjective noun-phrase | adjective noun
3.    verb-phrase        = verb adverb
4.    adjective          = “The” | “little”
5.    noun               = “boy”
6.    verb               = “ran”
7.    adverb             = “quickly”
                                         sentence
                     noun-phrase                     verb-phrase

                          noun-phrase

       adjective adjective          noun          verb        adverb
              ?    little               boy        ran         quickly
         The
Laszlo Böszörmenyi                  Compiler                   15 / 22
Phasen der Übersetzung / Ausführung
1. Quelle-zu-Quelle Preprozessor                  Quellcode
     •    Z.B. Markos, wie in C++               Preprozessor
2. Compiler erzeugt Assembly                   Quellcode neu
   Code für die Zielmaschine
3. Assembler erzeugt                             Compiler
   verschiebbaren Binärcode                    Ziel-Assembly
4. Linker und/oder Lader                         Assembler
   berechnen die endgültigen
   Adressen. Die sind entweder               Verschiebbarer Code
     •    Absolut oder                          Linker/Lader
     •    Relativ zum Wert eines Registers
                                             Code in Zielsprache
Laszlo Böszörmenyi             Compiler                      16 / 22
Struktur eines Compilers – Analyse
1. Lexikalische Analyse (der
   Scanner) wandelt den                   Zeichenstrom
   Zeichenstrom in einen Strom
                                             Scanner
   von Symbolen (Token) um
2. Der Parser prüft die Syntax            Symbolstrom
   und erzeugt den Syntaxbaum
                                              Parser
3. Die semantische Analyse     Symbol
   prüft kontextsensitive                  Syntaxbaum
                               Tabelle
   Eigenschaften, wie
   Typkompatibilität                    Semantische Analyse
4. Symboltabelle speichert     Fehler-     Syntaxbaum
   die syntaktischen Elemente meldungen
5. Fehler können in jedem
   Schritt erzeugt werden
Laszlo Böszörmenyi         Compiler                 17 / 22
Struktur eines Compilers – Synthese
1. Zwischencode wird                                  Syntaxbaum
   erzeugt
                                                 Zwischencode Generator
     •    Fehler können auch noch
          hier gefunden werden                        Zwischencode
2. Zielunabhängige
                                               Zielunabhängiger Optimierer
   Optimierung
3. Zielcode wird erzeugt                            Zwischencode neu
4. Zielabhängige                                     Codegenerator
   Optimierung                                          Zielcode
“Optimierung” nicht im
                                                Zielabhängiger Optimierer
Sinn von Op. Research:
Bedeutet Verbesserung                                 Zielcode neu

Laszlo Böszörmenyi                  Compiler                         18 / 22
“Paradigmas” von Programmiersprachen
• Prozedural (Fortran, Algol-60, C, Pascal)
      Parametrisierte Prozeduren, wie P(p1, p2) und globaler Zustand
      Im Mittelpunkt steht das „Verb“ (die Prozedur)
• Objekt-orientiert (C++, Java, C#, Modula-3)
      Objekte definieren Zustandsraum (Instanz-Variablen)
       und Verhalten (Methoden)
      Methoden werden dynamisch (zur Laufzeit) gebunden: o.m(p1, p2)
• Funktional (Lisp, ML)
      Idempotente Funktionsaufrufe, ohne Seiteneffekte (im Idealfall)
• Logisch (Prolog)
      Deklarative Fakten und Einschränkungen definieren das Programm
• Mengen basiert (SET-L, SQL)
• Parallel (High-performance Fortran, Vienna Fortran)
• Verteilt (Orca, Java RMI)
Laszlo Böszörmenyi                  Compiler                        19 / 22
Eine kleine Sprachgeschichte (1)
• Fünfziger Jahre
      Maschinencode, Assembly-Code
      Bedarf an höheren, “abstrakten” Sprachen
      Fortran (für Wissenschaft), Cobol (für Wirtschaft)
           Syntax + Semantik “definiert” durch den (IBM) Compiler
           1958: Übersetzter Code nur zweimal langsamer als händischer
• Sechziger Jahre
      Bedarf an wissenschaftlich fundierte Sprachen
      Algol-60 – „the birth of computer science“ (N. Wirth)
           Formale Syntax; Allgemeine Ausdrücke; Blockstruktur;
            Gültigkeitsbereiche; Parameterübergabe, Rekursion; Boolean
      Simula-67 (O.-J. Dahl, K. Nygaard)
           Erste objekt-orientierte Programmiersprache
           “Wiederentdeckt” 15 Jahre später (Smalltalk-80)
Laszlo Böszörmenyi                  Compiler                      20 / 22
Eine kleine Sprachgeschichte (2)
• Siebziger Jahre
      Bedarf an sicheren (safe) Sprachen
• Pascal (N. Wirth)
      Strikte, statische Typprüfung + benutzerdefinierte Typen
      Unterstützt „strukturierte Programmierung“ durch
       gründlich gewählte Anweisungen und Typkonstruktoren
• C (D. Ritchie)
      Entstanden als Implementierungssprache für Unix
      Eine Art „höhere“ Assembly-Sprache
      Ist nicht sicher (z.B. Pointers ohne Typ)
      Merkwürdige Karriere: C als Implementierungssprache
       für große Anwendungen – eine grobe Fehlentwicklung

Laszlo Böszörmenyi            Compiler                    21 / 22
Eine kleine Sprachgeschichte (3)
• Achtziger Jahre - Modularität, Objekt-Orientierung
      Mesa (Xerox PARC)
           Interface- und Implementierungsmodule, Multi-threading
      Modula-2 (N. Wirth) – wie Mesa, nur einfacher
      Smalltalk-80 (A. Goldmann, Xerox PARC)
      Eiffel (B. Meyer), Ada (J. Ichbiah), Modula-3 (DEC SRC)
      C++ (B. Stroustrup)
           Sehr mächtig, Mehrfachvererbung, nicht typsicher (C-Kompatib.)
• Neunziger Jahre
      Java (J. Gosling, Sun)
           Typsicher (fast), Multi-threading, Garbage Collection
      C# (Microsoft)
           Mächtiger, effizienter und sicherer als Java – zu spät?

Laszlo Böszörmenyi                   Compiler                         22 / 22

Weitere ähnliche Inhalte

Was ist angesagt?

Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14AMD Developer Central
 
[Unite2015 박민근] 유니티 최적화 테크닉 총정리
[Unite2015 박민근] 유니티 최적화 테크닉 총정리[Unite2015 박민근] 유니티 최적화 테크닉 총정리
[Unite2015 박민근] 유니티 최적화 테크닉 총정리MinGeun Park
 
JVM: A Platform for Multiple Languages
JVM: A Platform for Multiple LanguagesJVM: A Platform for Multiple Languages
JVM: A Platform for Multiple LanguagesKris Mok
 
OpenXR – State of the Union - Khronos GDC 2019
OpenXR – State of the Union - Khronos GDC 2019OpenXR – State of the Union - Khronos GDC 2019
OpenXR – State of the Union - Khronos GDC 2019Intel® Software
 
Project ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementationProject ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementationGeoffroy Van Cutsem
 
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012Esun Kim
 
Using Vivox to connect your players: Text and voice comms – Unite Copenhagen ...
Using Vivox to connect your players: Text and voice comms – Unite Copenhagen ...Using Vivox to connect your players: Text and voice comms – Unite Copenhagen ...
Using Vivox to connect your players: Text and voice comms – Unite Copenhagen ...Unity Technologies
 
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019Unity Technologies
 
NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL and Vulkan Support for 2017NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL and Vulkan Support for 2017Mark Kilgard
 
Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4Gerke Max Preussner
 
The Next Generation of PhyreEngine
The Next Generation of PhyreEngineThe Next Generation of PhyreEngine
The Next Generation of PhyreEngineSlide_N
 
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用Shengyou Fan
 
Parallel Futures of a Game Engine
Parallel Futures of a Game EngineParallel Futures of a Game Engine
Parallel Futures of a Game EngineJohan Andersson
 
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)Johan Andersson
 
【Unite Tokyo 2019】今すぐ現場で覚えておきたい最適化技法 ~「ゲシュタルト・オーディン」開発における最適化事例~
【Unite Tokyo 2019】今すぐ現場で覚えておきたい最適化技法 ~「ゲシュタルト・オーディン」開発における最適化事例~【Unite Tokyo 2019】今すぐ現場で覚えておきたい最適化技法 ~「ゲシュタルト・オーディン」開発における最適化事例~
【Unite Tokyo 2019】今すぐ現場で覚えておきたい最適化技法 ~「ゲシュタルト・オーディン」開発における最適化事例~UnityTechnologiesJapan002
 
Practical Occlusion Culling in Killzone 3
Practical Occlusion Culling in Killzone 3Practical Occlusion Culling in Killzone 3
Practical Occlusion Culling in Killzone 3Guerrilla
 
Xen and the Art of Virtualization
Xen and the Art of VirtualizationXen and the Art of Virtualization
Xen and the Art of Virtualizationsathish sak
 
Yocto project and open embedded training
Yocto project and open embedded trainingYocto project and open embedded training
Yocto project and open embedded trainingH Ming
 
FrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in FrostbiteFrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in FrostbiteElectronic Arts / DICE
 
GPU Virtualization on VMware's Hosted I/O Architecture
GPU Virtualization on VMware's Hosted I/O ArchitectureGPU Virtualization on VMware's Hosted I/O Architecture
GPU Virtualization on VMware's Hosted I/O Architectureguestb3fc97
 

Was ist angesagt? (20)

Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
 
[Unite2015 박민근] 유니티 최적화 테크닉 총정리
[Unite2015 박민근] 유니티 최적화 테크닉 총정리[Unite2015 박민근] 유니티 최적화 테크닉 총정리
[Unite2015 박민근] 유니티 최적화 테크닉 총정리
 
JVM: A Platform for Multiple Languages
JVM: A Platform for Multiple LanguagesJVM: A Platform for Multiple Languages
JVM: A Platform for Multiple Languages
 
OpenXR – State of the Union - Khronos GDC 2019
OpenXR – State of the Union - Khronos GDC 2019OpenXR – State of the Union - Khronos GDC 2019
OpenXR – State of the Union - Khronos GDC 2019
 
Project ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementationProject ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementation
 
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012
 
Using Vivox to connect your players: Text and voice comms – Unite Copenhagen ...
Using Vivox to connect your players: Text and voice comms – Unite Copenhagen ...Using Vivox to connect your players: Text and voice comms – Unite Copenhagen ...
Using Vivox to connect your players: Text and voice comms – Unite Copenhagen ...
 
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
 
NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL and Vulkan Support for 2017NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL and Vulkan Support for 2017
 
Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4
 
The Next Generation of PhyreEngine
The Next Generation of PhyreEngineThe Next Generation of PhyreEngine
The Next Generation of PhyreEngine
 
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
 
Parallel Futures of a Game Engine
Parallel Futures of a Game EngineParallel Futures of a Game Engine
Parallel Futures of a Game Engine
 
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
 
【Unite Tokyo 2019】今すぐ現場で覚えておきたい最適化技法 ~「ゲシュタルト・オーディン」開発における最適化事例~
【Unite Tokyo 2019】今すぐ現場で覚えておきたい最適化技法 ~「ゲシュタルト・オーディン」開発における最適化事例~【Unite Tokyo 2019】今すぐ現場で覚えておきたい最適化技法 ~「ゲシュタルト・オーディン」開発における最適化事例~
【Unite Tokyo 2019】今すぐ現場で覚えておきたい最適化技法 ~「ゲシュタルト・オーディン」開発における最適化事例~
 
Practical Occlusion Culling in Killzone 3
Practical Occlusion Culling in Killzone 3Practical Occlusion Culling in Killzone 3
Practical Occlusion Culling in Killzone 3
 
Xen and the Art of Virtualization
Xen and the Art of VirtualizationXen and the Art of Virtualization
Xen and the Art of Virtualization
 
Yocto project and open embedded training
Yocto project and open embedded trainingYocto project and open embedded training
Yocto project and open embedded training
 
FrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in FrostbiteFrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in Frostbite
 
GPU Virtualization on VMware's Hosted I/O Architecture
GPU Virtualization on VMware's Hosted I/O ArchitectureGPU Virtualization on VMware's Hosted I/O Architecture
GPU Virtualization on VMware's Hosted I/O Architecture
 

Andere mochten auch

Cuadros, formas de estado, nacionalidad, ciudadania
Cuadros, formas de estado, nacionalidad, ciudadaniaCuadros, formas de estado, nacionalidad, ciudadania
Cuadros, formas de estado, nacionalidad, ciudadania25442462
 
Artikel Betriebswirtschaftliche Blätter 03/2009_DMI E-Mail Rating by Matthias...
Artikel Betriebswirtschaftliche Blätter 03/2009_DMI E-Mail Rating by Matthias...Artikel Betriebswirtschaftliche Blätter 03/2009_DMI E-Mail Rating by Matthias...
Artikel Betriebswirtschaftliche Blätter 03/2009_DMI E-Mail Rating by Matthias...Matthias Schaefer
 
121127 fritz pleitgen slideshare
121127 fritz pleitgen slideshare121127 fritz pleitgen slideshare
121127 fritz pleitgen slideshareIlka Nienhoff
 
mep 4/2013 - MICE by melody
mep 4/2013 - MICE by melodymep 4/2013 - MICE by melody
mep 4/2013 - MICE by melodyMICEboard
 
Gorkana Breakfast Briefing_Handelsblatt
Gorkana Breakfast Briefing_HandelsblattGorkana Breakfast Briefing_Handelsblatt
Gorkana Breakfast Briefing_HandelsblattGorkana
 
Outfits
OutfitsOutfits
Outfitssara
 
Ausbildungsprogramm Reisejournalismus in Schottland
Ausbildungsprogramm Reisejournalismus in SchottlandAusbildungsprogramm Reisejournalismus in Schottland
Ausbildungsprogramm Reisejournalismus in SchottlandCitytravelreview / Curso eG
 
Cambiar puntero del mouse
Cambiar puntero del mouseCambiar puntero del mouse
Cambiar puntero del mousecanadiense
 
Ost 1 10950 73
Ost 1 10950 73Ost 1 10950 73
Ost 1 10950 73Marc Holt
 
Digitale Kommunikation - ethische Perspektiven
Digitale Kommunikation - ethische PerspektivenDigitale Kommunikation - ethische Perspektiven
Digitale Kommunikation - ethische PerspektivenNele Heise
 
Smart meetings and events - Park Inn by Radisson
Smart meetings and events - Park Inn by RadissonSmart meetings and events - Park Inn by Radisson
Smart meetings and events - Park Inn by RadissonMICEboard
 
Karl heinrich marx
Karl heinrich marxKarl heinrich marx
Karl heinrich marxalibasoff
 
Presentación final
Presentación finalPresentación final
Presentación finalFatima Meza
 
Articulo No 1 - Porque ...corregido
Articulo No 1 - Porque ...corregidoArticulo No 1 - Porque ...corregido
Articulo No 1 - Porque ...corregidoLin Giralt
 
Ein Volk, ein Reich, ein Führer
Ein Volk, ein Reich, ein FührerEin Volk, ein Reich, ein Führer
Ein Volk, ein Reich, ein FührerIEPEI
 

Andere mochten auch (19)

Fghdghh
FghdghhFghdghh
Fghdghh
 
Cuadros, formas de estado, nacionalidad, ciudadania
Cuadros, formas de estado, nacionalidad, ciudadaniaCuadros, formas de estado, nacionalidad, ciudadania
Cuadros, formas de estado, nacionalidad, ciudadania
 
Artikel Betriebswirtschaftliche Blätter 03/2009_DMI E-Mail Rating by Matthias...
Artikel Betriebswirtschaftliche Blätter 03/2009_DMI E-Mail Rating by Matthias...Artikel Betriebswirtschaftliche Blätter 03/2009_DMI E-Mail Rating by Matthias...
Artikel Betriebswirtschaftliche Blätter 03/2009_DMI E-Mail Rating by Matthias...
 
Netzorientiertes Lastmanagement in zukünftigen Smart Grids
Netzorientiertes Lastmanagement in zukünftigen Smart GridsNetzorientiertes Lastmanagement in zukünftigen Smart Grids
Netzorientiertes Lastmanagement in zukünftigen Smart Grids
 
121127 fritz pleitgen slideshare
121127 fritz pleitgen slideshare121127 fritz pleitgen slideshare
121127 fritz pleitgen slideshare
 
mep 4/2013 - MICE by melody
mep 4/2013 - MICE by melodymep 4/2013 - MICE by melody
mep 4/2013 - MICE by melody
 
Gorkana Breakfast Briefing_Handelsblatt
Gorkana Breakfast Briefing_HandelsblattGorkana Breakfast Briefing_Handelsblatt
Gorkana Breakfast Briefing_Handelsblatt
 
Outfits
OutfitsOutfits
Outfits
 
Eine Formel verändert die Welt (PPT)
Eine Formel verändert die Welt (PPT)Eine Formel verändert die Welt (PPT)
Eine Formel verändert die Welt (PPT)
 
Ausbildungsprogramm Reisejournalismus in Schottland
Ausbildungsprogramm Reisejournalismus in SchottlandAusbildungsprogramm Reisejournalismus in Schottland
Ausbildungsprogramm Reisejournalismus in Schottland
 
Cambiar puntero del mouse
Cambiar puntero del mouseCambiar puntero del mouse
Cambiar puntero del mouse
 
Ost 1 10950 73
Ost 1 10950 73Ost 1 10950 73
Ost 1 10950 73
 
Digitale Kommunikation - ethische Perspektiven
Digitale Kommunikation - ethische PerspektivenDigitale Kommunikation - ethische Perspektiven
Digitale Kommunikation - ethische Perspektiven
 
Smart meetings and events - Park Inn by Radisson
Smart meetings and events - Park Inn by RadissonSmart meetings and events - Park Inn by Radisson
Smart meetings and events - Park Inn by Radisson
 
Karl heinrich marx
Karl heinrich marxKarl heinrich marx
Karl heinrich marx
 
Presentación final
Presentación finalPresentación final
Presentación final
 
Articulo No 1 - Porque ...corregido
Articulo No 1 - Porque ...corregidoArticulo No 1 - Porque ...corregido
Articulo No 1 - Porque ...corregido
 
Literaturverwaltung & Bibliotheken - Das zentrale Portal für Informationen ...
Literaturverwaltung & Bibliotheken  - Das zentrale Portal  für Informationen ...Literaturverwaltung & Bibliotheken  - Das zentrale Portal  für Informationen ...
Literaturverwaltung & Bibliotheken - Das zentrale Portal für Informationen ...
 
Ein Volk, ein Reich, ein Führer
Ein Volk, ein Reich, ein FührerEin Volk, ein Reich, ein Führer
Ein Volk, ein Reich, ein Führer
 

Mehr von Förderverein Technische Fakultät

The Digital Transformation of Education: A Hyper-Disruptive Era through Block...
The Digital Transformation of Education: A Hyper-Disruptive Era through Block...The Digital Transformation of Education: A Hyper-Disruptive Era through Block...
The Digital Transformation of Education: A Hyper-Disruptive Era through Block...Förderverein Technische Fakultät
 
Engineering Serverless Workflow Applications in Federated FaaS.pdf
Engineering Serverless Workflow Applications in Federated FaaS.pdfEngineering Serverless Workflow Applications in Federated FaaS.pdf
Engineering Serverless Workflow Applications in Federated FaaS.pdfFörderverein Technische Fakultät
 
The Role of Machine Learning in Fluid Network Control and Data Planes.pdf
The Role of Machine Learning in Fluid Network Control and Data Planes.pdfThe Role of Machine Learning in Fluid Network Control and Data Planes.pdf
The Role of Machine Learning in Fluid Network Control and Data Planes.pdfFörderverein Technische Fakultät
 
Nonequilibrium Network Dynamics_Inference, Fluctuation-Respones & Tipping Poi...
Nonequilibrium Network Dynamics_Inference, Fluctuation-Respones & Tipping Poi...Nonequilibrium Network Dynamics_Inference, Fluctuation-Respones & Tipping Poi...
Nonequilibrium Network Dynamics_Inference, Fluctuation-Respones & Tipping Poi...Förderverein Technische Fakultät
 
East-west oriented photovoltaic power systems: model, benefits and technical ...
East-west oriented photovoltaic power systems: model, benefits and technical ...East-west oriented photovoltaic power systems: model, benefits and technical ...
East-west oriented photovoltaic power systems: model, benefits and technical ...Förderverein Technische Fakultät
 
Advances in Visual Quality Restoration with Generative Adversarial Networks
Advances in Visual Quality Restoration with Generative Adversarial NetworksAdvances in Visual Quality Restoration with Generative Adversarial Networks
Advances in Visual Quality Restoration with Generative Adversarial NetworksFörderverein Technische Fakultät
 
Industriepraktikum_ Unterstützung bei Projekten in der Automatisierung.pdf
Industriepraktikum_ Unterstützung bei Projekten in der Automatisierung.pdfIndustriepraktikum_ Unterstützung bei Projekten in der Automatisierung.pdf
Industriepraktikum_ Unterstützung bei Projekten in der Automatisierung.pdfFörderverein Technische Fakultät
 

Mehr von Förderverein Technische Fakultät (20)

Supervisory control of business processes
Supervisory control of business processesSupervisory control of business processes
Supervisory control of business processes
 
The Digital Transformation of Education: A Hyper-Disruptive Era through Block...
The Digital Transformation of Education: A Hyper-Disruptive Era through Block...The Digital Transformation of Education: A Hyper-Disruptive Era through Block...
The Digital Transformation of Education: A Hyper-Disruptive Era through Block...
 
A Game of Chess is Like a Swordfight.pdf
A Game of Chess is Like a Swordfight.pdfA Game of Chess is Like a Swordfight.pdf
A Game of Chess is Like a Swordfight.pdf
 
From Mind to Meta.pdf
From Mind to Meta.pdfFrom Mind to Meta.pdf
From Mind to Meta.pdf
 
Miniatures Design for Tabletop Games.pdf
Miniatures Design for Tabletop Games.pdfMiniatures Design for Tabletop Games.pdf
Miniatures Design for Tabletop Games.pdf
 
Distributed Systems in the Post-Moore Era.pptx
Distributed Systems in the Post-Moore Era.pptxDistributed Systems in the Post-Moore Era.pptx
Distributed Systems in the Post-Moore Era.pptx
 
Don't Treat the Symptom, Find the Cause!.pptx
Don't Treat the Symptom, Find the Cause!.pptxDon't Treat the Symptom, Find the Cause!.pptx
Don't Treat the Symptom, Find the Cause!.pptx
 
Engineering Serverless Workflow Applications in Federated FaaS.pdf
Engineering Serverless Workflow Applications in Federated FaaS.pdfEngineering Serverless Workflow Applications in Federated FaaS.pdf
Engineering Serverless Workflow Applications in Federated FaaS.pdf
 
The Role of Machine Learning in Fluid Network Control and Data Planes.pdf
The Role of Machine Learning in Fluid Network Control and Data Planes.pdfThe Role of Machine Learning in Fluid Network Control and Data Planes.pdf
The Role of Machine Learning in Fluid Network Control and Data Planes.pdf
 
Nonequilibrium Network Dynamics_Inference, Fluctuation-Respones & Tipping Poi...
Nonequilibrium Network Dynamics_Inference, Fluctuation-Respones & Tipping Poi...Nonequilibrium Network Dynamics_Inference, Fluctuation-Respones & Tipping Poi...
Nonequilibrium Network Dynamics_Inference, Fluctuation-Respones & Tipping Poi...
 
Towards a data driven identification of teaching patterns.pdf
Towards a data driven identification of teaching patterns.pdfTowards a data driven identification of teaching patterns.pdf
Towards a data driven identification of teaching patterns.pdf
 
Förderverein Technische Fakultät.pptx
Förderverein Technische Fakultät.pptxFörderverein Technische Fakultät.pptx
Förderverein Technische Fakultät.pptx
 
The Computing Continuum.pdf
The Computing Continuum.pdfThe Computing Continuum.pdf
The Computing Continuum.pdf
 
East-west oriented photovoltaic power systems: model, benefits and technical ...
East-west oriented photovoltaic power systems: model, benefits and technical ...East-west oriented photovoltaic power systems: model, benefits and technical ...
East-west oriented photovoltaic power systems: model, benefits and technical ...
 
Machine Learning in Finance via Randomization
Machine Learning in Finance via RandomizationMachine Learning in Finance via Randomization
Machine Learning in Finance via Randomization
 
IT does not stop
IT does not stopIT does not stop
IT does not stop
 
Advances in Visual Quality Restoration with Generative Adversarial Networks
Advances in Visual Quality Restoration with Generative Adversarial NetworksAdvances in Visual Quality Restoration with Generative Adversarial Networks
Advances in Visual Quality Restoration with Generative Adversarial Networks
 
Recent Trends in Personalization at Netflix
Recent Trends in Personalization at NetflixRecent Trends in Personalization at Netflix
Recent Trends in Personalization at Netflix
 
Industriepraktikum_ Unterstützung bei Projekten in der Automatisierung.pdf
Industriepraktikum_ Unterstützung bei Projekten in der Automatisierung.pdfIndustriepraktikum_ Unterstützung bei Projekten in der Automatisierung.pdf
Industriepraktikum_ Unterstützung bei Projekten in der Automatisierung.pdf
 
Introduction to 5G from radio perspective
Introduction to 5G from radio perspectiveIntroduction to 5G from radio perspective
Introduction to 5G from radio perspective
 

Die unsichtbaren Diener – Der Compiler und seine Artgenossen

  • 1. Compiler Die unsichtbaren Diener – Der Compiler und seine Artgenossen Laszlo Böszörmenyi Compiler 1 / 22
  • 2. Wozu Compiler? • Eine der ältesten und grundlegendsten Technologien • Compilertechnologie hat viele Anwendungsgebiete  Übersetzung von Programmiersprachen  Syntaxgetriebene Editoren, Kommandointerpreter  Halbformale Datenbeschreibungen (z.B. XML) • Wenn wir Compiler nicht verstehen, verstehen wir kaum, wie Programme am Rechner funktionieren  Was geschieht aufgrund folgender Programmzeilen? for (i = 0; i < 10; i++) { a[i] = a[i+1]*x.y.z; print(a[i]); } o.addSalary(float sum); if (o instance of Student) student = o else person = o;  Wie werden solche Anweisungen ausgeführt? Laszlo Böszörmenyi Compiler 2 / 22
  • 3. Was ist ein Compiler? • Transformiert Texte einer „höheren“ formalen Sprache auf eine “niedrigere” formale Sprache Quellecode Compiler Zielcode • Der Quellcode ist üblicherweise lesbar für Menschen; der Zielcode für Maschinen  C → Intel Assembler; Pascal → Motorola Maschinencode • Ausführbarer Zielcode Input Zielcode Output Laszlo Böszörmenyi Compiler 3 / 22
  • 4. Interpretation, Front-end, Back-end • Der Quellcode kann direkt interpretiert werden  Kommandointerpreter, Syntaxgetriebene Editoren, Scriptsprachen Quellecode Interpreter Output Input • Sprachabhängiges front-end → Zwischensprache  Z.B. Common Language Runtime (CLR in .NET) • Zielabhängiges back-end Quelle1 Front-end1 Back-end1 Ziel1 Zwischenspr. Quelle2 Front-end2 Back-end2 Ziel2 Laszlo Böszörmenyi Compiler 4 / 22
  • 5. Interpretierte Ausführung, JIT Compilation • Der Zwischencode kann von einer virtuellen Maschine (z.B. Java VM) interpretiert werden  Z.B. Java Byte Code – JVM läuft etwa im Browser Zwischencode Input virtuelle M. Output • Zwischencode wird “just-in-time” (JIT) übersetzt  Zur Laufzeit (z.B. Java); beim Laden (z.B. im .NET) Zwischencode JIT Compiler Zielcode Output Input Laszlo Böszörmenyi Compiler 5 / 22
  • 6. Formale Sprachen • Eine formale Sprache wird definiert durch  Ein endliches Alphabet, z.B. {0, 1} oder {a, … z, A, … Z}  Eine Grammatik als eine Menge von Regeln (Syntax) • Ein Wort (oder Satz) über das Alphabet Σ  wj = xj1 xj2 … xjm, wo Σ = {xi | 1 ≤ i ≤ n}  |wj| = m ist die Länge von wj  Σ+ : Menge der Wörter über Σ – transitive Hülle  Σ* : Σ + + {ε} – transitive und reflexive Hülle (|ε|=0)  Z.B. Σ = {0, 1}; Σ* = {ε, 0, 1, 00, 01, 11, 000, 001, …} • KEINE menschlichen Sprachen  Ziel ist Eindeutigkeit – schlecht für Humor oder Dichtung  Reife Theorie, relevant für viele Gebiete der Informatik Laszlo Böszörmenyi Compiler 6 / 22
  • 7. Grammatiken • Grammatik G ist definiert als: G = (VN, VT, P, S)  VN: Menge der Variablen (non-terminal Symbole )  VT : Menge der Terminale (sind Teil der Sprache)  P: Menge der Produktionen (Regel der Satzbildung, der Syntax)  S: Start Symbol (S ∊ VN)  VN ∩ VT = Ø (die zwei Mengen sind disjunkt)  VN ∪ VT = V (die Vereinigung beider Mengen ist V) • P enthält Ausdrücke der folgenden Form α → β (α ∊ V+ and β ∊ V*)  Wenn α → β ∊ P und γ, δ ∊ V* : γ α δ ⇒ γ β δ : γ β δ ist eine direkte Ableitung von γ α δ Laszlo Böszörmenyi Compiler 7 / 22
  • 8. Sprache, erzeugt durch eine Grammatik • Ableitung  Wenn α1 ⇒ α2, α2 ⇒ α3, … αn-1 ⇒ αn dann  α1 ⇒* αn d.h. αn ist eine Ableitung von α1  ⇒* ist die reflexive und transitive Hülle von ⇒  Ableitung in 0 oder mehr Schritten  ⇒n Ableitung in n Schritten • Die Sprache L, generiert durch Grammatik G ist  {w | w ∊ VT* ∧ S ⇒* w}  Die Menge aller Wörter, die aus Terminalen bestehen und aus dem Startsymbol abgeleitet werden können  Z.B.: G: VN = {S}, VT = {0, 1}, P = {S → 0S1, S → 01}  L(G) = {0n1n | n ≥ 1} Laszlo Böszörmenyi Compiler 8 / 22
  • 9. Grammatik Typen (Noah Chomsky) • Typ-3 (regulär)  Wenn A ∊ VN, B ∊ {VN, ε}, w ∊ VT*; Form der Produktionen A → w B or A → B w (rechtslinear bzw. linkslinear) • Typ-2 (kontextfrei)  ∀ A → β ∊ P A ∊ VN (Einzelvariable) und β # ε (ε ∉ L(G))  A kann in jedem Kontext durch β ersetzt werden • Typ-1 (kontextsensitiv)  A kann nur in einem bestimmten Kontext (wie zwischen α1 und α2) durch β ersetzt werden α1A α2 → α1βα2 (α1,α2,β ∊ V*; β # ε und A ∊ VN)  ∀ α → β ∊ P gilt: |β| ≥ |α|. • Typ-0 Laszlo Böszörmenyi Compiler 9 / 22
  • 10. Mächtigkeit der Grammatiken • Regulär ⊂ kontextfrei ⊂ kontextsensitiv ⊂ Typ-0  Typ-0 Grammatiken umfassen auch kontextsensitive Grammatiken, kontextsensitive umfassen kontextfreie und kontextfreie umfassen reguläre Grammatiken • Reguläre Grammatiken erzeugen die gleiche Klasse von Sprachen wie endliche Automaten • Kontextfreie Grammatiken erzeugen die gleiche Klasse von Sprachen wie Kellerautomaten • Zwei Grammatiken sind äquivalent, gdw. (genau dann, wenn) sie die gleiche Sprache erzeugen  G1 ≡ G2, gdw. L(G1) = L(G2) Laszlo Böszörmenyi Compiler 10 / 22
  • 11. Regulär vs. kontextfreie Grammatiken Regulär Kontextfrei Anwendung Lexikale Analyse Syntaktische Analyse Erkannt Endliche Automaten Kellerautomaten durch (Zustände + (Zustände + Übergänge + Übergänge) Keller) Produktionen A → a | aB A→α Grenzen Z.B. Konstruktpaare Z.B. Prüfung von (was geht (Verschachtelung, Übereinstimmung von NICHT) Klammerung) Typdeklaration und (anbn [n1]) Verwendung von Typen) (anbmcndm [n1, m1]) Laszlo Böszörmenyi Compiler 11 / 22
  • 12. Metasprachen • Definieren andere – komplexere – formale Sprachen • EBNF (Extended Backus-Naur Form)  John Backus, Peter Naur, Niklaus Wirth  Variablen: Namen für syntaktische Konstrukte  Terminale: Elemente der Sprache, zwischen “ “ A=xyz Sequenz: A besteht aus x, gefolgt durch y und z A = x1 | x2 | ... xk Alternative: A ist x1 oder x2 oder ... xk A = x [y] z Option: A ist xz oder xyz A = x {y} z Wiederholung: A ist xz oder xyz oder xy...yz A = x {y}+ z Wiederholung: y zumindest einmal (xz ist illegal) Laszlo Böszörmenyi Compiler 12 / 22
  • 13. Syntaxdiagramme – EBNF graphisch Terminale Seq. (A = x y z) A x y z x Alternative (A = x | y | z ) A y Variablen z Wiederholung (A = x {y} z) Option (A = x [y] z) A A x z x z y y Laszlo Böszörmenyi Compiler 13 / 22
  • 14. EBNF Beispiel • Ziffer = “0“|“1“|“2“|“3“|“4“|“5“|“6“|“7“|“8“|“9“ • Zahl = Ziffer { Ziffer } • Buchstabe = “a“ | “b“ | ... | “z“ | “A“ | “B“ | ... | “Z“ • Name = Buchstabe { Buchstabe | Ziffer } • Zahl = Ziffer | Ziffer Zahl (rekursive Definition von Zahl) Name Buchstabe • Diagramme sind leichter Ziffer zu lesen • EBNF ist sehr kompakt Buchstabe Laszlo Böszörmenyi Compiler 14 / 22
  • 15. Grammatik Beispiel (in EBNF) 1. sentence = noun-phrase verb-phrase 2. noun-phrase = adjective noun-phrase | adjective noun 3. verb-phrase = verb adverb 4. adjective = “The” | “little” 5. noun = “boy” 6. verb = “ran” 7. adverb = “quickly” sentence noun-phrase verb-phrase noun-phrase adjective adjective noun verb adverb ? little boy ran quickly The Laszlo Böszörmenyi Compiler 15 / 22
  • 16. Phasen der Übersetzung / Ausführung 1. Quelle-zu-Quelle Preprozessor Quellcode • Z.B. Markos, wie in C++ Preprozessor 2. Compiler erzeugt Assembly Quellcode neu Code für die Zielmaschine 3. Assembler erzeugt Compiler verschiebbaren Binärcode Ziel-Assembly 4. Linker und/oder Lader Assembler berechnen die endgültigen Adressen. Die sind entweder Verschiebbarer Code • Absolut oder Linker/Lader • Relativ zum Wert eines Registers Code in Zielsprache Laszlo Böszörmenyi Compiler 16 / 22
  • 17. Struktur eines Compilers – Analyse 1. Lexikalische Analyse (der Scanner) wandelt den Zeichenstrom Zeichenstrom in einen Strom Scanner von Symbolen (Token) um 2. Der Parser prüft die Syntax Symbolstrom und erzeugt den Syntaxbaum Parser 3. Die semantische Analyse Symbol prüft kontextsensitive Syntaxbaum Tabelle Eigenschaften, wie Typkompatibilität Semantische Analyse 4. Symboltabelle speichert Fehler- Syntaxbaum die syntaktischen Elemente meldungen 5. Fehler können in jedem Schritt erzeugt werden Laszlo Böszörmenyi Compiler 17 / 22
  • 18. Struktur eines Compilers – Synthese 1. Zwischencode wird Syntaxbaum erzeugt Zwischencode Generator • Fehler können auch noch hier gefunden werden Zwischencode 2. Zielunabhängige Zielunabhängiger Optimierer Optimierung 3. Zielcode wird erzeugt Zwischencode neu 4. Zielabhängige Codegenerator Optimierung Zielcode “Optimierung” nicht im Zielabhängiger Optimierer Sinn von Op. Research: Bedeutet Verbesserung Zielcode neu Laszlo Böszörmenyi Compiler 18 / 22
  • 19. “Paradigmas” von Programmiersprachen • Prozedural (Fortran, Algol-60, C, Pascal)  Parametrisierte Prozeduren, wie P(p1, p2) und globaler Zustand  Im Mittelpunkt steht das „Verb“ (die Prozedur) • Objekt-orientiert (C++, Java, C#, Modula-3)  Objekte definieren Zustandsraum (Instanz-Variablen) und Verhalten (Methoden)  Methoden werden dynamisch (zur Laufzeit) gebunden: o.m(p1, p2) • Funktional (Lisp, ML)  Idempotente Funktionsaufrufe, ohne Seiteneffekte (im Idealfall) • Logisch (Prolog)  Deklarative Fakten und Einschränkungen definieren das Programm • Mengen basiert (SET-L, SQL) • Parallel (High-performance Fortran, Vienna Fortran) • Verteilt (Orca, Java RMI) Laszlo Böszörmenyi Compiler 19 / 22
  • 20. Eine kleine Sprachgeschichte (1) • Fünfziger Jahre  Maschinencode, Assembly-Code  Bedarf an höheren, “abstrakten” Sprachen  Fortran (für Wissenschaft), Cobol (für Wirtschaft)  Syntax + Semantik “definiert” durch den (IBM) Compiler  1958: Übersetzter Code nur zweimal langsamer als händischer • Sechziger Jahre  Bedarf an wissenschaftlich fundierte Sprachen  Algol-60 – „the birth of computer science“ (N. Wirth)  Formale Syntax; Allgemeine Ausdrücke; Blockstruktur; Gültigkeitsbereiche; Parameterübergabe, Rekursion; Boolean  Simula-67 (O.-J. Dahl, K. Nygaard)  Erste objekt-orientierte Programmiersprache  “Wiederentdeckt” 15 Jahre später (Smalltalk-80) Laszlo Böszörmenyi Compiler 20 / 22
  • 21. Eine kleine Sprachgeschichte (2) • Siebziger Jahre  Bedarf an sicheren (safe) Sprachen • Pascal (N. Wirth)  Strikte, statische Typprüfung + benutzerdefinierte Typen  Unterstützt „strukturierte Programmierung“ durch gründlich gewählte Anweisungen und Typkonstruktoren • C (D. Ritchie)  Entstanden als Implementierungssprache für Unix  Eine Art „höhere“ Assembly-Sprache  Ist nicht sicher (z.B. Pointers ohne Typ)  Merkwürdige Karriere: C als Implementierungssprache für große Anwendungen – eine grobe Fehlentwicklung Laszlo Böszörmenyi Compiler 21 / 22
  • 22. Eine kleine Sprachgeschichte (3) • Achtziger Jahre - Modularität, Objekt-Orientierung  Mesa (Xerox PARC)  Interface- und Implementierungsmodule, Multi-threading  Modula-2 (N. Wirth) – wie Mesa, nur einfacher  Smalltalk-80 (A. Goldmann, Xerox PARC)  Eiffel (B. Meyer), Ada (J. Ichbiah), Modula-3 (DEC SRC)  C++ (B. Stroustrup)  Sehr mächtig, Mehrfachvererbung, nicht typsicher (C-Kompatib.) • Neunziger Jahre  Java (J. Gosling, Sun)  Typsicher (fast), Multi-threading, Garbage Collection  C# (Microsoft)  Mächtiger, effizienter und sicherer als Java – zu spät? Laszlo Böszörmenyi Compiler 22 / 22