We propose a profiling mechanism for constructing a more precise
dynamic call graph than a conservative one constructed using dynamic CHA.
To understand how the mechanism works, we first revisit the virtual
method dispatch table in Jikes RVM , which is a
standard implementation in modern Java virtual machines.
Figure 1(a) depicts the object layout in Jikes RVM. Each
object has a pointer, in its header, to the Type Information Block
(TIB) of its type (class). A TIB is an array of objects that encodes
the type information of a class. At a fixed offset from the TIB
header is the Virtual Method Table (VMT) which is embedded in the TIB
array. A resolved method has an entry in the VMT of its declaring
class, and the entry offset to the TIB header is a constant, say method_offset, assigned during class resolution. A VMT entry records
the instruction address of the method that owns it. Figure 1(b)
shows that, if a class, say A, inherits a method from its
superclass, java.lang.Object, the entry at the method offset in
the subclass' TIB has the inherited method's instruction address. If
a method in the subclass, say D, overrides a method from the
superclass, the two methods still have the same offset, but the
entries in two TIBs point to different method instructions.
Background: virtual method table
Given an object pointer at runtime, an invokevirtual bytecode is
implemented by three basic operations:
TIB = * (ptr + TIB_OFFSET);
INSTR = TIB[method_offset];
The first instruction obtains the TIB address from the object
header. The address of the real target is loaded at the method_offset offset in the TIB. Finally the execution is
transferred to the target address.
Lazy method compilation works by first initializing TIB entries with
the address of a lazy compilation code stub. When a method is invoked
for the first time, the code stub gets executed. The code stub
triggers the compilation of the target method and patches the
address of the compiled method into the TIB entry (where the code stub
Virtual Method Dispatching Table in Jikes RVM