Full HTML for

Basic foilset Optimizing Java

Given by Zoran Budimlic at Java for CSE Meeting on Dec 16 1996. Foils prepared Jan 12 1997
Outside Index Summary of Material No Title


Based on Summer work by Zoran Budimlic at JavaSoft and Collaboration with Ken Kennedy
Java bytecodes are at a higher level than ordinary assembly code
Exceptions greatly reduce code movement opportunities
OOP style (lots of method calls) reduces the data flow information available
No knowledge about the whole program at compile time
Standard trilema: functionality vs. portability vs. performance
Adopt the current javac strategy: one class at a time, no changes to VM, lowest performance
Or sacrifice some portability and functionality for better optimization
Or sacrifice a lot of portability and functionality for best performance

Table of Contents for full HTML of Optimizing Java

Denote Foils where Image Critical
Denote Foils where HTML is sufficient
denotes presence of Additional linked information which is greyed out if missing

1 No Title Optimizing JavaTM
2 No Title Issues
3 Global View
4 First Approach
5 First Approach: Pros And Cons
6 Register and Stack Allocation
7 Current Performance
8 Second Approach
9 Interprocedural Analysis
10 Object Inlining
11 Class Duplication
12 Third Approach
13 Global Problem: Exceptions
14 Exceptions: Possible Solutions
15 Impact on HP Java
16 Conclusion

Outside Index Summary of Material



HTML version of Basic Foils prepared Jan 12 1997

Foil 1 Optimizing JavaTM

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index No Title
Zoran Budimlic
Rice University

HTML version of Basic Foils prepared Jan 12 1997

Foil 2 Issues

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index No Title
Java bytecodes are at a higher level than ordinary assembly code
exceptions greatly reduce code movement opportunities
OOP style (lots of method calls) reduces the data flow information available
no knowledge about the whole program at compile time

HTML version of Basic Foils prepared Jan 12 1997

Foil 3 Global View

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
standard trilema: functionality vs. portability vs. performance
adopt the current javac strategy: one class at a time, no changes to VM, lowest performance
sacrifice some portability and functionality for better optimization
sacrifice a lot of portability and functionality for best performance

HTML version of Basic Foils prepared Jan 12 1997

Foil 4 First Approach

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
based on summer work in JavaSoft
standalone, cross-bytecode, one class at a time
local and peephole optimizations
  • local CSE, cprop, dead, register allocation, stack allocation, copy propagation
SSA construction
simple SSA optimizations
  • dead and cprop

HTML version of Basic Foils prepared Jan 12 1997

Foil 5 First Approach: Pros And Cons

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
requires no changes to VM
insensitive to the choice of source compiler and interpreter/JIT compiler
no interprocedural optimizations
low performance gain
space for some additional, though limited improvements

HTML version of Basic Foils prepared Jan 12 1997

Foil 6 Register and Stack Allocation

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
Java doesn't have registers
local variables are not the same:
  • first 4 (R0-R3) have shorter manipulating instructions
  • first 64 can fit into the register set on UltraJavaTM
operand stack should be used to shorten the bytecode sequence
  • solved in code generation for p-code

HTML version of Basic Foils prepared Jan 12 1997

Foil 7 Current Performance

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index

HTML version of Basic Foils prepared Jan 12 1997

Foil 8 Second Approach

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
interprocedural optimizations of the part of the program that is available
make some assumptions about the code at a compile time, pass the information about it to the run-time

HTML version of Basic Foils prepared Jan 12 1997

Foil 9 Interprocedural Analysis

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
OOP Style
  • lots of short methods
  • lots of method calls
inheritance
  • dynamic binding for intraclass calls
  • objects parameters
limited analysis
  • final methods and classes, instantiated objects, private classes

HTML version of Basic Foils prepared Jan 12 1997

Foil 10 Object Inlining

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
inlining has to preserve field privacy
simple idea: inline both methods and data
we can only inline objects that we instantiated
  • combine with interprocedural analysis
preliminary experiments (Linpack by hand) give ~2 times speed increase, with 20-30% code size increase

HTML version of Basic Foils prepared Jan 12 1997

Foil 11 Class Duplication

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
compile and optimize classes assuming static intraclass calls
have two versions of each class, one for instantiation, one for inheritance
requires the run-time environment to know about this and have appropriate behavior
duplicates the code size

HTML version of Basic Foils prepared Jan 12 1997

Foil 12 Third Approach

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
wait until the whole program is available at the client's side
perform the full range of heavy-duty optimizations, generate native code
high performance, loss of portability
ongoing research ("classical" optimizations, Jeff Dean's thesis)

HTML version of Basic Foils prepared Jan 12 1997

Foil 13 Global Problem: Exceptions

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
many Java instructions can cause an exception
exact exception model
no appropriate model for methods with exception handlers yet
greatly reduces code movement opportunities

HTML version of Basic Foils prepared Jan 12 1997

Foil 14 Exceptions: Possible Solutions

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
determine instructions that will not cause exceptions
  • similar to type analysis
  • restrict the performed optimizations
  • cheat if you can't get caught!
enclose the whole method code in a try
  • encode the knowledge about performed optimizations in the exception handler
  • similar to optimized code debugging

HTML version of Basic Foils prepared Jan 12 1997

Foil 15 Impact on HP Java

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
some portability and functionality has to be sacrificed for high performance
within factor 2 of native C expected for Web based programs
with native-code, whole program optimizing Java compiler, very limited use of exceptions in user programs, we should expect getting very close to native C performance

HTML version of Basic Foils prepared Jan 12 1997

Foil 16 Conclusion

From Optimizing Java Java for CSE Meeting -- Dec 16 1996. *
Full HTML Index
Java is becoming the language of choice in many applications, from WWW to scientific code
it has many appealing features
unfortunately, it is very hard to optimize
fortunately, it is very hard to optimize, so I can get my thesis out of it

Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Apr 11 1999