SlideShare ist ein Scribd-Unternehmen logo
1 von 222
Downloaden Sie, um offline zu lesen
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
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010
JVM Internals - NEJUG Nov 2010

Weitere ähnliche Inhalte

Andere mochten auch

Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint Petersburg
Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint PetersburgUnsafe Java World - Crossing the Borderline - JokerConf 2014 Saint Petersburg
Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint PetersburgChristoph Engelbert
 
Distributed computing with Hazelcast - JavaOne 2014
Distributed computing with Hazelcast - JavaOne 2014Distributed computing with Hazelcast - JavaOne 2014
Distributed computing with Hazelcast - JavaOne 2014Christoph Engelbert
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
A Post-Apocalyptic sun.misc.Unsafe World
A Post-Apocalyptic sun.misc.Unsafe WorldA Post-Apocalyptic sun.misc.Unsafe World
A Post-Apocalyptic sun.misc.Unsafe WorldChristoph Engelbert
 
Understanding Garbage Collection
Understanding Garbage CollectionUnderstanding Garbage Collection
Understanding Garbage CollectionDoug Hawkins
 
In-Memory Computing - Distributed Systems - Devoxx UK 2015
In-Memory Computing - Distributed Systems - Devoxx UK 2015In-Memory Computing - Distributed Systems - Devoxx UK 2015
In-Memory Computing - Distributed Systems - Devoxx UK 2015Christoph Engelbert
 

Andere mochten auch (7)

Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint Petersburg
Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint PetersburgUnsafe Java World - Crossing the Borderline - JokerConf 2014 Saint Petersburg
Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint Petersburg
 
Distributed computing with Hazelcast - JavaOne 2014
Distributed computing with Hazelcast - JavaOne 2014Distributed computing with Hazelcast - JavaOne 2014
Distributed computing with Hazelcast - JavaOne 2014
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
A Post-Apocalyptic sun.misc.Unsafe World
A Post-Apocalyptic sun.misc.Unsafe WorldA Post-Apocalyptic sun.misc.Unsafe World
A Post-Apocalyptic sun.misc.Unsafe World
 
Understanding Garbage Collection
Understanding Garbage CollectionUnderstanding Garbage Collection
Understanding Garbage Collection
 
In-Memory Computing - Distributed Systems - Devoxx UK 2015
In-Memory Computing - Distributed Systems - Devoxx UK 2015In-Memory Computing - Distributed Systems - Devoxx UK 2015
In-Memory Computing - Distributed Systems - Devoxx UK 2015
 
Hazelcast - In-Memory DataGrid
Hazelcast - In-Memory DataGridHazelcast - In-Memory DataGrid
Hazelcast - In-Memory DataGrid
 

Mehr von Doug Hawkins

JVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksJVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksDoug Hawkins
 
ReadyNow: Azul's Unconventional "AOT"
ReadyNow: Azul's Unconventional "AOT"ReadyNow: Azul's Unconventional "AOT"
ReadyNow: Azul's Unconventional "AOT"Doug Hawkins
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance PuzzlersDoug Hawkins
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in JavaDoug Hawkins
 
JVM Internals - NHJUG Jan 2012
JVM Internals - NHJUG Jan 2012JVM Internals - NHJUG Jan 2012
JVM Internals - NHJUG Jan 2012Doug Hawkins
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Doug Hawkins
 
JVM Internals - Garbage Collection & Runtime Optimizations
JVM Internals - Garbage Collection & Runtime OptimizationsJVM Internals - Garbage Collection & Runtime Optimizations
JVM Internals - Garbage Collection & Runtime OptimizationsDoug Hawkins
 

Mehr von Doug Hawkins (8)

JVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksJVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's Tricks
 
ReadyNow: Azul's Unconventional "AOT"
ReadyNow: Azul's Unconventional "AOT"ReadyNow: Azul's Unconventional "AOT"
ReadyNow: Azul's Unconventional "AOT"
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance Puzzlers
 
JVM Mechanics
JVM MechanicsJVM Mechanics
JVM Mechanics
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in Java
 
JVM Internals - NHJUG Jan 2012
JVM Internals - NHJUG Jan 2012JVM Internals - NHJUG Jan 2012
JVM Internals - NHJUG Jan 2012
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011
 
JVM Internals - Garbage Collection & Runtime Optimizations
JVM Internals - Garbage Collection & Runtime OptimizationsJVM Internals - Garbage Collection & Runtime Optimizations
JVM Internals - Garbage Collection & Runtime Optimizations
 

Kürzlich hochgeladen

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Kürzlich hochgeladen (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 

JVM Internals - NEJUG Nov 2010

  • 1. JVM Internals Douglas Q. Hawkins - dougqh@gmail.com http://www.dougqh.net/ Wednesday, November 10, 2010
  • 2. JVM Internals Douglas Q. Hawkins - dougqh@gmail.com http://www.dougqh.net/ http://www.meetup.com/boston-java Wednesday, November 10, 2010
  • 3. 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
  • 5. Garbage Collection Current HotSpot Collectors Demos Garbage First (G1) Collector Wednesday, November 10, 2010
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. 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
  • 11. 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
  • 12. 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
  • 13. 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
  • 14. 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
  • 15. 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
  • 16. 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
  • 17. 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
  • 18. 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
  • 19. 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
  • 20. 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
  • 21. 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
  • 22. 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
  • 23. 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
  • 24. 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
  • 25. 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
  • 26. 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
  • 27. 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
  • 28. 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
  • 29. 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
  • 30. 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
  • 31. 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
  • 32. 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
  • 33. 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
  • 34. 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
  • 35. 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
  • 36. 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
  • 37. 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
  • 38. Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
  • 39. Stop the World! Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
  • 40. Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
  • 41. Serial Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
  • 42. Serial Parallel Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
  • 44. 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
  • 45. 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
  • 46. 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
  • 47. 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
  • 48. 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
  • 49. 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
  • 50. 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
  • 51. 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
  • 52. 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
  • 53. 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
  • 54. 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
  • 55. 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
  • 56. 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
  • 57. 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
  • 58. 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
  • 60. 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
  • 61. 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
  • 62. 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
  • 63. 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
  • 64. 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
  • 65. 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
  • 66. 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
  • 68. 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
  • 69. 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
  • 70. 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
  • 71. 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
  • 72. 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
  • 73. 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
  • 74. 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
  • 75. 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
  • 76. G1 - Garbage First Heap http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
  • 77. G1 - Garbage First http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
  • 78. G1 - Garbage First Unused http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
  • 79. G1 - Garbage First Unused Young http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
  • 80. G1 - Garbage First Unused Young Old http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
  • 81. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  • 82. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  • 83. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  • 84. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  • 85. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  • 86. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  • 87. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  • 88. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  • 89. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  • 90. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  • 91. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  • 92. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  • 93. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  • 94. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  • 95. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  • 96. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  • 97. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  • 98. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  • 101. HotSpot Optimizations Compiler Optimizations Runtime Optimizations Wednesday, November 10, 2010
  • 102. Class File Format & Byte Code Wednesday, November 10, 2010
  • 103. Class File Format & Byte Code Class File Layout & Parts Introduction to Byte Code Examples of Java Compiled to Byte Code Wednesday, November 10, 2010
  • 104. 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
  • 105. 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
  • 106. 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
  • 107. 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
  • 108. 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
  • 109. 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
  • 110. 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
  • 111. 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
  • 112. 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
  • 113. 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
  • 114. 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
  • 115. Field Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
  • 116. 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
  • 117. Field Format Flags Name Descriptor “name” Attributes Wednesday, November 10, 2010
  • 118. Field Format Flags Name Descriptor “Ljava/lang/String;” Attributes Wednesday, November 10, 2010
  • 119. Field Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
  • 120. Field Format Flags Name Descriptor Attributes ConstantValue Wednesday, November 10, 2010
  • 121. Method Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
  • 122. 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
  • 123. Method Format Flags Name Descriptor “main” Attributes Wednesday, November 10, 2010
  • 124. Method Format Flags Name Descriptor “([Ljava/lang/String;)V” Attributes Wednesday, November 10, 2010
  • 125. Method Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
  • 126. Method Format Flags Name Descriptor Attributes Exceptions Wednesday, November 10, 2010
  • 127. Method Format Flags Name Descriptor Attributes Exceptions Code Wednesday, November 10, 2010
  • 128. 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
  • 130. 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
  • 131. 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
  • 132. 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
  • 133. 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
  • 134. 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
  • 135. 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
  • 136. 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
  • 138. Operation Types Load and Store Arithmetic and Logic Type Conversion Control Transfer Object Creation and Manipulation Operand Stack Method Invocation Wednesday, November 10, 2010
  • 139. 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
  • 140. 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
  • 141. 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
  • 142. 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
  • 143. 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
  • 144. 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
  • 145. 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
  • 146. 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
  • 147. 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
  • 148. 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
  • 149. 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
  • 150. 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
  • 151. 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
  • 152. 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
  • 153. 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
  • 154. 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
  • 155. 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
  • 156. 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
  • 157. 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
  • 158. Hello World System.out.println( “Hello World” ); Wednesday, November 10, 2010
  • 159. 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
  • 160. 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
  • 161. 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
  • 162. 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
  • 163. 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
  • 164. 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
  • 165. New Object return new BigDecimal(“2.0”); Wednesday, November 10, 2010
  • 166. 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
  • 167. 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
  • 168. 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
  • 169. 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
  • 170. 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
  • 171. 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
  • 173. If / Else static boolean isPositive( int val ){ if ( val > 0 ) { return true; } else { return false; } } Wednesday, November 10, 2010
  • 174. 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
  • 175. 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
  • 176. 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
  • 177. 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
  • 178. 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
  • 179. 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
  • 180. 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
  • 181. 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
  • 182. 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
  • 183. 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
  • 184. 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
  • 185. 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
  • 186. 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
  • 187. 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
  • 188. 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
  • 189. Exception Handling static int read( InputStream in ) { try { return in.read(); } catch ( IOException e ) { return -1; } finally { IoUtils.closeQuietly( in ); } } Wednesday, November 10, 2010