0
JVM Internals
         Douglas Q. Hawkins - dougqh@gmail.com
              http://www.dougqh.net/




Wednesday, November ...
JVM Internals
         Douglas Q. Hawkins - dougqh@gmail.com
              http://www.dougqh.net/
                        ...
JVM Internals
              HotSpot Garbage Collector
              HotSpot Optimizations
                   Class File Fo...
Garbage Collection




Wednesday, November 10, 2010
Garbage Collection
                     Current HotSpot Collectors
                     Demos
                     Garbage...
Generational Hypothesis
              Generational Hypothesis
                   92 to 98% objects die young
             ...
HotSpot Garbage Collector




                                               Heap


http://download.oracle.com/javase/1.5....
HotSpot Garbage Collector
         Young Generation




         Old Generation




http://download.oracle.com/javase/1.5....
HotSpot Garbage Collector
         Young Generation
  Eden

        S1                                          S2

      ...
Object Allocation
         Young Generation
  Eden

        S1                                               S2

         ...
Object Allocation
         Young Generation
  Eden

        S1                                               S2

         ...
Object Allocation
         Young Generation
  Eden

        S1                                               S2

         ...
Object Allocation
         Young Generation
  Eden

        S1                                               S2

         ...
Object Allocation
         Young Generation
  Eden

        S1                                               S2

         ...
Object Allocation
         Young Generation
  Eden

        S1                                               S2

         ...
Object Allocation
         Young Generation
  Eden

        S1                                               S2

         ...
Object Allocation
         Young Generation
  Eden

        S1                                               S2

         ...
Object Allocation
                                                      TLAB
         Young Generation
  Eden

        S1 ...
Object Allocation
                                                      TLAB
         Young Generation
  Eden

        S1 ...
Object Allocation
                                                      TLAB
         Young Generation
  Eden

        S1 ...
Object Allocation
                                                      TLAB
         Young Generation
  Eden

        S1 ...
Object Allocation
                                                      TLAB
         Young Generation
  Eden

        S1 ...
Object Allocation
                                                      TLAB
         Young Generation
  Eden

        S1 ...
Object Allocation
                                                      TLAB
         Young Generation
  Eden

        S1 ...
Object Allocation
                                                      TLAB
         Young Generation
  Eden

        S1 ...
Object Allocation
                                                      TLAB
         Young Generation
  Eden

        S1 ...
Minor Collection
                                                   TLAB
         Young Generation
  Eden

        S1     ...
Minor Collection
                                                   TLAB
         Young Generation
  Eden

        S1     ...
Minor Collection
                                                   TLAB
         Young Generation
  Eden

        S1     ...
Minor Collection
         Young Generation
  Eden

        S1                                           S2

         Old G...
Minor Collection
         Young Generation
  Eden

        S1                                           S2

         Old G...
Minor Collection
         Young Generation
  Eden

        S1                                           S2

         Old G...
Minor Collection
         Young Generation
  Eden

        S1                                           S2

         Old G...
Minor Collection
         Young Generation
  Eden

        S1                                           S2

         Old G...
Minor Collection
         Young Generation
  Eden

        S1                                           S2

         Old G...
Minor Collection
         Young Generation
  Eden

        S1                                           S2

         Old G...
Minor Collection
         Young Generation
  Eden

        S1                                           S2

         Old G...
Application Thread                         GC Thread
 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf
We...
Stop the World!




                          Application Thread                           GC Thread
 http://www.austinjug...
Application Thread                         GC Thread
 http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf
We...
Serial




                          Application Thread                         GC Thread
 http://www.austinjug.org/presen...
Serial                                Parallel




                          Application Thread                         GC...
Demo




Wednesday, November 10, 2010
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Major Collection
         Young Generation
  Eden

        S1                                          S2

         Old Ge...
Serial Mark                               Parallel Mark
                   Sweep & Compact                            Swee...
Serial Mark                                                       Parallel Mark
     Sweep & Compact                      ...
Serial Mark                                                       Parallel Mark
     Sweep & Compact                      ...
Serial Mark                                                       Parallel Mark
     Sweep & Compact                      ...
Demo




Wednesday, November 10, 2010
Permanent Generation
    Young Generation
  Eden

         S1                                            S2
         Old G...
Permanent Generation
    Young Generation
  Eden

         S1                                            S2
         Old G...
Permanent Generation
    Young Generation
  Eden

         S1                                            S2
         Old G...
Permanent Generation
    Young Generation
  Eden

         S1                                            S2
         Old G...
Permanent Generation
    Young Generation
  Eden

         S1                                            S2
         Old G...
Permanent Generation
    Young Generation
  Eden

         S1                                            S2
         Old G...
Permanent Generation
    Young Generation
  Eden

         S1                                            S2
         Old G...
Demo




Wednesday, November 10, 2010
Java 6 Collectors


                                                    Parallel        Parallel
 Young                   ...
Java 6 Collectors
                -XX:+UseSerialGC


                                                    Parallel        P...
Java 6 Collectors
                                        -XX:+UseParNewGC


                                             ...
Java 6 Collectors
                                                                   -XX:+UseParallelGC


                ...
Java 6 Collectors
                                 -XX:+UseConcMarkSweepGC


                                             ...
Java 6 Collectors
                                                              -XX:+UseParallelOldGC


                  ...
Java 6 Collectors


                                                    Parallel        Parallel
 Young                   ...
Java 6 Collectors


                                                    Parallel        Parallel
 Young                   ...
G1 - Garbage First



                                            Heap



http://developers.sun.com/learning/javaoneonline...
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-...
G1 - Garbage First




                               Unused         Young
http://developers.sun.com/learning/javaoneonlin...
G1 - Garbage First




                               Unused         Young                     Old
http://developers.sun.c...
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...
Class File Format & Byte Code




Wednesday, November 10, 2010
Class File Format & Byte Code
                     Class File Layout & Parts
                     Introduction to Byte Cod...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Class File Format
               CA              FE   BA        BE        Minor Version Major Version


                  ...
Field Format
                   Flags       Name        Descriptor
                                   Attributes




Wedne...
Field Format
                   Flags       Name        Descriptor




                                              pu te...
Field Format
                   Flags       Name        Descriptor
                                        “name”
        ...
Field Format
                   Flags       Name        Descriptor   “Ljava/lang/String;”
                                ...
Field Format
                   Flags       Name        Descriptor
                                   Attributes




Wedne...
Field Format
                   Flags       Name        Descriptor
                                   Attributes

        ...
Method Format
                   Flags       Name        Descriptor
                                   Attributes




Wedn...
Wednesday, November 10, 2010
                               Name        Flags




                               st
      ...
Method Format
                   Flags       Name        Descriptor
                                         “main”
      ...
Method Format
                   Flags       Name        Descriptor   “([Ljava/lang/String;)V”
                           ...
Method Format
                   Flags       Name        Descriptor
                                   Attributes




Wedn...
Method Format
                   Flags       Name        Descriptor
                                   Attributes

       ...
Method Format
                   Flags       Name        Descriptor
                                   Attributes

       ...
Browsing Class File Format




          JClassLib Viewer http://www.ej-technologies.com/products/jclasslib/overview.html
...
Byte Code




Wednesday, November 10, 2010
Stack Based Virtual Machine
           0 iconst_1
                               0   1   2   3
           1 iconst_2
     ...
Stack Based Virtual Machine
           0 iconst_1
                                   0   1   2   3
           1 iconst_2
 ...
Stack Based Virtual Machine
           0 iconst_1
                                   0   1   2   3
           1 iconst_2
 ...
Stack Based Virtual Machine
           0 iconst_1
                                     0   1   2   3
           1 iconst_2...
Stack Based Virtual Machine
           0 iconst_1
                                   0   1   2   3
           1 iconst_2
 ...
Stack Based Virtual Machine
           0 iconst_1
                               0       1   2   3
           1 iconst_2  ...
Stack Based Virtual Machine
           0 iconst_1
                                   0       1   2   3
           1 iconst...
Demo




Wednesday, November 10, 2010
Operation Types
              Load and Store
              Arithmetic and Logic
              Type Conversion
            ...
Data Types




                                                                               x
                          ...
Parameters and Local Variables
static int volume(
  int width,
  int depth,
  int height )
{
  int area = width * depth;
 ...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Parameters and Local Variables
static int volume(               0 iload_0
  int width,                     1 iload_1
  int...
Static vs Virtual Methods
 static int volume(              0 iload_0
  int width,                     1 iload_1
  int dept...
Static vs Virtual Methods
 int volume(                     0 iload_0
  int width,                     1 iload_1
  int dept...
Static vs Virtual Methods
 int volume(                     0 iload_0
  int width,                     1 iload_1
  int dept...
Static vs Virtual Methods
 int volume(                     0 iload_1
  int width,                     1 iload_2
  int dept...
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
        System.out.println( “Hello World” );
                                               0   1       2    3...
Hello World
        System.out.println( “Hello World” );
                                               0   1       2    3...
Hello World
        System.out.println( “Hello World” );
                                               0   1       2    3...
Hello World




                                                              g
                                          ...
Types of Method Invocations
            invokestatic - invoke static methods
            invokevirtual - invoke instance m...
New Object
             return new BigDecimal(“2.0”);




Wednesday, November 10, 2010
New Object
             return new BigDecimal(“2.0”);

        0 new                  BigDecimal

        3 dup

        4...
New Object
             return new BigDecimal(“2.0”);
                                                     0   1    2     ...
New Object
             return new BigDecimal(“2.0”);
                                                     0   1       2  ...
New Object
             return new BigDecimal(“2.0”);
                                                     0   1       2  ...
New Object
             return new BigDecimal(“2.0”);
                                                     0   1       2  ...
New Object
             return new BigDecimal(“2.0”);
                                                     0   1       2  ...
Demo




Wednesday, November 10, 2010
If / Else
  static boolean isPositive( int val ){
    if ( val > 0 ) {
      return true;
    } else {
      return false;...
If / Else
  static boolean isPositive( int val ){          0 iload_0




                                          test
  ...
If / Else
  static boolean isPositive( int val ){          0 iload_0




                                          test
  ...
If / Else
  static boolean isPositive( int val ){          0 iload_0




                                          test
  ...
If / Else
  static boolean isPositive( int val ){          0 iload_0




                                          test
  ...
If / Else
  static boolean isPositive( int val ){          0 iload_0




                                          test
  ...
If / Else
  static boolean isPositive( int val ){
    if ( val > 0 ) {
      return true;
    } else {
      return false;...
If / Else
  static boolean isPositive( int val ){          0 iload_0




                                          test
  ...
For Loop
  static int sum( int min, int max ){
    int sum = 0;
    for ( int i=min; i<max; ++i ){
      sum += i;
    }
 ...
before
                                                              0 iconst_0
        For Loop




                     ...
before
                                                              0 iconst_0
        For Loop




                     ...
before
                                                              0 iconst_0
        For Loop




                     ...
before
                                                              0 iconst_0
        For Loop




                     ...
before
                                                              0 iconst_0
        For Loop




                     ...
before
                                                              0 iconst_0
        For Loop




                     ...
before
                                                              0 iconst_0
        For Loop




                     ...
Exception Handling
  static int read( InputStream in ) {
    try {
      return in.read();
    } catch ( IOException e ) {...
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
Upcoming SlideShare
Loading in...5
×

JVM Internals - NEJUG Nov 2010

4,698

Published on

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

Published in: Technology, Sports
3 Comments
19 Likes
Statistics
Notes
  • perfact article.but i can't download it,can you send me a copy?
    xilinniao@gmail.com thanks!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • really it is a good presentation, can you provide a presentation on embedded java pls...
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Doug - very excellent presentations and talk; decompile demos very helpful. Thanks!! A+

    Dan@Lexikos.com
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
4,698
On Slideshare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
880
Comments
3
Likes
19
Embeds 0
No embeds

No notes for slide

Transcript of "JVM Internals - NEJUG Nov 2010"

  1. 1. JVM Internals Douglas Q. Hawkins - dougqh@gmail.com http://www.dougqh.net/ Wednesday, November 10, 2010
  2. 2. JVM Internals Douglas Q. Hawkins - dougqh@gmail.com http://www.dougqh.net/ http://www.meetup.com/boston-java Wednesday, November 10, 2010
  3. 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
  4. 4. Garbage Collection Wednesday, November 10, 2010
  5. 5. Garbage Collection Current HotSpot Collectors Demos Garbage First (G1) Collector Wednesday, November 10, 2010
  6. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 38. Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
  39. 39. Stop the World! Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
  40. 40. Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
  41. 41. Serial Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
  42. 42. Serial Parallel Application Thread GC Thread http://www.austinjug.org/presentations/JDK6PerfUpdate_Dec2009.pdf Wednesday, November 10, 2010
  43. 43. Demo Wednesday, November 10, 2010
  44. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  59. 59. Demo Wednesday, November 10, 2010
  60. 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. 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. 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. 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. 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. 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. 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
  67. 67. Demo Wednesday, November 10, 2010
  68. 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. 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. 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. 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. 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. 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. 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. 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. 76. G1 - Garbage First Heap http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
  77. 77. G1 - Garbage First http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
  78. 78. G1 - Garbage First Unused http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
  79. 79. G1 - Garbage First Unused Young http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
  80. 80. G1 - Garbage First Unused Young Old http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5419.pdf Wednesday, November 10, 2010
  81. 81. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  82. 82. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  83. 83. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  84. 84. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  85. 85. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  86. 86. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  87. 87. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  88. 88. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  89. 89. G1 - Minor Collection Unused Young Old Wednesday, November 10, 2010
  90. 90. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  91. 91. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  92. 92. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  93. 93. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  94. 94. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  95. 95. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  96. 96. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  97. 97. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  98. 98. G1 - Major Collection Unused Young Old Wednesday, November 10, 2010
  99. 99. Break Wednesday, November 10, 2010
  100. 100. HotSpot Optimizations Wednesday, November 10, 2010
  101. 101. HotSpot Optimizations Compiler Optimizations Runtime Optimizations Wednesday, November 10, 2010
  102. 102. Class File Format & Byte Code Wednesday, November 10, 2010
  103. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 115. Field Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
  116. 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. 117. Field Format Flags Name Descriptor “name” Attributes Wednesday, November 10, 2010
  118. 118. Field Format Flags Name Descriptor “Ljava/lang/String;” Attributes Wednesday, November 10, 2010
  119. 119. Field Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
  120. 120. Field Format Flags Name Descriptor Attributes ConstantValue Wednesday, November 10, 2010
  121. 121. Method Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
  122. 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. 123. Method Format Flags Name Descriptor “main” Attributes Wednesday, November 10, 2010
  124. 124. Method Format Flags Name Descriptor “([Ljava/lang/String;)V” Attributes Wednesday, November 10, 2010
  125. 125. Method Format Flags Name Descriptor Attributes Wednesday, November 10, 2010
  126. 126. Method Format Flags Name Descriptor Attributes Exceptions Wednesday, November 10, 2010
  127. 127. Method Format Flags Name Descriptor Attributes Exceptions Code Wednesday, November 10, 2010
  128. 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
  129. 129. Byte Code Wednesday, November 10, 2010
  130. 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. 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. 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. 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. 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. 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. 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
  137. 137. Demo Wednesday, November 10, 2010
  138. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 158. Hello World System.out.println( “Hello World” ); Wednesday, November 10, 2010
  159. 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. 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. 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. 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. 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. 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. 165. New Object return new BigDecimal(“2.0”); Wednesday, November 10, 2010
  166. 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. 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. 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. 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. 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. 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
  172. 172. Demo Wednesday, November 10, 2010
  173. 173. If / Else static boolean isPositive( int val ){ if ( val > 0 ) { return true; } else { return false; } } Wednesday, November 10, 2010
  174. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×