1

I'm trying to understand 'native code generation and execution' part of Java JITC, but having a hard time visualizing exactly what happens. E.g. say I have the following class:

class Foo
{
    private int x;
    public void incX()
    {
        x++;
    }
}

javac generates the following byte code for the method:

public void incX();
Code:
Stack=3, Locals=1, Args_size=1
0:   aload_0
1:   dup
2:   getfield        #17; //Field x:I
5:   iconst_1
6:   iadd
7:   putfield        #17; //Field x:I
10:  return
LineNumberTable:
line 33: 0
line 34: 10

LocalVariableTable:
Start  Length  Slot  Name   Signature
0      11      0    this       LFoo;

When JITC converts this into native code, what exactly happens? And how is this native code executed by JVM?

int3
  • 12,861
  • 8
  • 51
  • 80
shrini1000
  • 7,038
  • 12
  • 59
  • 99

1 Answers1

0

When the method gets called sufficiently often to pass the JVM's compilation threshold, the JIT compiles the bytecode into native code, and sets it up so that calls to the function go directly to the natively compiled method.

Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413