Tutorial 3: Code Generation
|
|
- James Higgins
- 6 years ago
- Views:
Transcription
1 S C I E N C E P A S S I O N T E C H N O L O G Y Tutorial 3: Code Generation Univ.-Prof. Dr. Franz Wotawa, DI Roxane Koitz, Stephan Frühwirt, Christopher Liebmann, Martin Zimmermann Institute for Software Technology 1 u
2 Compiler Phases Jova Input Program Java Byte Code 2
3 Compiler Phases Jova Input Program Java Byte Code 3
4 Grammar (Jova.g4) Workflow (1/2) ANTLR Lexer and Parser ANTLR visitor / listener Source Code (*.jova file) Syntax tree Symbol table Lexical and syntactical errors Debugging output Type checking errors Debugging output 4
5 Workflow (2/2) Syntax tree Jasmin code (.j file) Byte code (.class file) Symbol table Jasmin 5
6 What is Jasmin? Assembler for Java bytecode Input: <filename>.j file contains assembly of the original code written in Jasmin assembler language Output: executable Java.class file 6
7 Pipeline Create Assembly Produce jasmin assembly Result: <filename>.j Convert Invoke java jar jasmin.jar <filename>.j Result: <filename>.class Execute Invoke java <filename> Result: executes main method of class 7
8 Jasmin syntax One class per.j file One statement per line Assembly setup: Required options Methods Statements (JVM instructions) 8
9 File structure: Class options.source: e.g.:.class: e.g.:.super: always:.field: e.g.: Source of assembly.source MyClass.jova Resulting java class description.class public MyClass Superclass of resulting java class.super java/lang/object Specify fields of class.field public my_field I 9
10 File structure: Methods.method <method signature> e.g..method public mymethod(i)v.limit stack n n: choose realistic number.limit locals n n = #parameters + #local_vars + #temp_var <instructions> return requires matching type on top-of-stack for non-void returns (e.g. ireturn).end method 10
11 Default Constructor needs to be defined for every class since Jova does not have Constructors you can use the same definition for every class:.method public <init>()v.limit stack 1.limit locals 1 aload_0 invokespecial java/lang/object/<init>()v return.end method 11
12 Example: DoNix File: DoNix.j.source nosource.class public DoNix.super java/lang/object.method public static main([ljava/lang/string;)v.limit stack 0.limit locals 1 ;nothing to do here return.end method 12
13 Data Management Two data structures per method (invocation/frame) Stack Local array Operations to manipulate both Build-in datatypes Primitive Types (int, float, byte, char, ) Reference Types (class types, array types, interface types) Very limited support for boolean 13
14 Data Management: Stack Each method has its own operand stack Size is definable per method (just assume a realistic number) LIFO Stack operations Push values onto stack Pop/Fetch values from stack Instructions which require one or multiple values on stack (order does matter!) 14
15 Data Management: Local Variable Array Each method has its own local variable array Definable size for each method (0-based indices) Typing Can store arbitrary types Items need to be initialized before read access Contains Method parameters (stored in lowest indices) At index 0 the this reference 15
16 Data Managment: Types a few primitives Integer Void Boolean indicated by letter I indicated by letter V indicated by letter Z Objects following the format Lpackage/Classname; e.g. Ljava/lang/String; String object Array indicated by a leading [ e.g. [Ljava/lang/String; array of Strings 16
17 Instructions Can involve stack and local array Most instructions operate on expected types Instruction template: <T><instr> where <T> = type letter <instr> = operation E.g.: iadd, fadd Instructions which do not operate on specific type E.g.: swap, dup 17
18 Instructions: Stack - Locals interaction iload n istore n aload n astore n pushes integer, stored in index n of local array, onto stack pops integer from stack and stores it into index n of local array pushes object, stored in index n of local array, onto stack pops object from stack and stores it into index n of local array 18
19 Instructions: Constants sipush n / bipush n Pushes integer constant onto stack E.g. sipush 10 For m1-5 you can also use iconst_<n> ldc <string> Pushes string constant <string> onto stack E.g. ldc Hello World Note: Strings are Objects (variable access with astore/aload) 19
20 Instructions: Arithmetic Operators iadd isub imul idiv irem ineg add two integers subtract two integers multiply two integers divide two integers modulo division of two integers toggles sign of int on top of stack 20
21 Example: BasicInstructions File: BasicInstructions.j.source nosource.class public BasicInstructions.super java/lang/object.method public static main([ljava/lang/string;)v.limit stack 3.limit locals 2 sipush 5 ;push integer 5 onto stack istore 0 ;pop integer 5 and store in index 0 ldc "Hello i11" ;push string i11 onto stack astore 1 ;store string in index 1 iload 0 ;load 5 dup ;duplicate stack entry 5 sipush 2 ;push integer 2 onto stack isub ;pop 5 and 2 and store result 3 onto stack iadd ;pop 5 and 3 and store result 8 onto stack istore 0 ;store result 8 in index 0 return.end method 21
22 Example: BasicInstructions File: BasicInstructions.j sipush 5 local array args stack 22
23 Example: BasicInstructions File: BasicInstructions.j istore 0 local array args stack 5 23
24 Example: BasicInstructions File: BasicInstructions.j ldc "Hello i11" 5 local array stack 24
25 Example: BasicInstructions File: BasicInstructions.j astore 1 5 local array stack Hello i11 25
26 Example: BasicInstructions File: BasicInstructions.j local array 5 Hello i11 iload 0 stack 26
27 Example: BasicInstructions File: BasicInstructions.j dup local array 5 Hello i11 stack 5 27
28 Example: BasicInstructions File: BasicInstructions.j local array 5 Hello i11 stack sipush
29 Example: BasicInstructions File: BasicInstructions.j local array 5 Hello i11 isub stack
30 Example: BasicInstructions File: BasicInstructions.j local array 5 Hello i11 stack iadd
31 Example: BasicInstructions File: BasicInstructions.j local array 5 Hello i11 stack istore
32 Example: BasicInstructions File: BasicInstructions.j local array 8 Hello i11 stack return 32
33 Instructions: Logical Operators iand ior inot bitwise and of two integers bitwise or of two integers does not exist! Note: Needs to be assembled using custom labels and conditional jump operations 33
34 Instructions: Relational Operators Do not exist! Need to be assembled using custom labels and conditional jump operations 34
35 Instructions: Labels and Jumps <labelname>: sets a label in the assembly goto <labelname> continues execution of current method at position of the label <labelname> if_icmpxx <labelname> pops two elements of the stack, relates them and jumps to <labelname> if comparison computes to true 35
36 Instructions: if_icmp variations if_icmplt relation using < if_icmple relation using <= if_icmpge relation using >= if_icmpgt relation using > if_icmpeq relation using == if_icmpne relation using!= 36
37 Example: LabelsAndJumps File: LabelsAndJumps.j.source nosource.class public LabelsAndJumps.super java/lang/object 37.method public static main([ljava/lang/string;)v.limit stack 2.limit locals 2 sipush 10 istore 0 ;store 10 in index 0 goto L_skip_redef sipush 20 istore 0 ;store 20 to index 0 - skipped L_skip_redef: iload 0 ;push value of index 0: 10 sipush 15 ;push 15 if_icmplt L_is_lesser ldc "greater" ;push string to stack - skipped goto L_end L_is_lesser: ldc "lesser" ;push string to stack L_end: return.end method ; result: string "lesser" on top of stack
38 Example: LabelsAndJumps File: LabelsAndJumps.j sipush 10 local array args stack 38
39 Example: LabelsAndJumps File: LabelsAndJumps.j istore 0 local array args stack 10 39
40 Example: LabelsAndJumps File: LabelsAndJumps.j goto L_skip_redef sipush 20 istore 0 L_skip_redef: local array 10 stack 40
41 Example: LabelsAndJumps File: LabelsAndJumps.j sipush 20 istore 0 L_skip_redef: local array 10 stack 41
42 Example: LabelsAndJumps File: LabelsAndJumps.j local array 10 iload 0 stack 42
43 Example: LabelsAndJumps File: LabelsAndJumps.j local array 10 sipush 15 stack 10 43
44 Example: LabelsAndJumps File: LabelsAndJumps.j local array 10 if_icmplt L_is_lesser ldc "greater" goto L_end L_is_lesser: ldc "lesser" L_end: stack
45 Example: LabelsAndJumps File: LabelsAndJumps.j local array 10 stack ldc "greater" goto L_end L_is_lesser: 45
46 Example: LabelsAndJumps File: LabelsAndJumps.j local array 10 stack ldc "lesser" 46
47 Example: LabelsAndJumps File: LabelsAndJumps.j local array 10 stack lesser L_end: 47
48 Example: LabelsAndJumps File: LabelsAndJumps.j local array 10 stack lesser return 48
49 Instructions: field access Call put-/getfield of object on stack Call using putfield <class ID>/<field ID> <type> getfield <class ID>/<field ID> <type> Requires value and object on stack Example Jova-field: Jasmin-signature: assembly: public int my_field MyClass/my_field I putfield MyClass/my_field I 49
50 Instructions: non-static method calls Call method of object on stack Call using invokevirtual <class ID>/<method signature> Requires parameters and object on stack (in correct order!) Example method: public int mymethod(int a) Jasmin- sig.: MyClass/myMethod(I)I invokevirtual MyClass/myMethod(I)I invokation: 50
51 Instructions: print Based on virtual invokation How to: 1. Push PrintStream object onto stack getstatic java/lang/system/out Ljava/io/PrintStream; 2. Push value onto stack (iload, aload, etc.) 3. Invoke matching PrintStream method invokevirtual java/io/printstream/print(i)v invokevirtual java/io/printstream/print(ljava/lang/string;)v invokevirtual java/io/printstream/print(z)v 51
52 Hints Try and write some simple Jasmin code yourselves Use aload_0 to get this reference Number your labels Map Jova/internal variables to locals array indices Instruction swap/dup may be useful in some cases Use the online documentation to find additional instructions/explanations When in doubt: model a problem in Java - compile it - and use javap -c <Class> to decompile the.class files 52
53 References: Jasmin User Guide: The Structure of the Java Virtual Machine: /html/jvms-2.html 53
54 Questions? 54
CSC 4181 Handout : JVM
CSC 4181 Handout : JVM Note: This handout provides you with the basic information about JVM. Although we tried to be accurate about the description, there may be errors. Feel free to check your compiler
More informationOver-view. CSc Java programs. Java programs. Logging on, and logging o. Slides by Michael Weeks Copyright Unix basics. javac.
Over-view CSc 3210 Slides by Michael Weeks Copyright 2015 Unix basics javac java.j files javap 1 2 jasmin converting from javap to jasmin classfile structure calling methods adding line numbers Java programs
More informationCompiler construction 2009
Compiler construction 2009 Lecture 2 Code generation 1: Generating Jasmin code JVM and Java bytecode Jasmin Naive code generation The Java Virtual Machine Data types Primitive types, including integer
More information02 B The Java Virtual Machine
02 B The Java Virtual Machine CS1102S: Data Structures and Algorithms Martin Henz January 22, 2010 Generated on Friday 22 nd January, 2010, 09:46 CS1102S: Data Structures and Algorithms 02 B The Java Virtual
More informationJVM. What This Topic is About. Course Overview. Recap: Interpretive Compilers. Abstract Machines. Abstract Machines. Class Files and Class File Format
Course Overview What This Topic is About PART I: overview material 1 Introduction 2 Language processors (tombstone diagrams, bootstrapping) 3 Architecture of a compiler PART II: inside a compiler 4 Syntax
More informationCOMP3131/9102: Programming Languages and Compilers
COMP3131/9102: Programming Languages and Compilers Jingling Xue School of Computer Science and Engineering The University of New South Wales Sydney, NSW 2052, Australia http://www.cse.unsw.edu.au/~cs3131
More informationThe Java Virtual Machine
Virtual Machines in Compilation Abstract Syntax Tree Compilation 2007 The compile Virtual Machine Code interpret compile Native Binary Code Michael I. Schwartzbach BRICS, University of Aarhus 2 Virtual
More informationCompiling Techniques
Lecture 10: Introduction to 10 November 2015 Coursework: Block and Procedure Table of contents Introduction 1 Introduction Overview Java Virtual Machine Frames and Function Call 2 JVM Types and Mnemonics
More informationCOMP3131/9102: Programming Languages and Compilers
COMP3131/9102: Programming Languages and Compilers Jingling Xue School of Computer Science and Engineering The University of New South Wales Sydney, NSW 2052, Australia http://www.cse.unsw.edu.au/~cs3131
More informationProgramming Language Systems
Programming Language Systems Instructors: Taiichi Yuasa and Masahiro Yasugi Course Description (overview, purpose): The course provides an introduction to run-time mechanisms such as memory allocation,
More informationCS2110 Fall 2011 Lecture 25. Under the Hood: The Java Virtual Machine, Part II
CS2110 Fall 2011 Lecture 25 Under the Hood: The Java Virtual Machine, Part II 1 Java program last time Java compiler Java bytecode (.class files) Compile for platform with JIT Interpret with JVM run native
More informationAn Introduction to Multicodes. Ben Stephenson Department of Computer Science University of Western Ontario
An Introduction to Multicodes Ben Stephenson Department of Computer Science University of Western Ontario ben@csd csd.uwo.ca Outline Java Virtual Machine Background The Current State of the Multicode Art
More informationCSE 431S Final Review. Washington University Spring 2013
CSE 431S Final Review Washington University Spring 2013 What You Should Know The six stages of a compiler and what each stage does. The input to and output of each compilation stage (especially the back-end).
More informationCourse Overview. PART I: overview material. PART II: inside a compiler. PART III: conclusion
Course Overview PART I: overview material 1 Introduction (today) 2 Language Processors (basic terminology, tombstone diagrams, bootstrapping) 3 The architecture of a Compiler PART II: inside a compiler
More informationJVML Instruction Set. How to get more than 256 local variables! Method Calls. Example. Method Calls
CS6: Program and Data Representation University of Virginia Computer Science Spring 006 David Evans Lecture 8: Code Safety and Virtual Machines (Duke suicide picture by Gary McGraw) pushing constants JVML
More informationKU Compilerbau - Programming Assignment
716.077 KU Compilerbau - Programming Assignment Dr. Birgit Hofer, Univ.-Prof. Dr. Franz Wotawa Institute for Software Technology, Graz University of Technology March 11, 2014 Introduction During this semester
More informationThe Java Virtual Machine. CSc 553. Principles of Compilation. 3 : The Java VM. Department of Computer Science University of Arizona
The Java Virtual Machine CSc 553 Principles of Compilation 3 : The Java VM Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2011 Christian Collberg The Java VM has gone
More informationRecap: Printing Trees into Bytecodes
Recap: Printing Trees into Bytecodes To evaluate e 1 *e 2 interpreter evaluates e 1 evaluates e 2 combines the result using * Compiler for e 1 *e 2 emits: code for e 1 that leaves result on the stack,
More informationA Quantitative Analysis of Java Bytecode Sequences
A Quantitative Analysis of Java Bytecode Sequences Ben Stephenson Wade Holst Department of Computer Science, University of Western Ontario, London, Ontario, Canada 1 Introduction A variety of studies have
More informationCode Generation Introduction
Code Generation Introduction i = 0 LF w h i l e i=0 while (i < 10) { a[i] = 7*i+3 i = i + 1 lexer i = 0 while ( i < 10 ) source code (e.g. Scala, Java,C) easy to write Compiler (scalac, gcc) parser type
More informationSOFTWARE ARCHITECTURE 7. JAVA VIRTUAL MACHINE
1 SOFTWARE ARCHITECTURE 7. JAVA VIRTUAL MACHINE Tatsuya Hagino hagino@sfc.keio.ac.jp slides URL https://vu5.sfc.keio.ac.jp/sa/ Java Programming Language Java Introduced in 1995 Object-oriented programming
More informationPart VII : Code Generation
Part VII : Code Generation Code Generation Stack vs Register Machines JVM Instructions Code for arithmetic Expressions Code for variable access Indexed variables Code for assignments Items How to use items
More informationCSc 620 Debugging, Profiling, Tracing, and Visualizing Programs. Compiling Java. The Java Class File Format 1 : JVM
Attributes Execute The Java Virtual Machine CSc 620 Debugging, Profiling, Tracing, and Visualizing Programs 1 : JVM Christian Collberg collberg+620@gmail.com The Java VM has gone the many complex instructions/large
More informationTopics. Structured Computer Organization. Assembly language. IJVM instruction set. Mic-1 simulator programming
Topics Assembly language IJVM instruction set Mic-1 simulator programming http://www.ontko.com/mic1/ Available in 2 nd floor PC lab S/W found in directory C:\mic1 1 Structured Computer Organization 2 Block
More informationUnder the Hood: The Java Virtual Machine. Problem: Too Many Platforms! Compiling for Different Platforms. Compiling for Different Platforms
Compiling for Different Platforms Under the Hood: The Java Virtual Machine Program written in some high-level language (C, Fortran, ML, ) Compiled to intermediate form Optimized Code generated for various
More informationLet s make some Marc R. Hoffmann Eclipse Summit Europe
Let s make some Marc R. Hoffmann Eclipse Summit Europe 2012 24.10.2012 public class WhatIsFaster { int i; void inc1() { i = i + 1; } void inc2() { i += 1; } void inc3() { i++; } } Why? Compilers Scrip;ng
More informationCompiler Construction. (1 Design practical)
S C I E N C E n P A S S I O N n T E C H N O L O G Y (1 ) 716.077 SS 2017 Univ.-Prof. Dr. Franz Wotawa, DI Roxane Koitz Martin Zimmermann, Christopher Liebmann, Stephan Frühwirt Institute for Software Technology
More informationUnder the Hood: The Java Virtual Machine. Lecture 23 CS2110 Fall 2008
Under the Hood: The Java Virtual Machine Lecture 23 CS2110 Fall 2008 Compiling for Different Platforms Program written in some high-level language (C, Fortran, ML,...) Compiled to intermediate form Optimized
More informationVirtual Machines. COMP 520: Compiler Design (4 credits) Alexander Krolik MWF 9:30-10:30, TR
COMP 520 Winter 2018 Virtual Machines (1) Virtual Machines COMP 520: Compiler Design (4 credits) Alexander Krolik alexander.krolik@mail.mcgill.ca MWF 9:30-10:30, TR 1080 http://www.cs.mcgill.ca/~cs520/2018/
More informationCOMP 520 Fall 2013 Code generation (1) Code generation
COMP 520 Fall 2013 Code generation (1) Code generation COMP 520 Fall 2013 Code generation (2) The code generation phase has several sub-phases: computing resources such as stack layouts, offsets, labels,
More informationBuilding a Compiler with. JoeQ. Outline of this lecture. Building a compiler: what pieces we need? AKA, how to solve Homework 2
Building a Compiler with JoeQ AKA, how to solve Homework 2 Outline of this lecture Building a compiler: what pieces we need? An effective IR for Java joeq Homework hints How to Build a Compiler 1. Choose
More informationThe Java Virtual Machine
The Java Virtual Machine Norman Matloff and Thomas Fifield University of California at Davis c 2001-2007, N. Matloff December 11, 2006 Contents 1 Background Needed 3 2 Goal 3 3 Why Is It a Virtual Machine?
More informationChapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats
Chapter 5 Objectives Understand the factors involved in instruction set architecture design. Chapter 5 A Closer Look at Instruction Set Architectures Gain familiarity with memory addressing modes. Understand
More informationStatic Program Analysis
Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ws-1617/spa/ Recap: Taking Conditional Branches into Account Extending
More informationCompilation 2012 Code Generation
Compilation 2012 Jan Midtgaard Michael I. Schwartzbach Aarhus University Phases Computing resources, such as: layout of data structures offsets register allocation Generating an internal representation
More informationChapter 5. A Closer Look at Instruction Set Architectures
Chapter 5 A Closer Look at Instruction Set Architectures Chapter 5 Objectives Understand the factors involved in instruction set architecture design. Gain familiarity with memory addressing modes. Understand
More informationJoeQ Framework CS243, Winter 20156
Overview Java Intermediate representation JoeQ Framework CS243, Winter 20156 Bytecode JoeQ Framework Quads: Instruction set used in JoeQ JoeQ constructs Writing analysis in JoeQ HW 2 Typical Compiler Infrastructure
More informationJava byte code verification
Java byte code verification SOS Master Science Informatique U. Rennes 1 Thomas Jensen SOS Java byte code verification 1 / 26 Java security architecture Java: programming applications with code from different
More informationPlan for Today. Safe Programming Languages. What is a secure programming language?
cs2220: Engineering Software Class 19: Java Security Java Security Plan for Today Java Byte s () and Verification Fall 2010 UVa David Evans Reminder: Project Team Requests are due before midnight tomorrow
More informationSpace Exploration EECS /25
1/25 Space Exploration EECS 4315 www.eecs.yorku.ca/course/4315/ Nondeterminism 2/25 Nondeterministic code is code that, even for the same input, can exhibit different behaviours on different runs, as opposed
More informationProgram Dynamic Analysis. Overview
Program Dynamic Analysis Overview Dynamic Analysis JVM & Java Bytecode [2] A Java bytecode engineering library: ASM [1] 2 1 What is dynamic analysis? [3] The investigation of the properties of a running
More information3/15/18. Overview. Program Dynamic Analysis. What is dynamic analysis? [3] Why dynamic analysis? Why dynamic analysis? [3]
Overview Program Dynamic Analysis Dynamic Analysis JVM & Java Bytecode [2] A Java bytecode engineering library: ASM [1] 2 What is dynamic analysis? [3] The investigation of the properties of a running
More informationRun-time Program Management. Hwansoo Han
Run-time Program Management Hwansoo Han Run-time System Run-time system refers to Set of libraries needed for correct operation of language implementation Some parts obtain all the information from subroutine
More informationJAM 16: The Instruction Set & Sample Programs
JAM 16: The Instruction Set & Sample Programs Copyright Peter M. Kogge CSE Dept. Univ. of Notre Dame Jan. 8, 1999, modified 4/4/01 Revised to 16 bits: Dec. 5, 2007 JAM 16: 1 Java Terms Java: A simple,
More informationChapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats
Chapter 5 Objectives Chapter 5 A Closer Look at Instruction Set Architectures Understand the factors involved in instruction set architecture design. Gain familiarity with memory addressing modes. Understand
More informationChapter 5. A Closer Look at Instruction Set Architectures
Chapter 5 A Closer Look at Instruction Set Architectures Chapter 5 Objectives Understand the factors involved in instruction set architecture design. Gain familiarity with memory addressing modes. Understand
More informationCMSC430 Spring 2014 Midterm 2 Solutions
CMSC430 Spring 2014 Midterm 2 Solutions 1. (12 pts) Syntax directed translation & type checking Consider the following grammar fragment for an expression for C--: exp CONST IDENT 1 IDENT 2 [ exp 1 ] Assume
More informationCOMP 520 Fall 2009 Virtual machines (1) Virtual machines
COMP 520 Fall 2009 Virtual machines (1) Virtual machines COMP 520 Fall 2009 Virtual machines (2) Compilation and execution modes of Virtual machines: Abstract syntax trees Interpreter AOT-compile Virtual
More informationCode Generation. Frédéric Haziza Spring Department of Computer Systems Uppsala University
Code Generation Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008 Operating Systems Process Management Memory Management Storage Management Compilers Compiling
More informationJoeq Analysis Framework. CS 243, Winter
Joeq Analysis Framework CS 243, Winter 2009-2010 Joeq Background Compiler backend for analyzing and optimizing Java bytecode Developed by John Whaley and others Implemented in Java Research project infrastructure:
More informationImproving Java Performance
Improving Java Performance #perfmatters Raimon Ràfols ...or the mumbo-jumbo behind the java compiler Agenda - Disclaimer - Who am I? - Our friend the java compiler - Language additions & things to consider
More informationjavac 29: pop 30: iconst_0 31: istore_3 32: jsr [label_51]
Analyzing Control Flow in Java Bytecode Jianjun Zhao Department of Computer Science and Engineering Fukuoka Institute of Technology 3-10-1 Wajiro-Higashi, Higashi-ku, Fukuoka 811-02, Japan zhao@cs.t.ac.jp
More informationCS263: Runtime Systems Lecture: High-level language virtual machines. Part 1 of 2. Chandra Krintz UCSB Computer Science Department
CS263: Runtime Systems Lecture: High-level language virtual machines Part 1 of 2 Chandra Krintz UCSB Computer Science Department Portable, Mobile, OO Execution Model Execution model embodied by recent
More informationJava Class Loading and Bytecode Verification
Java Class Loading and Bytecode Verification Every object is a member of some class. The Class class: its members are the (definitions of) various classes that the JVM knows about. The classes can be dynamically
More informationCMPSC 497: Java Security
CMPSC 497: Java Security Trent Jaeger Systems and Internet Infrastructure Security (SIIS) Lab Computer Science and Engineering Department Pennsylvania State University 1 Enforcement Mechanisms Static mechanisms
More informationCode Generation COMP 520: Compiler Design (4 credits) Professor Laurie Hendren
COMP 520 Winter 2015 Code Generation (1) Code Generation COMP 520: Compiler Design (4 credits) Professor Laurie Hendren hendren@cs.mcgill.ca Maggie the Devourer (of Code) COMP 520 Winter 2015 Code Generation
More informationImproving Java Code Performance. Make your Java/Dalvik VM happier
Improving Java Code Performance Make your Java/Dalvik VM happier Agenda - Who am I - Java vs optimizing compilers - Java & Dalvik - Examples - Do & dont's - Tooling Who am I? (Mobile) Software Engineering
More informationCSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1
CSE P 501 Compilers Java Implementation JVMs, JITs &c Hal Perkins Winter 2008 3/11/2008 2002-08 Hal Perkins & UW CSE V-1 Agenda Java virtual machine architecture.class files Class loading Execution engines
More informationStatic Analysis of Dynamic Languages. Jennifer Strater
Static Analysis of Dynamic Languages Jennifer Strater 2017-06-01 Table of Contents Introduction............................................................................... 1 The Three Compiler Options...............................................................
More informationShared Mutable State SWEN-220
Shared Mutable State SWEN-220 The Ultimate Culprit - Shared, Mutable State Most of your development has been in imperative languages. The fundamental operation is assignment to change state. Assignable
More informationCompiling for Different Platforms. Problem: Too Many Platforms! Dream: Platform Independence. Java Platform 5/3/2011
CS/ENGD 2110 Object-Oriented Programming and Data Structures Spring 2011 Thorsten Joachims Lecture 24: Java Virtual Machine Compiling for Different Platforms Program written in some high-level language
More informationProblem: Too Many Platforms!
Compiling for Different Platforms 2 Program written in some high-level language (C, Fortran, ML,...) Compiled to intermediate form Optimized UNDE THE HOOD: THE JAVA VITUAL MACHINE Code generated for various
More information301AA - Advanced Programming [AP-2017]
301AA - Advanced Programming [AP-2017] Lecturer: Andrea Corradini andrea@di.unipi.it Tutor: Lillo GalleBa galleba@di.unipi.it Department of Computer Science, Pisa Academic Year 2017/18 AP-2017-06: The
More informationJava and C II. CSE 351 Spring Instructor: Ruth Anderson
Java and C II CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Lab 5 Due TONIGHT! Fri 6/2
More informationTranslating JVM Code to MIPS Code 1 / 43
Translating JVM Code to MIPS Code 1 / 43 Outline 1 Introduction 2 SPIM and the MIPS Architecture 3 Our Translator 2 / 43 Introduction Compilation is not necessarily done after the class file is constructed
More informationCODE GENERATION FOR JVM,.NET, AND MIPS TARGETS FROM C MINUS LANGUAGE. A Thesis. Submitted to the Department of Computer Science and Engineering
CODE GENERATION FOR JVM,.NET, AND MIPS TARGETS FROM C MINUS LANGUAGE A Thesis Submitted to the Department of Computer Science and Engineering of BRAC University by Md. Zahurul Islam Student ID: 01101002
More informationCompiler construction 2009
Compiler construction 2009 Lecture 3 JVM and optimization. A first look at optimization: Peephole optimization. A simple example A Java class public class A { public static int f (int x) { int r = 3; int
More informationMnemonics Type-Safe Bytecode Generation in Scala
Mnemonics Type-Safe Bytecode Generation in Scala Johannes Rudolph CleverSoft GmbH, Munich Peter Thiemann Albert-Ludwigs-Universität Freiburg, Germany Scala Days 2010, Lausanne, 15.04.2010 Existing bytecode
More informationAgenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1
Agenda CSE P 501 Compilers Java Implementation JVMs, JITs &c Hal Perkins Summer 2004 Java virtual machine architecture.class files Class loading Execution engines Interpreters & JITs various strategies
More informationExercise 7 Bytecode Verification self-study exercise sheet
Concepts of ObjectOriented Programming AS 2018 Exercise 7 Bytecode Verification selfstudy exercise sheet NOTE: There will not be a regular exercise session on 9th of November, because you will take the
More informationKU Compilerbau - Programming Assignment
716.077 KU Compilerbau - Programming Assignment Univ.-Prof. Dr. Franz Wotawa, Birgit Hofer Institute for Software Technology, Graz University of Technology April 20, 2011 Introduction During this semester
More informationJava Instrumentation for Dynamic Analysis
Java Instrumentation for Dynamic Analysis and Michael Ernst MIT CSAIL Page 1 Java Instrumentation Approaches Instrument source files Java Debug Interface (JDI) Instrument class files Page 2 Advantages
More information1 689, High-Performance Computing with Java Technology
1 689, High-Performance Computing with Java Technology High-Performance Computing With Java Technology Stefan Nilsson Assistant Professor Royal Institute of Technology 2 689, High-Performance Computing
More informationJava: framework overview and in-the-small features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer
More informationCSE 431S Code Generation. Washington University Spring 2013
CSE 431S Code Generation Washington University Spring 2013 Code Generation Visitor The code generator does not execute the program represented by the AST It outputs code to execute the program Source to
More informationToday. Instance Method Dispatch. Instance Method Dispatch. Instance Method Dispatch 11/29/11. today. last time
CS2110 Fall 2011 Lecture 25 Java program last time Java compiler Java bytecode (.class files) Compile for platform with JIT Interpret with JVM Under the Hood: The Java Virtual Machine, Part II 1 run native
More informationCode Profiling. CSE260, Computer Science B: Honors Stony Brook University
Code Profiling CSE260, Computer Science B: Honors Stony Brook University http://www.cs.stonybrook.edu/~cse260 Performance Programs should: solve a problem correctly be readable be flexible (for future
More informationCompiler I (dt. Übersetzer I) Prof. Dr. Uwe Kastens Winter 2001/2002
CI-1 Compiler I (dt. Übersetzer I) Prof. Dr. Uwe Kastens Winter 2001/2002 Objectives CI-2 The participants are taught to understand fundamental techniques of language implementation, use generating tools
More information2001 bei Prof. Dr. Uwe Kastens
CI-1 Objectives CI-2 I (dt. Übersetzer I) Prof. Dr. Uwe Kastens Winter 2001/2002 The participants are taught to understand fundamental techniques of language implementation, use generating tools and standard
More informationCompilation 2012 The What and Why of Compilers
Compilation 2012 The What and Why of Compilers Jan Midtgaard Michael I. Schwartzbach Aarhus University What is a Compiler? A program that: tralates from one programming language to another preserves the
More informationCourse Overview. Levels of Programming Languages. Compilers and other translators. Tombstone Diagrams. Syntax Specification
Course Overview Levels of Programming Languages PART I: overview material 1 Introduction 2 Language processors (tombstone diagrams, bootstrapping) 3 Architecture of a compiler PART II: inse a compiler
More informationWhen do We Run a Compiler?
When do We Run a Compiler? Prior to execution This is standard. We compile a program once, then use it repeatedly. At the start of each execution We can incorporate values known at the start of the run
More informationChapter 6: Code Generation
Chapter 6: Code Generation Aarne Ranta Slides for the book Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, 2012. Bridging the semantic gap between
More informationA Tour of Language Implementation
1 CSCE 314: Programming Languages Dr. Flemming Andersen A Tour of Language Implementation Programming is no minor feat. Prometheus Brings Fire by Heinrich Friedrich Füger. Image source: https://en.wikipedia.org/wiki/prometheus
More informationA Force-Directed Program Graph Visualizer for Teaching White-Box Testing Techniques
Paper ID #11203 A Force-Directed Program Graph Visualizer for Teaching White-Box Testing Techniques Dr. Weifeng Xu, Gannon University Dr. Weifeng Xu is an associate professor in department of computer
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationIntroduction Basic elements of Java
Software and Programming I Introduction Basic elements of Java Roman Kontchakov / Carsten Fuhs Birkbeck, University of London Module Information Time: Thursdays in the Spring term Lectures: MAL B04: 2
More informationAdvances in Programming Languages: Generics, interoperability and implementation
Advances in Programming Languages: Generics, interoperability and implementation Stephen Gilmore The University of Edinburgh February 1, 2007 Understanding generic code Generic Java extends Java with generic
More informationCharacterizing the SPEC JVM98 Benchmarks On The Java Virtual Machine
Characterizing the SPEC JVM98 Benchmarks On The Java Virtual Machine Kyle R. Bowers David Kaeli Northeastern University Computer Architecture Research Group Department of Electrical and Computer Engineering
More information301AA - Advanced Programming [AP-2017]
301AA - Advanced Programming [AP-2017] Lecturer: Andrea Corradini andrea@di.unipi.it Tutor: Lillo GalleBa galleba@di.unipi.it Department of Computer Science, Pisa Academic Year 2017/18 AP-2017-05: The
More informationLecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University
Lecture 2 COMP1406/1006 (the Java course) Fall 2013 M. Jason Hinek Carleton University today s agenda a quick look back (last Thursday) assignment 0 is posted and is due this Friday at 2pm Java compiling
More informationJAVA OPERATORS GENERAL
JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators
More informationImplementing on Object-Oriented Language 2.14
2.14 Implementing on Object-Oriented Language 2.14 This section is for readers interested in seeing how an objected-oriented language like Java executes on a MIPS architecture. It shows the Java bytecodes
More informationMichael Rasmussen ZeroTurnaround
Michael Rasmussen ZeroTurnaround Terminology ASM basics Generating bytecode Simple examples Your examples? Lately I ve been, I ve been losing sleep, dreaming about the things that we could be Binary names
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationJava Primer 1: Types, Classes and Operators
Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,
More informationCompiler Construction Assignment 1 Spring 2018
Compiler Construction Assignment 1 Spring 2018 Robert van Engelen In this assignment we construct a compiler in C that translates source program code into target JVM bytecode for execution by the JVM.
More informationINTERMEDIATE REPRESENTATIONS RTL EXAMPLE
INTERMEDIATE REPRESENTATIONS CS 403: Intermediate Representations and Code Generation Stefan D. Bruda Winter 2015 Code generation is typically not done directly The functioning of a compiler is typically
More informationBASICS.
BASICS http://www.flickr.com/photos/oskay/472097903/ CSCI 135 - Fundamentals of Computer Science I 2 Outline Computer Basics Programs and Languages Introduction to the Eclipse IDE Our First Program Comments
More informationEXAMINATIONS 2008 MID-YEAR COMP431 COMPILERS. Instructions: Read each question carefully before attempting it.
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON EXAMINATIONS 2008 MID-YEAR COMP431 COMPILERS Time Allowed: 3 Hours Instructions: Read each
More information