An Introduction to Multicodes. Ben Stephenson Department of Computer Science University of Western Ontario

Similar documents
A Quantitative Analysis of Java Bytecode Sequences

Compiling Techniques

Improving Java Performance

Improving Java Code Performance. Make your Java/Dalvik VM happier

The Java Virtual Machine

Compiler construction 2009

javac 29: pop 30: iconst_0 31: istore_3 32: jsr [label_51]

Compiler construction 2009

CSC 4181 Handout : JVM

Context Threading: A flexible and efficient dispatch technique for virtual machine interpreters

JVML Instruction Set. How to get more than 256 local variables! Method Calls. Example. Method Calls

A Simplified Java Compilation System for Resource-Constrained Embedded Processors

Building a Compiler with. JoeQ. Outline of this lecture. Building a compiler: what pieces we need? AKA, how to solve Homework 2

Recap: Printing Trees into Bytecodes

A Simplified Java Bytecode Compilation System for Resource-Constrained Embedded Processors

Code Generation Introduction

Compiling Faster, Compiling Better with Falcon. Iván

JVM. What This Topic is About. Course Overview. Recap: Interpretive Compilers. Abstract Machines. Abstract Machines. Class Files and Class File Format

Tutorial 3: Code Generation

Let s make some Marc R. Hoffmann Eclipse Summit Europe

An Analysis of Basic Blocks within SPECjvm98 Applications

The Java Virtual Machine. CSc 553. Principles of Compilation. 3 : The Java VM. Department of Computer Science University of Arizona

Course Overview. PART I: overview material. PART II: inside a compiler. PART III: conclusion

Run-time Program Management. Hwansoo Han

Running class Timing on Java HotSpot VM, 1

COMP 520 Fall 2009 Virtual machines (1) Virtual machines

The Java Virtual Machine

Programming Language Systems

CS2110 Fall 2011 Lecture 25. Under the Hood: The Java Virtual Machine, Part II

Java and C II. CSE 351 Spring Instructor: Ruth Anderson

Shared Mutable State SWEN-220

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats

Just In Time Compilation

Compilation 2012 Code Generation

Chapter 5. A Closer Look at Instruction Set Architectures

A Quantitative Analysis of the Performance Impact of Specialized Bytecodes in Java

SOFTWARE ARCHITECTURE 7. JAVA VIRTUAL MACHINE

Joeq Analysis Framework. CS 243, Winter

Java byte code verification

Program Dynamic Analysis. Overview

3/15/18. Overview. Program Dynamic Analysis. What is dynamic analysis? [3] Why dynamic analysis? Why dynamic analysis? [3]

Topics. Structured Computer Organization. Assembly language. IJVM instruction set. Mic-1 simulator programming

CS263: Runtime Systems Lecture: High-level language virtual machines. Part 1 of 2. Chandra Krintz UCSB Computer Science Department

Java Class Loading and Bytecode Verification

02 B The Java Virtual Machine

Part VII : Code Generation

H.-S. Oh, B.-J. Kim, H.-K. Choi, S.-M. Moon. School of Electrical Engineering and Computer Science Seoul National University, Korea

Under the Hood: The Java Virtual Machine. Problem: Too Many Platforms! Compiling for Different Platforms. Compiling for Different Platforms

Under the Hood: The Java Virtual Machine. Lecture 23 CS2110 Fall 2008

Over-view. CSc Java programs. Java programs. Logging on, and logging o. Slides by Michael Weeks Copyright Unix basics. javac.

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats

Chapter 5. A Closer Look at Instruction Set Architectures

Mixed Mode Execution with Context Threading

LCC 6310 The Computer as an Expressive Medium. Lecture 1

Plan for Today. Safe Programming Languages. What is a secure programming language?

JoeQ Framework CS243, Winter 20156

CS577 Modern Language Processors. Spring 2018 Lecture Interpreters

2001 bei Prof. Dr. Uwe Kastens

CSc 453 Interpreters & Interpretation

Compiler I (dt. Übersetzer I) Prof. Dr. Uwe Kastens Winter 2001/2002

A Trace-based Java JIT Compiler Retrofitted from a Method-based Compiler

Characterizing the SPEC JVM98 Benchmarks On The Java Virtual Machine

Java Instrumentation for Dynamic Analysis

CSCE 314 Programming Languages

Static Program Analysis

A brief overview of COSTA

VM instruction formats. Bytecode translator

Exercise 7 Bytecode Verification self-study exercise sheet

Portable Resource Control in Java The J-SEAL2 Approach

301AA - Advanced Programming [AP-2017]

Mnemonics Type-Safe Bytecode Generation in Scala

JAM 16: The Instruction Set & Sample Programs

Compiler-guaranteed Safety in Code-copying Virtual Machines

Code Generation. Frédéric Haziza Spring Department of Computer Systems Uppsala University

Project. there are a couple of 3 person teams. a new drop with new type checking is coming. regroup or see me or forever hold your peace

to perform dependence analysis on Java bytecode, we must extend existing dependence analysis techniques for adapting Java bytecode. In this paper we p

Portable Resource Control in Java: Application to Mobile Agent Security

Java: framework overview and in-the-small features

Trace Compilation. Christian Wimmer September 2009

Code Generation: Introduction

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Oak Intermediate Bytecodes

Administration CS 412/413. Why build a compiler? Compilers. Architectural independence. Source-to-source translator

EXAMINATIONS 2014 TRIMESTER 1 SWEN 430. Compiler Engineering. This examination will be marked out of 180 marks.

COMP3131/9102: Programming Languages and Compilers

CSc 620 Debugging, Profiling, Tracing, and Visualizing Programs. Compiling Java. The Java Class File Format 1 : JVM

Compiler I. (dt. Übersetzer I) Prof. Dr. Uwe Kastens. Winter 2001/2002. Lecture Compiler I WS 2001/2002 / Slide 01

Code Profiling. CSE260, Computer Science B: Honors Stony Brook University

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1

Translating JVM Code to MIPS Code 1 / 43

COMP3131/9102: Programming Languages and Compilers

High Performance Annotation-aware JVM for Java Cards

YETI. GraduallY Extensible Trace Interpreter VEE Mathew Zaleski, Angela Demke Brown (University of Toronto) Kevin Stoodley (IBM Toronto)

Certified Memory Usage Analysis

The Java Language Implementation

Trusting Virtual Trust

Deriving Java Virtual Machine Timing Models for Portable Worst-Case Execution Time Analysis

point in worrying about performance. The goal of our work is to show that this is not true. This paper is organised as follows. In section 2 we introd

Taming the Java Virtual Machine. Li Haoyi, Chicago Scala Meetup, 19 Apr 2017

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1

Transcription:

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 Future Research Directions Getting More Information

The Java Virtual Machine A piece of software used to execute Java applications Java applications are made up of class files Initialized Data (Constant Pool) Field Information Information for each Method Bytecodes describing functionality of method

Java Bytecodes Similar to assembly language Java virtual machine is a stack based architecture Math and logic bytecodes pop operands off stack and push result onto stack Load and store bytecodes are used to access local variables Get and put bytecodes are used to access fields

A Simple Method int i void f() { } for (i = 0; i < 10; i++) { } System.out.println println(i);

0 aload_0 1 iconst_0 2 putfield #5 <Field int i> 5 goto 28 8 getstatic #6 <Field java.io io.printstream out> 11 aload_0 12 getfield #5 <Field int i> 15 invokevirtual #7 <Method void println(int int)> 18 aload_0 19 dup 20 getfield #5 <Field int i> 23 iconst_1 24 iadd 25 putfield #5 <Field int i> 28 aload_0 29 getfield #5 <Field int i> 32 bipush 10 34 if_icmplt icmplt 8 37 return

0 aload_0 1 iconst_0 i = 0 2 putfield #5 <Field int i> 5 goto 28 8 getstatic #6 <Field java.io io.printstream out> 11 aload_0 System.out.println println(i) 12 getfield #5 <Field int i> 15 invokevirtual #7 <Method void println(int int)> 18 aload_0 19 dup 20 getfield #5 <Field int i> i++ 23 iconst_1 24 iadd 25 putfield #5 <Field int i> 28 aload_0 29 getfield #5 <Field int i> i < 10 32 bipush 10 34 if_icmplt icmplt 8 37 return

Executing a Java Method Execution starts at the beginning of the method A loop inside the VM is used to Fetch the next bytecode Transfer control to the correct place in the JVM to execute the bytecode Execute the bytecode Return to the top of the loop

Executing a Java Method Notice that there is a large amount of overhead! A loop is used to Fetch the next bytecode Transfer control to the correct place in the JVM to execute the bytecode Execute the bytecode Return to the top of the loop

Multicodes Multicodes reduce the amount of overhead by grouping several bytecodes together forming a new bytecode This reduces the number of times the loop must execute, reducing the amount of overhead Consider converting the sequence aload_0 dup getfield iconst_1 iadd putfield to a multicode named fieldinc

0 aload_0 1 iconst_0 i = 0 2 putfield #5 <Field int i> 5 goto 28 8 getstatic #6 <Field java.io io.printstream out> 11 aload_0 System.out.println println(i) 12 getfield #5 <Field int i> 15 invokevirtual #7 <Method void println(int int)> 18 fieldinc #5 <Field int i> i++ 22 aload_0 23 getfield #5 <Field int i> i < 10 26 bipush 10 28 if_icmplt icmplt 8 29 return Five fewer bytecodes Five fewer fetch, transfer and loop operations per iteration of the loop

Identifying Bytecode Sequences We don t want to do a static analysis of the class files Does not consider code that is executed more than 1 time Considers code that is never executed A dynamic analysis was performed Every bytecode executed was recorded The trace of the bytecodes was analyzed

Application Class Files Library Modified Java VM Execution Trace Block Identification Block List Class Files Block List Multicode Identification Multicode List

Bytecode List for Heap Sort 1. aload_1 iload aload_1 iload_3 daload dastore iload_3 iload_3 dup istore iadd istore_3 goto 2. aload_1 iload_3 daload aload_1 iload_3 iconst_1 iadd daload dcmpg ifge 3. aload_0 getfield aload_0 getfield 4. dload aload_1 iload_3 daload dcmpg ifge 5. aload_0 dup getfield iconst_1 iadd putfield S3 arraylength if_icmpge icmpge 6. iload aload_0 getfield if_icmplt icmplt 7. S3 iload iadd caload iload_3 if_icmpne icmpne 8. iload_3 iload if_icmple icmple 9. iload_1 i2c istore_3 iload_2 ifge 10. S3 aload_0 getfield caload invokevirtual

Performance Results (Multicodes of Length 2)

Performance Results (Multicodes of lengths 2 through 5)

Performance Anomaly (Multicodes of lengths 2 through 5) Run Time (s) 56 55.5 55 54.5 54 53.5 53 52.5 52 51.5 51 0 1 2 3 4 5 6 7 8 9 10 Number of Multicodes JavaC

Future Work Optimizing Multicodes At the present time our multicodes are implemented by concatenating the functionality of the bytecodes. This sequence of instructions can be optimized Consider iconst_1 iadd top++ st[top] = 1 top-- st[top] = st[top] + st[top+1] st[top] = st[top] + 1

Future Work Implement more multicodes Loosen the restrictions on multicodes Allow multicodes containing branch bytecodes Perform substitutions at runtime Use multicodes in conjunction with a JIT

Getting More Information B. Stephenson and W. Holst. Multicodes: : Characterization and Optimization of Java Applications [Poster]. Extended abstract in i Proceedings of OOPSLA 2003, Anaheim, California, October 2003. B. Stephenson and W. Holst.. A Quantitative Analysis of Java Bytecode Sequences. Accepted for publication in Proceedings of PPPJ 2004, Las Vegas, Nevada, June 2004. K. Casey, D. Gregg, et. al. Towards Superinstructions for Java Interpreters. In Proceedings of SCOPES 2003, Vienna, Austria, September 2003. T. A. Proebsting.. Optimizing an ANSI C Interpreter with Superoperators.. In Proceedings of POPL 1995. Talk to me

Questions?