• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
JVM Internals - NEJUG Nov 2010
 

JVM Internals - NEJUG Nov 2010

on

  • 4,100 views

NEJUG JVM Internals Presentation covers...

NEJUG JVM Internals Presentation covers...
- Garbage Collection
- Byte Code
- HotSpot Optimizations

Statistics

Views

Total Views
4,100
Views on SlideShare
4,076
Embed Views
24

Actions

Likes
16
Downloads
828
Comments
3

7 Embeds 24

http://localhost 10
http://elifmem.com 7
http://www.linkedin.com 2
https://www.linkedin.com 2
http://www.elifmem.com 1
http://www.docshut.com 1
http://115.112.207.57 1
More...

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

13 of 3 previous next Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • perfact article.but i can't download it,can you send me a copy?
    xilinniao@gmail.com thanks!
    Are you sure you want to
    Your message goes here
    Processing…
  • really it is a good presentation, can you provide a presentation on embedded java pls...
    Are you sure you want to
    Your message goes here
    Processing…
  • Doug - very excellent presentations and talk; decompile demos very helpful. Thanks!! A+

    Dan@Lexikos.com
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    JVM Internals - NEJUG Nov 2010 JVM Internals - NEJUG Nov 2010 Presentation Transcript

    • JVM Internals Douglas Q. Hawkins - dougqh@gmail.com http://www.dougqh.net/ Wednesday, November 10, 2010
    • JVM Internals Douglas Q. Hawkins - dougqh@gmail.com http://www.dougqh.net/ http://www.meetup.com/boston-java Wednesday, November 10, 2010
    • JVM Internals HotSpot Garbage Collector HotSpot Optimizations Class File Format & Byte Code Compile Time Run Time Demos Presentation Materials http://www.slideshare.net/dougqh https://github.com/dougqh Wednesday, November 10, 2010
    • Garbage Collection Wednesday, November 10, 2010
    • Garbage Collection Current HotSpot Collectors Demos Garbage First (G1) Collector Wednesday, November 10, 2010
    • Generational Hypothesis Generational Hypothesis 92 to 98% objects die young Few references exist from old objects to new objects http://www.devx.com/Java/Article/21977 http://www.ibm.com/developerworks/java/library/j-jtp09275.html http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • HotSpot Garbage Collector Heap http://download.oracle.com/javase/1.5.0/docs/guide/vm/gc-ergonomics.html http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • HotSpot Garbage Collector Young Generation Old Generation http://download.oracle.com/javase/1.5.0/docs/guide/vm/gc-ergonomics.html http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • HotSpot Garbage Collector Young Generation Eden S1 S2 Old Generation http://download.oracle.com/javase/1.5.0/docs/guide/vm/gc-ergonomics.html http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Object Allocation Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation TLAB Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation TLAB Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation TLAB Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation TLAB Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation TLAB Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation TLAB Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation TLAB Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation TLAB Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Object Allocation TLAB Young Generation Eden S1 S2 Old Generation http://blogs.sun.com/jonthecollector/entry/the_real_thing http://blogs.sun.com/jonthecollector/entry/a_little_thread_privacy_please Wednesday, November 10, 2010
    • Minor Collection TLAB Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Minor Collection TLAB Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Minor Collection TLAB Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Minor Collection Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Minor Collection Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Minor Collection Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Minor Collection Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Minor Collection Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Minor Collection Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Minor Collection Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Minor Collection Young Generation Eden S1 S2 Old Generation http://www.fasterj.com/articles/G1.shtml http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html Wednesday, November 10, 2010
    • Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
    • Stop the World! Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
    • Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
    • Serial Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
    • Serial Parallel Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
    • Demo Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Major Collection Young Generation Eden S1 S2 Old Generation http://www.devx.com/Java/Article/21977/0 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf Wednesday, November 10, 2010
    • Serial Mark Parallel Mark Sweep & Compact Sweep & Compact Application Thread GC Thread http://www.devx.com/Java/Article/21977/0/page/3 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
    • Serial Mark Parallel Mark Sweep & Compact Sweep & Compact Application Thread GC Thread http://www.devx.com/Java/Article/21977/0/page/3 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
    • Serial Mark Parallel Mark Sweep & Compact Sweep & Compact Concurrent Mark & Sweep Application Thread GC Thread http://www.devx.com/Java/Article/21977/0/page/3 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
    • Serial Mark Parallel Mark Sweep & Compact Sweep & Compact Concurrent Mark & Sweep Concurrent Marking Remark Concurrent Sweep Application Thread GC Thread http://www.devx.com/Java/Article/21977/0/page/3 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
    • Demo Wednesday, November 10, 2010
    • Permanent Generation Young Generation Eden S1 S2 Old Generation http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pageId=2669 http://dow.ngra.de/2009/06/15/classloaderlocal-how-to-avoid-classloader-leaks-on-application-redeploy/ Wednesday, November 10, 2010
    • Permanent Generation Young Generation Eden S1 S2 Old Generation Permanent Generation http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pageId=2669 http://dow.ngra.de/2009/06/15/classloaderlocal-how-to-avoid-classloader-leaks-on-application-redeploy/ Wednesday, November 10, 2010
    • Permanent Generation Young Generation Eden S1 S2 Old Generation Permanent Generation Bootstrap App Server Web Application http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pageId=2669 http://dow.ngra.de/2009/06/15/classloaderlocal-how-to-avoid-classloader-leaks-on-application-redeploy/ Wednesday, November 10, 2010
    • Permanent Generation Young Generation Eden S1 S2 Old Generation Permanent Generation Bootstrap App Server Web Application http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pageId=2669 http://dow.ngra.de/2009/06/15/classloaderlocal-how-to-avoid-classloader-leaks-on-application-redeploy/ Wednesday, November 10, 2010
    • Permanent Generation Young Generation Eden S1 S2 Old Generation Permanent Generation Bootstrap App Server Web Application http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pageId=2669 http://dow.ngra.de/2009/06/15/classloaderlocal-how-to-avoid-classloader-leaks-on-application-redeploy/ Wednesday, November 10, 2010
    • Permanent Generation Young Generation Eden S1 S2 Old Generation Permanent Generation Bootstrap App Server Web Application http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pageId=2669 http://dow.ngra.de/2009/06/15/classloaderlocal-how-to-avoid-classloader-leaks-on-application-redeploy/ Wednesday, November 10, 2010
    • Permanent Generation Young Generation Eden S1 S2 Old Generation Permanent Generation Bootstrap App Server http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pageId=2669 http://dow.ngra.de/2009/06/15/classloaderlocal-how-to-avoid-classloader-leaks-on-application-redeploy/ Wednesday, November 10, 2010
    • Demo Wednesday, November 10, 2010
    • Java 6 Collectors Parallel Parallel Young Serial New Scavenge Serial Old Concurrent Parallel Old (Mark Sweep Mark & Old Compact) Sweep http://www.petefreitag.com/articles/gctuning/ http://blogs.sun.com/jonthecollector/entry/our_collectors http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html Wednesday, November 10, 2010
    • Java 6 Collectors -XX:+UseSerialGC Parallel Parallel Young Serial New Scavenge Serial Old Concurrent Parallel Old (Mark Sweep Mark & Old Compact) Sweep http://www.petefreitag.com/articles/gctuning/ http://blogs.sun.com/jonthecollector/entry/our_collectors http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html Wednesday, November 10, 2010
    • Java 6 Collectors -XX:+UseParNewGC Parallel Parallel Young Serial New Scavenge Serial Old Concurrent Parallel Old (Mark Sweep Mark & Old Compact) Sweep http://www.petefreitag.com/articles/gctuning/ http://blogs.sun.com/jonthecollector/entry/our_collectors http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html Wednesday, November 10, 2010
    • Java 6 Collectors -XX:+UseParallelGC Parallel Parallel Young Serial New Scavenge Serial Old Concurrent Parallel Old (Mark Sweep Mark & Old Compact) Sweep http://www.petefreitag.com/articles/gctuning/ http://blogs.sun.com/jonthecollector/entry/our_collectors http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html Wednesday, November 10, 2010
    • Java 6 Collectors -XX:+UseConcMarkSweepGC Parallel Parallel Young Serial New Scavenge Serial Old Concurrent Parallel Old (Mark Sweep Mark & Old Compact) Sweep http://www.petefreitag.com/articles/gctuning/ http://blogs.sun.com/jonthecollector/entry/our_collectors http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html Wednesday, November 10, 2010
    • Java 6 Collectors -XX:+UseParallelOldGC Parallel Parallel Young Serial New Scavenge Serial Old Concurrent Parallel Old (Mark Sweep Mark & Old Compact) Sweep http://www.petefreitag.com/articles/gctuning/ http://blogs.sun.com/jonthecollector/entry/our_collectors http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html Wednesday, November 10, 2010
    • Java 6 Collectors Parallel Parallel Young Serial New Scavenge Serial Old Concurrent Parallel Old (Mark Sweep Mark & Old Compact) Sweep http://www.petefreitag.com/articles/gctuning/ http://blogs.sun.com/jonthecollector/entry/our_collectors http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html Wednesday, November 10, 2010
    • Java 6 Collectors Parallel Parallel Young Serial New Scavenge G1 Serial Old Concurrent Parallel Old (Mark Sweep Mark & Old Compact) Sweep http://www.petefreitag.com/articles/gctuning/ http://blogs.sun.com/jonthecollector/entry/our_collectors http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html Wednesday, November 10, 2010
    • G1 - Garbage First Heap http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
    • G1 - Garbage First http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
    • G1 - Garbage First Unused http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
    • G1 - Garbage First Unused Young http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
    • G1 - Garbage First Unused Young Old http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
    • G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
    • G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
    • Break Wednesday, November 10, 2010
    • HotSpot Optimizations Wednesday, November 10, 2010
    • HotSpot Optimizations Compiler Optimizations Runtime Optimizations Wednesday, November 10, 2010
    • Class File Format & Byte Code Wednesday, November 10, 2010
    • Class File Format & Byte Code Class File Layout & Parts Introduction to Byte Code Examples of Java Compiled to Byte Code Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool n Flags This Class Super Class pu te d tio ce iva te er ct ta ab tfp pr ec int ra fa ic um pr ic no Interfaces st bl ric ot al at en an fin st st Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf Wednesday, November 10, 2010
    • Field Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
    • Field Format Flags Name Descriptor pu te d lat nt iva te ile vo ie pr ec ic pr ic ns Attributes bl ot al at tra fin Wednesday, November 10, 2010 st
    • Field Format Flags Name Descriptor “name” Attributes Wednesday, November 10, 2010
    • Field Format Flags Name Descriptor “Ljava/lang/String;” Attributes Wednesday, November 10, 2010
    • Field Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
    • Field Format Flags Name Descriptor Attributes ConstantValue Wednesday, November 10, 2010
    • Method Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
    • Wednesday, November 10, 2010 Name Flags st Method Format ric tfp Attributes na tiv va e ra rg s Descriptor sy nc fin hr al on st ize at d pr ic ot pr ec iva te pu te d bl ic
    • Method Format Flags Name Descriptor “main” Attributes Wednesday, November 10, 2010
    • Method Format Flags Name Descriptor “([Ljava/lang/String;)V” Attributes Wednesday, November 10, 2010
    • Method Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
    • Method Format Flags Name Descriptor Attributes Exceptions Wednesday, November 10, 2010
    • Method Format Flags Name Descriptor Attributes Exceptions Code Wednesday, November 10, 2010
    • Browsing Class File Format JClassLib Viewer http://www.ej-technologies.com/products/jclasslib/overview.html JAD http://www.varaneckas.com/jad Wednesday, November 10, 2010
    • Byte Code Wednesday, November 10, 2010
    • Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 2 iadd 3 istore_0 4 iload_0 Wednesday, November 10, 2010
    • Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 2 iadd 3 istore_0 4 iload_0 1 Wednesday, November 10, 2010
    • Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 2 iadd 3 istore_0 4 iload_0 2 1 Wednesday, November 10, 2010
    • Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 2 iadd 3 istore_0 4 iload_0 1+2 Wednesday, November 10, 2010
    • Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 2 iadd 3 istore_0 4 iload_0 3 Wednesday, November 10, 2010
    • Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 3 2 iadd 3 istore_0 4 iload_0 Wednesday, November 10, 2010
    • Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 3 2 iadd 3 istore_0 4 iload_0 3 Wednesday, November 10, 2010
    • Demo Wednesday, November 10, 2010
    • Operation Types Load and Store Arithmetic and Logic Type Conversion Control Transfer Object Creation and Manipulation Operand Stack Method Invocation Wednesday, November 10, 2010
    • Data Types x refi als ns de P ray Loc ac ts By ture St tan Co k/ na te Sig Co Ar boolean Z Integer Types byte B b char C c short S s int I i long J l float F f double D d reference L a void V Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( int width, int depth, int height ) { int area = width * depth; int volume = area * height; return volume; } Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul { 3 istore_3 int area = width * depth; 4 iload_3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; 4 iload_3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn 1 Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 2 11ireturn 1 Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn 2 Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 2 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 2 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn 2 Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 2 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 3 11ireturn 2 Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 2 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn 6 Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 2 6 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 2 6 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn 6 Wednesday, November 10, 2010
    • Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul e t h lum igh h pt a dt { are 3 istore_3 de he wi vo 0 1 2 3 4 int area = width * depth; int volume = area * height; 4 iload_3 1 2 3 2 6 return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn Wednesday, November 10, 2010
    • Static vs Virtual Methods static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum h igh pt a dt { 3 istore_3 de he wi vo 0 1 2 3 4 5 int area = width * depth; 4 iload_3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11 ireturn Wednesday, November 10, 2010
    • Static vs Virtual Methods int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum h igh pt a dt { 3 istore_3 de he wi vo 0 1 2 3 4 5 int area = width * depth; 4 iload_3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11 ireturn Wednesday, November 10, 2010
    • Static vs Virtual Methods int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t he h lum h igh pt a dt s { 3 istore_3 de thi wi vo 0 1 2 3 4 5 int area = width * depth; 4 iload_3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11 ireturn Wednesday, November 10, 2010
    • Static vs Virtual Methods int volume( 0 iload_1 int width, 1 iload_2 int depth, 2 imul e int height ) are t he h lum h igh pt a dt s { 3 istore 4 de thi wi vo 0 1 2 3 4 5 int area = width * depth; 5 iload 4 int volume = area * height; return volume; 7 iload_3 } 8 imul 9 istore 5 11 iload 5 13 ireturn Wednesday, November 10, 2010
    • Hello World System.out.println( “Hello World” ); Wednesday, November 10, 2010
    • Hello World System.out.println( “Hello World” ); 0 getstatic System.out 3 ldc “Hello World” 5 invokevirtual PrintStream.println 8 return Wednesday, November 10, 2010
    • Hello World System.out.println( “Hello World” ); 0 1 2 3 0 getstatic System.out 3 ldc “Hello World” 5 invokevirtual PrintStream.println “Hello World” 8 return System.out Wednesday, November 10, 2010
    • Hello World System.out.println( “Hello World” ); 0 1 2 3 0 getstatic System.out 3 ldc “Hello World” 5 invokevirtual PrintStream.println “Hello World” 8 return System.out Wednesday, November 10, 2010
    • Hello World System.out.println( “Hello World” ); 0 1 2 3 0 getstatic System.out 3 ldc “Hello World” 5 invokevirtual PrintStream.println “Hello World” 8 return System.out Wednesday, November 10, 2010
    • Hello World g s ms thi System.out.println( “Hello World” ); 0 1 2 3 0 getstatic System.out 3 ldc “Hello World” 5 invokevirtual PrintStream.println “Hello World” 8 return System.out Wednesday, November 10, 2010
    • Types of Method Invocations invokestatic - invoke static methods invokevirtual - invoke instance method from class invokeinterface - invoke instance method from interface invokespecial - invoke <init> / invoke super method Wednesday, November 10, 2010
    • New Object return new BigDecimal(“2.0”); Wednesday, November 10, 2010
    • New Object return new BigDecimal(“2.0”); 0 new BigDecimal 3 dup 4 ldc “2.0” 6 invokespecial BigDecimal.<init> 9 areturn Wednesday, November 10, 2010
    • New Object return new BigDecimal(“2.0”); 0 1 2 3 0 new BigDecimal 3 dup 4 ldc “2.0” “2.0” 6 invokespecial BigDecimal.<init> 9 areturn Wednesday, November 10, 2010
    • New Object return new BigDecimal(“2.0”); 0 1 2 3 0 new BigDecimal 3 dup 4 ldc “2.0” “2.0” 6 invokespecial BigDecimal.<init> 9 areturn BigDecimal Wednesday, November 10, 2010
    • New Object return new BigDecimal(“2.0”); 0 1 2 3 0 new BigDecimal 3 dup 4 ldc “2.0” “2.0” 6 invokespecial BigDecimal.<init> 9 areturn BigDecimal Wednesday, November 10, 2010
    • New Object return new BigDecimal(“2.0”); 0 1 2 3 0 new BigDecimal 3 dup 4 ldc “2.0” “2.0” 6 invokespecial BigDecimal.<init> 9 areturn BigDecimal Wednesday, November 10, 2010
    • New Object return new BigDecimal(“2.0”); 0 1 2 3 0 new BigDecimal 3 dup 4 ldc “2.0” “2.0” 6 invokespecial BigDecimal.<init> 9 areturn BigDecimal Wednesday, November 10, 2010
    • Demo Wednesday, November 10, 2010
    • If / Else static boolean isPositive( int val ){ if ( val > 0 ) { return true; } else { return false; } } Wednesday, November 10, 2010
    • If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn Wednesday, November 10, 2010
    • If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn Wednesday, November 10, 2010
    • If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn Wednesday, November 10, 2010
    • If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn Wednesday, November 10, 2010
    • If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn static boolean isPositive( int val ){ return ( val > 0 ); } Wednesday, November 10, 2010
    • If / Else static boolean isPositive( int val ){ if ( val > 0 ) { return true; } else { return false; } } static boolean isPositive( int val ){ return ( val > 0 ); } Wednesday, November 10, 2010
    • If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn static boolean isPositive( int val ){ return ( val > 0 ); } Wednesday, November 10, 2010
    • For Loop static int sum( int min, int max ){ int sum = 0; for ( int i=min; i<max; ++i ){ sum += i; } return sum; } Wednesday, November 10, 2010
    • before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn Wednesday, November 10, 2010
    • before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn Wednesday, November 10, 2010
    • before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn Wednesday, November 10, 2010
    • before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn Wednesday, November 10, 2010
    • before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn Wednesday, November 10, 2010
    • before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn Wednesday, November 10, 2010
    • before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn Wednesday, November 10, 2010
    • Exception Handling static int read( InputStream in ) { try { return in.read(); } catch ( IOException e ) { return -1; } finally { IoUtils.closeQuietly( in ); } } Wednesday, November 10, 2010
    • 0 aload_0 Exception Handling 1 invokevirtual InputStream.read try / finally static int read( InputStream in ) { 4 istore_1 try { 5 aload_0 return in.read(); 6 invokestatic IoUtils.closeQuietly } catch ( IOException e ) { 9 iload_1 return -1; 10 ireturn } finally { 11 pop IoUtils.closeQuietly( in ); catch / finally } 12 aload_0 } 13 invokestatic IoUtils.closeQuietly 16 iconst_m1 17 ireturn 18 astore_2 19 aload_0 finally 20 invokestatic IoUtils.closeQuietly 23 aload_2 24 athrow Wednesday, November 10, 2010
    • 0 aload_0 Exception Handling 1 invokevirtual InputStream.read try / finally static int read( InputStream in ) { 4 istore_1 try { 5 aload_0 return in.read(); 6 invokestatic IoUtils.closeQuietly } catch ( IOException e ) { 9 iload_1 return -1; 10 ireturn } finally { 11 pop IoUtils.closeQuietly( in ); catch / finally } 12 aload_0 } 13 invokestatic IoUtils.closeQuietly 16 iconst_m1 17 ireturn 18 astore_2 19 aload_0 finally 20 invokestatic IoUtils.closeQuietly 23 aload_2 24 athrow Wednesday, November 10, 2010
    • 0 aload_0 Exception Handling 1 invokevirtual InputStream.read try / finally static int read( InputStream in ) { 4 istore_1 try { 5 aload_0 return in.read(); 6 invokestatic IoUtils.closeQuietly } catch ( IOException e ) { 9 iload_1 return -1; 10 ireturn } finally { 11 pop IoUtils.closeQuietly( in ); catch / finally } 12 aload_0 } 13 invokestatic IoUtils.closeQuietly 16 iconst_m1 17 ireturn Exception Table 18 astore_2 start end handler Exception 19 aload_0 0 5 11 IOException finally 20 invokestatic IoUtils.closeQuietly 0 5 18 any 23 aload_2 11 12 18 any 24 athrow Wednesday, November 10, 2010
    • 0 aload_0 Exception Handling 1 invokevirtual InputStream.read try / finally static int read( InputStream in ) { 4 istore_1 try { 5 aload_0 return in.read(); 6 invokestatic IoUtils.closeQuietly } catch ( IOException e ) { 9 iload_1 return -1; 10 ireturn } finally { 11 pop IoUtils.closeQuietly( in ); catch / finally } 12 aload_0 } 13 invokestatic IoUtils.closeQuietly 16 iconst_m1 17 ireturn Exception Table 18 astore_2 start end handler Exception 19 aload_0 0 5 11 IOException finally 20 invokestatic IoUtils.closeQuietly 0 5 18 any 23 aload_2 11 12 18 any 24 athrow Wednesday, November 10, 2010
    • Optimizations Wednesday, November 10, 2010
    • Optimizations Execution Lifecycle Just In Time Compilation Purely Interpreted Ahead of Time Compilation Most Optimizations are Runtime Wednesday, November 10, 2010
    • HotSpot Lifecycle 1 2 Interpreted Profiling Dynamic Dynamic Decompilation Compilation 4 3 http://java.sun.com/products/hotspot/whitepaper.html http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html http://www.azulsystems.com/blog/cliff-click/2010-07-16-tiered-compilation http://www.slideshare.net/drorbr/so-you-want-to-write-your-own-benchmark-presentation Wednesday, November 10, 2010
    • Is This Optimized? double sumU = 0, sumV = 0; for ( int i = 0; i < 100; ++i ) { Vector2D vector = new Vector2D( i, i ); synchronized ( vector ) { sumU += vector.getU(); sumV += vector.getV(); } } Wednesday, November 10, 2010
    • Is This Optimized? double sumU = 0, sumV = 0; for ( int i = 0; i < 100; ++i ) { Vector2D vector = new Vector2D( i, i ); synchronized ( vector ) { sumU += vector.getU(); How many...? sumV += vector.getV(); Loop Iterations } Heap Allocations } Method Invocations Lock Acquisitions Wednesday, November 10, 2010
    • Is This Optimized? double sumU = 0, sumV = 0; for ( int i = 0; i < 100; ++i ) { Vector2D vector = new Vector2D( i, i ); synchronized ( vector ) { sumU += vector.getU(); How many...? sumV += vector.getV(); Loop Iterations 100 } Heap Allocations 100 } Method Invocations 200 Lock Acquisitions 100 Wednesday, November 10, 2010
    • Is This Optimized? double sumU = 0, sumV = 0; for ( int i = 0; i < 100; ++i ) { Vector2D vector = new Vector2D( i, i ); synchronized ( vector ) { sumU += vector.getU(); How many...? sumV += vector.getV(); Loop Iterations 0 } Heap Allocations 0 } Method Invocations 0 Lock Acquisitions 0 Wednesday, November 10, 2010
    • Common Sub-Expression Elimination int x = a + b; int y = a + b; http://www.slideshare.net/drorbr/so-you-want-to-write-your-own-benchmark-presentation Wednesday, November 10, 2010
    • Common Sub-Expression Elimination int x = a + b; int y = a + b; int tmp = a + b; int x = tmp; int y = tmp; http://www.slideshare.net/drorbr/so-you-want-to-write-your-own-benchmark-presentation Wednesday, November 10, 2010
    • Array Bounds Check Elimination int[] nums = ... for ( int i = 0; i < nums.length; ++i ) { System.out.println( “nums[“ + i + “]=” + nums[ i ] ); } http://www.cs.umd.edu/~vibha/330/array-bounds.pdf Wednesday, November 10, 2010
    • Array Bounds Check Elimination int[] nums = ... for ( int i = 0; i < nums.length; ++i ) { System.out.println( “nums[“ + i + “]=” + nums[ i ] ); } int[] nums = ... for ( int i = 0; i < nums.length; ++i ) { if ( i < 0 || i >= nums.length ) { throw new ArrayIndexOutOfBoundsException(); } System.out.println( “nums[“ + i + “]=” + nums[ i ] ); } http://www.cs.umd.edu/~vibha/330/array-bounds.pdf Wednesday, November 10, 2010
    • Loop Invariant Hoisting for ( int i = 0; i < nums.length; ++i ) { ... } http://java.sun.com/products/hotspot/docs/whitepaper/Java_Hotspot_v1.4.1/Java_HSpot_WP_v1.4.1_1002_4.html Wednesday, November 10, 2010
    • Loop Invariant Hoisting for ( int i = 0; i < nums.length; ++i ) { ... } int length = nums.length; for ( int i = 0; i < length; ++i ) { ... } http://java.sun.com/products/hotspot/docs/whitepaper/Java_Hotspot_v1.4.1/Java_HSpot_WP_v1.4.1_1002_4.html Wednesday, November 10, 2010
    • Loop Unrolling int sum = 0; for ( int i = 0; i < 10; ++i ) { sum += i; } Wednesday, November 10, 2010
    • Loop Unrolling int sum = 0; for ( int i = 0; i < 10; ++i ) { sum += i; } int sum = 0; sum += 1; ... sum += 9; Wednesday, November 10, 2010
    • Method Inlining Vector vector = ... double magnitude = vector.magnitude(); http://www.ibm.com/developerworks/library/j-jtp12214/ http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html http://java.sun.com/developer/technicalArticles/Networking/HotSpot/inlining.html Wednesday, November 10, 2010
    • Method Inlining Vector vector = ... double magnitude = vector.magnitude(); Vector vector = ... double magnitude = Math.sqrt( vector.u*vector.u + vector.v*vector.v ); http://www.ibm.com/developerworks/library/j-jtp12214/ http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html http://java.sun.com/developer/technicalArticles/Networking/HotSpot/inlining.html Wednesday, November 10, 2010
    • Method Inlining Vector vector = ... double magnitude = vector.magnitude(); Vector vector = ... double magnitude = Math.sqrt( vector.u*vector.u + vector.v*vector.v ); Vector vector = ... double magnitude; if ( vector instance of Vector2D ) { magnitude = Math.sqrt( vector.u*vector.u + vector.v*vector.v ); } else { magnitude = vector.magnitude(); } http://www.ibm.com/developerworks/library/j-jtp12214/ http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html http://java.sun.com/developer/technicalArticles/Networking/HotSpot/inlining.html Wednesday, November 10, 2010
    • Method Inlining Vector vector = ... double magnitude = vector.magnitude(); Vector vector = ... static always double magnitude = Math.sqrt( final always vector.u*vector.u + vector.v*vector.v ); private always Vector vector = ... virtual often double magnitude; reflective sometimes if ( vector instance of Vector2D ) { magnitude = Math.sqrt( dynamic often vector.u*vector.u + vector.v*vector.v ); } else { magnitude = vector.magnitude(); } http://www.ibm.com/developerworks/library/j-jtp12214/ http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html http://java.sun.com/developer/technicalArticles/Networking/HotSpot/inlining.html Wednesday, November 10, 2010
    • Lock Coarsening StringBuffer buffer = ... buffer.append( “Hello” ); buffer.append( name ); buffer.append( “n” ); http://java.sun.com/performance/reference/whitepapers/6_performance.html#2.1 Wednesday, November 10, 2010
    • Lock Coarsening StringBuffer buffer = ... buffer.append( “Hello” ); buffer.append( name ); buffer.append( “n” ); StringBuffer buffer = ... lock( buffer ); buffer.append( “Hello” ); unlock( buffer ); lock( buffer ); buffer.append( name ); unlock( buffer ); lock( buffer ); buffer.append( “n” ); unlock( buffer ); http://java.sun.com/performance/reference/whitepapers/6_performance.html#2.1 Wednesday, November 10, 2010
    • Lock Coarsening StringBuffer buffer = ... buffer.append( “Hello” ); buffer.append( name ); buffer.append( “n” ); StringBuffer buffer = ... lock( buffer ); buffer.append( “Hello” ); unlock( buffer ); lock( buffer ); buffer.append( name ); unlock( buffer ); lock( buffer ); buffer.append( “n” ); unlock( buffer ); StringBuffer buffer = ... lock( buffer ); buffer.append( “Hello” ); buffer.append( name ); buffer.append( “n” ); unlock( buffer ); http://java.sun.com/performance/reference/whitepapers/6_performance.html#2.1 Wednesday, November 10, 2010
    • Other Lock Optimizations Biased Locking Adaptive Locking - Thread sleep vs. Spin lock http://java.sun.com/performance/reference/whitepapers/6_performance.html#2.1 Wednesday, November 10, 2010
    • Escape Analysis Point p1 = new Point( x1, y1 ), p2 = new Point( x2, y2 ); synchronized ( p1 ) { synchronized ( p2 ) { double dx = p1.getX() - p2.getX(); double dy = p1.getY() - p2.getY(); double distance = Math.sqrt( dx*dx + dy*dy ); } } Wednesday, November 10, 2010
    • Escape Analysis Point p1 = new Point( x1, y1 ), p2 = new Point( x2, y2 ); double dx = p1.getX() - p2.getX(); double dy = p1.getY() - p2.getY(); double distance = Math.sqrt( dx*dx + dy*dy ); Wednesday, November 10, 2010
    • Escape Analysis Point p1 = new Point( x1, y1 ), p2 = new Point( x2, y2 ); double dx = p1.getX() - p2.getX(); double dy = p1.getY() - p2.getY(); double distance = Math.sqrt( dx*dx + dy*dy ); double dx = x1 - x2; double dx = y1 - y2; double distance = Math.sqrt( dx*dx + dy*dy ); Wednesday, November 10, 2010
    • Run Time Demo Wednesday, November 10, 2010
    • Is This Optimized? double sumU = 0, sumV = 0; for ( int i = 0; i < 100; ++i ) { Vector2D vector = new Vector2D( i, i ); synchronized ( vector ) { sumU += vector.getU(); sumV += vector.getV(); } } Wednesday, November 10, 2010
    • Is This Optimized? double sumU = 0, sumV = 0; for ( int i = 0; i < 100; ++i ) { Vector2D vector = new Vector2D( i, i ); synchronized ( vector ) { sumU += vector.getU(); How many...? sumV += vector.getV(); Loop Iterations 0 } Heap Allocations 0 } Method Invocations 0 Lock Acquisitions 0 Wednesday, November 10, 2010