Compilation 2012 Code Generation
|
|
- Aron Tucker
- 5 years ago
- Views:
Transcription
1 Compilation 2012 Jan Midtgaard Michael I. Schwartzbach Aarhus University
2 Phases Computing resources, such as: layout of data structures offsets register allocation Generating an internal representation of machine code for statements and expressions Optimizing the generated code (ignored for now) Emitting the code to files in assembler format Assembling the emitted code to binary format 2
3 Joos Compute offsets and signatures Generate code for static initializers Generate code for statements and expressions Optimize the generated code (ignored for now) Compute locals and stack limits Emit Jasmin code Assemble Jasmin code to class files 3
4 Computing Offsets Each formal and local variables must have an offset in the stack frame The this object always has offset 0 The naive solution: enumerate all formals and locals The better solution: reuse offsets for locals in disjoint scopes The clever solution: exploit liveness information must still respect the runtime types of locals Each slot in the local array must have a unique type at each location (but not necessarily unique across the whole method) 4
5 Naive Offsets public void m(int p 1, int q 2, Object r 3 ) { 4 int x = 42; int w 5 ; { int z 6 ; z = 87; { boolean a ; Object o 8 ; { boolean b 9 ; int z 10 ; b = true; boolean c 11 ; c = b && (x==87); { int y 12 ; y = x; 7 max = 12 5
6 Better Offsets public void m(int p 1, int q 2, Object r 3 ) { 4 int x = 42; int w 5 ; { int z 6 ; z = 87; { boolean a ; Object o 7 ; { boolean b 8 ; int z 9 ; b = true; boolean c 10 ; c = b && (x==87); { int y 8 ; y = x; 6 max = 10 6
7 Clever Offsets public void m(int p 1, int q 2, Object r 3 ) { 1 int x = 42; int w 2 ; { int z 2 ; z = 87; { boolean a ; Object o 2 ; { boolean b 2 ; int z 3 ; b = true; boolean c 3 ; c = b && (x==87); { int y 2 ; y = x; 2 max = 3 7
8 Computing Signatures (1/2) The function sig(σ) encodes a type: sig(void) = V sig(short) = S sig(char) = C sig(σ[]) = [desc(σ) sig(byte) = B sig(int) = I sig(boolean) = Z sig(c 1.C C k ) = C 1 /C 2 /.../C k desc(void) = V desc(byte) = B desc(short) = S desc(int) = I desc(char) = C desc(boolean) = Z desc(σ[]) = [desc(σ) desc(c 1.C C k ) = LC 1 /C 2 /.../C k ; 8
9 Computing Signatures (2/2) This extends to fields, methods, and constructors The field named x in class C: sig(c)/x The method σ m(σ 1 x 1,..., σ k x k ) in class C: sig(c)/m(desc(σ 1 )...desc(σ k ))desc(σ) The constructor C(σ 1 x 1,..., σ k x k ) in class C: sig(c)/<init>(desc(σ 1 )...desc(σ k ))V 9
10 Static Initializers (1/3) Initialization of static fields is performed when the class is loaded by the JVM All static fields are first given default values The code for initialization is written in a special method with the name <clinit> Fields that are static final and constant valued must then be initialized Finally, all other static fields are initialized 10
11 Static Initializers (2/3) public class A { public static int x = A.y+1; public static final int y = 42; public static void main(string[] args) { System.out.print(A.x); 43 public class A { public static int x = A.y+1; public static int y = 42; public static void main(string[] args) { System.out.print(A.x); 1 public class A { public static int x = A.y+1; public static final int y = A.fortytwo(); public static int fortytwo() { return 42; public static void main(string[] args) { System.out.print(A.x); 1 11
12 Static Initializers (3/3) class A { public static final int y = z; public static final int z = y; public static void main(string args[]) { System.out.println(y+z); Error: Use before definition class A { public static final int y = A.z; public static final int z = A.y; public static void main(string args[]) { System.out.println(y+z); 0
13 Generating Code Each statement and expression generates a sequence of bytecodes A code template shows how to generate bytecodes for a given language construct The template ignores the surrounding context And it ignores uniqueness of label names The given label names are symbolic; you have to make sure they are unique via Instruction.make_label This yields a simple, recursive strategy for the code generation 13
14 Code Template Invariants A statement and a void expression leaves the stack height unchanged A non-void expression increases the stack height by one This is a local property of each template The generated code must be verifiable This is not a local property, since the verifier performs a global static analysis 14
15 Code Templates (1/12) if(e) S 1 else S 2 E ifeq false S 1 goto endif false: S 2 endif: nop if(e) S E ifeq false S false: nop nop not strictly necessary b/c reachability constraints guarantee this is not the last instruction while(e) S goto cond: loop: S cond: E ifne loop while(true) S loop: S goto loop 15
16 Code Templates (2/12) { σ n = E; S E σstore offset(n) S σstore is either istore or astore depending on σ { σ n; S S E; E type(e) = void E; E pop type(e) void throw E; E athrow return E; E σreturn return; return 16
17 Code Templates (3/12) new C(E 1,...,E k δ new sig(c) dup E 1... E k invokespecial sig(δ) this(e 1,...,E k δ aload 0 E 1... E k invokespecial δ indicates that δ is the corresponding resolved declaration 17
18 Code Templates (4/12) super(e 1,...,E k δ aload 0 E 1 The current class contains the non-static field initializations: σ 1 x 1 = I 1 ;... σ n x n = I n ;... E k invokespecial sig(δ) aload 0 I 1 putfield sig(x 1 ) desc(σ 1 )... aload 0 I n putfield sig(x n ) desc(σ n ) 18
19 Code Templates (5/12) E.m(E 1,...,E k δ sig(δ) is on a class E.m(E 1,...,E k δ sig(δ) is on an interface E E 1... E k invokevirtual sig(δ) E E 1... E k invokeinterface sig(δ) C.m(E 1,...,E k δ E 1... E k invokestatic sig(δ) 19
20 Code Templates (6/12) (C)E E checkcast sig(c) (char)e E i2c E instanceof C E instanceof sig(c) 20
21 Code Templates (7/12) this aload 0 n type(n) = σ σload offset(n) E.f E getfield sig(f) desc(type(e.f)) C.f getstatic sig(f) desc(type(c.f)) E 1 [E 2 ] E 1 E 2 σaload type(e 1 [E 2 ]) = σ σaload is either iaload, baload, saload, caload, or aaload depending on σ 21
22 Code Templates (8/12) n = E type(n) = σ E dup σstore offset(n) E 1.f = E 2 E 1 E 2 dup_x1 putfield sig(f) desc(type(e 1.f)) C.f = E E dup putstatic sig(f) desc(type(c.f)) E 1 [E 2 ] = E 3 E 1 E 2 type(e 1 [E 2 ]) = σ E 3 dup_x2 σastore 22
23 Code Templates (9/12) new σ[e] E multianewarray desc(σ ) 1 type(new σ[e]) = σ E.length E arraylength E.clone() E invokevirtual sig(type(e))/clone()ljava/lang/object; 23
24 Code Templates (10/12) 42 ldc_int 42 true ldc_int 1 null aconst_null "abc" ldc_string "abc" 24
25 Code Templates (11/12) E 1 + E 2 E 1 type(e 1 +E 2 ) = int E 2 iadd E 1 + E 2 E 1 E type(e 2 1 +E 2 ) = String invokevirtual S/concat(LS;)LS; S java/lang/string - E E ineg 25
26 Code Templates (12/12) E 1 E 2 E 1 dup ifne firsttrue pop E 2 firsttrue: nop E 1 && E 2 E 1 dup ifeq firstfalse pop E 2 firstfalse: nop nops not strictly necessary b/c reachability constraints guarantee this is not the last instruction 26
27 Stack and Locals Limits The generated code must explicitly state: the maximal number of local and formal offsets the maximal local stack height This is used to determine the size of the frame The locals limit is the maximal offset + 1 The stack limit is computed by a static analysis 27
28 Stack Limit Analysis Consider the control flow graph of the bytecodes succ(s i ) denotes the set of successor bytecodes Δ(S i ) denotes the change in stack height by S i S 0 denotes the first bytecode For every bytecode S i we define the following integer-valued properties: B[[S i ]] denotes the stack height before S i A[[S i ]] denotes the stack height after S i 28
29 Dataflow Constraints B[[S 0 ]] = 0 A[[S i ]] = B[[S i ]] + Δ(S i ) x succ(s i ): A[[S i ]] = B[[x]] A[[S i ]] 0 These constraints must have a solution The stack limit is the largest value of any A[[S i ]] 29
30 Jasmin Class Format (1/3) The overall structure of a Jasmin file is:.source sourcefile.class modifiers name.super sig(superclass).implements sig(interface).field modifiers desc(type) constructors methods 30
31 Jasmin Class Format (2/3) The structure of a constructor is:.method modifiers sig(constructor).throws sig(exception).limit stack stacklimit.limit locals localslimit bytecodes.end method 31
32 Jasmin Class Format (3/3) The structure of a method is:.method modifiers sig(method).throws sig(exception).limit stack stacklimit.limit locals localslimit bytecodes.end method 32
33 A Tiny Class public class Foo { public int y = 42; public Foo(int z) { y = y+z; public String print(int n) { if (n==0) return new Integer(y).toString(); else return new Foo(y).print(n-1); 33
34 The Generated Code.source Foo.java.class public Foo.super java/lang/object.field public "y" I.method public <init>(i)v.limit stack 3.limit locals 2 aload_0 invokespecial java/lang/object/<init>()v aload_0 bipush 42 putfield Foo/y I aload_0 aload_0 getfield Foo/y I iload_1 iadd dup_x1 putfield Foo/y I pop return.end method.method public print(i)ljava/lang/string;.limit stack 3.limit locals 2 iload_1 ifne false0 new java/lang/integer dup aload_0 getfield Foo/y I invokespecial java/lang/integer/<init>(i)v invokevirtual java/lang/integer/tostring()ljava/lang/string; areturn false0: new Foo dup aload_0 getfield Foo/y I invokespecial Foo/<init>(I)V iload_1 iconst_1 isub invokevirtual Foo/print(I)Ljava/lang/String; areturn.end method 34
35 The Binary Class File cafe babe e 001e 0c00 0a a f6c 616e 672f 496e a f6c 616e 672f 4f62 6a c69 6e69 743e c d f6f e 740c c 0a00 1d f a53 6f c a a c f e67 0c00 0f f 6f2e 6a c6a f 6c61 6e67 2f e 673b 0a a 001d 000b c 6a f6c 616e 672f e67 3b f e ab a10 2ab a2a b b 605a b b a e a e1b 039f a bb00 1d59 2ab b700 0cb6 001b b0bb a b400 04b7 001a 1b04 64b b
COMP 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 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 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 informationCSC 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationCompilation 2012 Static Type Checking
Compilation 2012 Jan Midtgaard Michael I. Schwartzbach Aarhus University The Type Checker The type checker has several tasks: determine the types of all expressions check that values and variables are
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 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 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 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 informationCompilation 2012 Static Analysis
Compilation 2012 Jan Midtgaard Michael I. Schwartzbach Aarhus University Interesting Questions Is every statement reachable? Does every non-void method return a value? Will local variables definitely be
More informationTutorial 3: Code Generation
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
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 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 informationStatic Type Checking. Static Type Checking. The Type Checker. Type Annotations. Types Describe Possible Values
The Type Checker Compilation 2007 The type checker has several tasks: determine the types of all expressions check that values and variables are used correctly resolve certain ambiguities by transformations
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 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 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 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 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 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 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 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 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 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 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 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 informationDelft-Java Dynamic Translation
Delft-Java Dynamic Translation John Glossner 1,2 and Stamatis Vassiliadis 2 1 IBM Research DSP and Embedded Computing Yorktown Heights, NY glossner@us.ibm.com (formerly with Lucent Technologies) 2 Delft
More informationIntroduction to Compiler Construction in a Java World
Introduction to Compiler Construction in a Java World Bill Campbell, Swami Iyer, Bahar Akbal-Delibaş Errata Here you can find a listing of known errors in our text. If you find others, please let us know
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 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 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 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 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 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 informationCompiling Faster, Compiling Better with Falcon. Iván
Compiling Faster, Compiling Better with Falcon Iván Krȳlov @JohnWings Compiling Faster, Compiling Better with Falcon Overview of 3 technologies Falcon compiler ReadyNow & Compile Stashing Challenges (largely
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 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 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 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 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 informationReverse engineering of binary programs for custom virtual machines
Reverse engineering of binary programs for custom virtual machines Alexander Chernov, PhD Katerina Troshina, PhD Moscow, Russsia SmartDec.net About us SmartDec decompiler Academic background Defended Ph.D.
More informationJaos - Java on Aos. Oberon Event 03 Patrik Reali
Jaos - Java on Aos Oberon Event 03 Patrik Reali 1 Agenda! Oberon vs. Java! Java for Aos! Type Mapping! Compiling! Linking! Exceptions! Native Methods! Concurrency! Special Topics! Strings! Overloading!
More informationEXAMINATIONS 2014 TRIMESTER 1 SWEN 430. Compiler Engineering. This examination will be marked out of 180 marks.
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 2014 TRIMESTER 1 SWEN 430 Compiler Engineering Time Allowed: THREE HOURS Instructions:
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 informationScala: Byte-code Fancypants. David Pollak JVM Language Summit 2009
Scala: Byte-code Fancypants David Pollak JVM Language Summit 2009 http://github.com/dpp/jvm_summit_2009 About DPP Author Beginning Scala BDFL Lift Wrote some spreadsheets What is Scala? A pile of short-cuts
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 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 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 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 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 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 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 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 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 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 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 informationAdministration CS 412/413. Why build a compiler? Compilers. Architectural independence. Source-to-source translator
CS 412/413 Introduction to Compilers and Translators Andrew Myers Cornell University Administration Design reports due Friday Current demo schedule on web page send mail with preferred times if you haven
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 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 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 informationPractical VM exploiting based on CACAO
Just in Time compilers - breaking a VM Practical VM exploiting based on CACAO Roland Lezuo, Peter Molnar Just in Time compilers - breaking a VM p. Who are we? We are (were) CS students at Vienna University
More informationJava Card Platform. Virtual Machine Specification, Classic Edition. Version 3.1. January 2019
Java Card Platform Virtual Machine Specification, Classic Edition Version 3.1 January 2019 Java Card Platform Virtual Machine Specification, Classic Edition Version 3.1 Copyright 1998, 2019, Oracle and/or
More informationTaming the Java Virtual Machine. Li Haoyi, Chicago Scala Meetup, 19 Apr 2017
Taming the Java Virtual Machine Li Haoyi, Chicago Scala Meetup, 19 Apr 2017 Who Am I? Previously: Dropbox Engineering Currently: Bright Technology Services - Data Science, Scala consultancy Fluent Code
More information1 Compilation (Chapter 1) 2. 2 Lexical Analysis (Chapter 2) 4. 3 Parsing (Chapter 3) 7. 4 Type Checking (Chapter 4) 13
Contents 1 Compilation (Chapter 1) 2 2 Lexical Analysis (Chapter 2) 4 3 Parsing (Chapter 3) 7 4 Type Checking (Chapter 4) 13 5 JVM Code Generation (Chapter 5) 14 6 Translating JVM Code to MIPS Code (Chapter
More informationJava TM. Multi-Dispatch in the. Virtual Machine: Design and Implementation. Computing Science University of Saskatchewan
Multi-Dispatch in the Java TM Virtual Machine: Design and Implementation Computing Science University of Saskatchewan Chris Dutchyn (dutchyn@cs.ualberta.ca) September 22, 08 Multi-Dispatch in the Java
More informationCopyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
1 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16 Towards JVM Dynamic Languages Toolchain Insert Picture Here Attila
More informationOak Intermediate Bytecodes
Oak Intermediate Bytecodes A summary of a paper for the ACM SIGPLAN Workshop on Intermediate Representations (IR 95) James Gosling 100 Hamilton Avenue 3rd floor Palo Alto CA 94301 Oak
More informationJava Code Coverage Mechanics. by Evgeny Mandrikov at EclipseCon Europe 2017
Java Code Coverage Mechanics by Evgeny Mandrikov at EclipseCon Europe 2017 Evgeny Mandrikov @_Godin_ Godin Marc Hoffmann @marcandsweep marchof JaCoCo and Eclipse EclEmma Project Leads /* TODO Don't forget
More informationJava Code Coverage Mechanics
at by Evgeny Mandrikov Java Code Coverage Mechanics #DevoxxFR Evgeny Mandrikov @_Godin_.com/Godin one of JaCoCo and Eclipse EclEmma Project Leads Disclaimer /* TODO don't forget to add huge disclaimer
More informationBytecode-based Analysis for Increasing Class-Component Testability
Bytecode-based Analysis for Increasing Class-Component Testability Supaporn Kansomkeat Faculty of Engineering, Chulalongkorn University Bangkok, 10330, THAILAND supaporn.k@student.chula.ac.th Jeff Offutt
More informationJava Code Coverage Mechanics Evgeny Mandrikov Marc Hoffmann #JokerConf 2017, Saint-Petersburg
Java Code Coverage Mechanics Evgeny Mandrikov Marc Hoffmann #JokerConf 2017, Saint-Petersburg Evgeny Mandrikov @_Godin_ Godin Marc Hoffmann @marcandsweep marchof JaCoCo and Eclipse EclEmma Project Leads
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 informationto perform dependence analysis on Java bytecode, we must extend existing dependence analysis techniques for adapting Java bytecode. In this paper we p
Dependence Analysis of 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 Email:zhao@cs.t.ac.jp
More informationRoadmap. Java: Assembly language: OS: Machine code: Computer system:
Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp
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 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 informationLast name:... First name:... Department (if not D-INFK):...
Concepts of Object-Oriented Programming AS 2016 Concepts of Object-Oriented Programming Midterm Examination 11.11.2016 Prof. Dr. Peter Müller Last name:................................. First name:.................................
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 informationCPSC213/2014W1 Midterm EXTRA Practice
CPSC213/2014W1 Midterm EXTRA Practice DEC/HEX/BIN NUMERACY 1. Convert into decimal: 1a. 0x33 1b. 0x57 1c. 0xaf 1d. 0x7a 1e. 0x1234 1f. 0x69bd 1g. 0x1a64 1h. 0xdead 2. Convert into hex numbers of the specified
More informationCSc 372 Comparative Programming Languages. Getting started... Getting started. B: Java Bytecode BCEL
BCEL CSc 372 Comparative Programming Languages B: Java Bytecode BCEL BCEL (formerly JavaClass) allows you to load a class, iterate through the methods and fields, change methods, add new methods and fields,
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 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 information