Habanero Extreme Scale Software Research Project



Similar documents
language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

The Java Virtual Machine (JVM) Pat Morin COMP 3002

University of Twente. A simulation of the Java Virtual Machine using graph grammars

Structural Typing on the Java Virtual. Machine with invokedynamic

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

The C Programming Language course syllabus associate level

Habanero Extreme Scale Software Research Project

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding

02 B The Java Virtual Machine

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Chapter 7D The Java Virtual Machine

Java Interview Questions and Answers

1 The Java Virtual Machine

Pemrograman Dasar. Basic Elements Of Java

Under the Hood: The Java Virtual Machine. Lecture 24 CS 2110 Fall 2011

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

Java Virtual Machine, JVM

ProfBuilder: A Package for Rapidly Building Java Execution Profilers Brian F. Cooper, Han B. Lee, and Benjamin G. Zorn

HVM TP : A Time Predictable and Portable Java Virtual Machine for Hard Real-Time Embedded Systems JTRES 2014

CS 111 Classes I 1. Software Organization View to this point:

Chapter 1 Fundamentals of Java Programming

Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111

picojava TM : A Hardware Implementation of the Java Virtual Machine

Crash Course in Java

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Inside the Java Virtual Machine

- Applet java appaiono di frequente nelle pagine web - Come funziona l'interprete contenuto in ogni browser di un certo livello? - Per approfondire

Implementation Aspects of OO-Languages

Stack Allocation. Run-Time Data Structures. Static Structures

Lecture 32: The Java Virtual Machine. The Java Virtual Machine

Glossary of Object Oriented Terms

Built-in Concurrency Primitives in Java Programming Language. by Yourii Martiak and Mahir Atmis

Checking Access to Protected Members in the Java Virtual Machine

Introduction to Java

An Overview of Java. overview-1

COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms.

How To Write A Program In Java (Programming) On A Microsoft Macbook Or Ipad (For Pc) Or Ipa (For Mac) (For Microsoft) (Programmer) (Or Mac) Or Macbook (For

7.1 Our Current Model

AP Computer Science Java Subset

C Compiler Targeting the Java Virtual Machine

The Hotspot Java Virtual Machine: Memory and Architecture

Moving from CS 61A Scheme to CS 61B Java

Instruction Set Architecture (ISA)

CSCI E 98: Managed Environments for the Execution of Programs

Reducing Transfer Delay Using Java Class File Splitting and Prefetching

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.

Can You Trust Your JVM Diagnostic Tools?

Java Application Developer Certificate Program Competencies

The Needle Programming Language

Chapter 4 Lecture 5 The Microarchitecture Level Integer JAVA Virtual Machine

Programmation 2. Introduction à la programmation Java

Computing Concepts with Java Essentials

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Java Programming Fundamentals

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

MCI-Java: A Modified Java Virtual Machine Approach to Multiple Code Inheritance

Java Virtual Machine Locks

Java 6 'th. Concepts INTERNATIONAL STUDENT VERSION. edition

El Dorado Union High School District Educational Services

Chapter 5 Names, Bindings, Type Checking, and Scopes

Java and Java Virtual Machine Security

Real-time Java Processor for Monitoring and Test

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings:

CSC 8505 Handout : JVM & Jasmin

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Sources: On the Web: Slides will be available on:

Armed E-Bunny: A Selective Dynamic Compiler for Embedded Java Virtual Machine Targeting ARM Processors

Java (12 Weeks) Introduction to Java Programming Language

C++ Programming Language

X86-64 Architecture Guide

General Introduction

Write Barrier Removal by Static Analysis

From Bytecode to Javascript: the Js of ocaml Compiler

C++ INTERVIEW QUESTIONS

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming

Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!

Semantic Analysis: Types and Type Checking

Java CPD (I) Frans Coenen Department of Computer Science

The Java Virtual Machine Specification

Java programming for C/C++ developers

C# and Other Languages

Description of Class Mutation Mutation Operators for Java

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Hardware/Software Co-Design of a Java Virtual Machine

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

Java Crash Course Part I

Chapter 5 Functions. Introducing Functions

Object Oriented Software Design

Infrastructure that supports (distributed) componentbased application development

Transcription:

Habanero Extreme Scale Software Research Project

Comp215: Java Method Dispatch Zoran Budimlić (Rice University)

Always remember that you are absolutely unique. Just like everyone else. - Margaret Mead

Polymorphism IList<String> emptylist = List.Empty.create(); IList<String> list = emptylist.add( Alice").add("Bob").add("Charlie"); assertequals(list.head(), Charlie ); GList.head() IList.head()?? List.head()? LazyList.head()

Java system overview

Java Technology The Java programming language The library (JDK) The Java virtual machine (JVM) An instruction set and the meaning of those instructions the bytecodes A binary format the class file format An algorithm to verify the class file

JVM Data Types reference int long Pointer to an object or array 32-bit integer (signed) 64-bit integer (signed) float 32-bit floating-point (IEEE 754-1985) double 64-bit floating-point (IEEE 754-1985) No boolean, char, byte, and short types Stack contains only 32-bit and 64-bit data Conversion instructions

JVM Instruction Set The Bytecodes Operations on the operand stack Variable length Simple, e.g. iadd Complex, e.g. new Symbolic references 201 different instructions

Instruction Types Arithmetic Load and store Type conversion Object creation and manipulation Operand stack manipulation Control transfer Method invocation and return

Arithmetic Instructions Operate on the values from the stack Push the result back onto the stack Instructions for int, long, float and double No direct support for byte, short or char types Handled by int operations and type conversion

Method Invocation, Return invokevirtual Invokes an instance method of an object, dispatching on the (virtual) type of the object. This is the normal method dispatch in the Java programming language invokeinterface Invokes a method that is implemented by an interface invokespecial Invokes an instance method requiring special handling Instance initialization method, a private method, or a superclass method invokestatic Invokes a class (static) method invokedynamic allows the language implementor to define custom linkage behavior. Simplifies implementation of non-java dynamic languages on top of JVM

Class Information Instance size Static (class) variables Virtual method table Interface table Constant pool Reference to super class

Java Class data structure

Method Structure Information about a method Address Length (for the cache) Pointer to the constant pool of the class Number of arguments and local variables

Object Format Direct pointer Handle possible Return pointer to the class information

Stack on Method Invocation SP - stack pointer VP - variable pointer

Your program is a graph IList<String> emptylist = List.Empty.create(); IList<String> list = emptylist.add( Alice").add("Bob").add("Charlie"); assertequals(list.head(), Charlie ); IList.head()?? List.head() LazyList.head()

Method Binding Determining the method to execute in response to a message Binding can be accomplished either statically or dynamically Static Binding: Also known as Early Binding Resolved at compile time Resolution based on static type of the object(s) Allows compiler optimizations Dynamic Binding: Also known as Late Binding Resolved at run-time Resolution based on the dynamic type of the object(s) Uses method dispatch table or Virtual function table

Dynamic dispatch method call is compiled into invokevirtual index index is always the same for the method the method structure gets overwritten in the subclass that overrides the method the JVM looks up the index entry in the virtual method table to find the method information interfaces have their own tables

Virtual Method Dispatch class Foo public class Foo { public void method1(){ }; public int method2(){ }; public double method3(){ }; } public class Bar extends Foo{ public void method1(){ }; public double method3(){ }; } public class Baz extends Foo { public void method1(){ }; public int method2(){ }; } method1 method2 method3 class Baz method1 method2 method3 class Bar method1 method2 method3

Inline cashing IList<String> emptylist = List.Empty.create(); IList<String> list = emptylist.add( Alice").add("Bob").add("Charlie");... assertequals(list.head(), Charlie ); IList.head() List.head()

Inline cashing IList<String> emptylist = List.Empty.create(); IList<String> list = emptylist.add( Alice").add("Bob").add("Charlie");... assertequals(list.head(), Charlie ); + check List.head() Inline cashing of this method in HotSpot JVM

Deep hierarchies Virtual method tables can be pretty large Memory overhead Method dispatch can be pretty expensive Inline cashing not always effective Truly polymorphic variables Be careful with your mission-critical code

Tail Recursion class List: public boolean contains(t element){ if (head().equals(element)) return true; return tail().contains(element); } class List.Empty: public boolean contains(t element){ return false; } Tail Recursion! if(mylist.contains(myelement))...

Tail Recursion Empty().contains() tail().contains() tail().contains() mylist.contains()

Tail Recursion Empty().contains() goto goto tail().contains() goto tail().contains() mylist.contains()

Tail recursion and tail call elimination in Java Not there in Java (yet) Brian Goetz (Java Language Architect at Oracle): it will eventually get done. Other languages have it (Scala, ML, Scheme, ) Some of them map onto JVM Good practice So when Java finally implements it, or you move to another functional language, you re ready

Live Coding: Dan s Log class