Java Bytecode Profiler

Patrick Tullmann tullmann at
Tue Nov 10 08:35:35 PST 1998

Tom Harkins wrote:
> I am trying to design a Java Bytecode Profiler using the kaffe source code.
> I am trying to do some analysis to keep track of branches, jumps, and
> function calls done by the Java Bytecode.  I have downloaded the kaffe
> source code and compiled it on a Sun Ultra-Sparc machine.
> Does anyone know where in the source code I might start to look for the
> code that does the branching and jumping. 

If you want to gather run-time information on Java bytecodes, then you
should look at kaffe/kaffevm/intrp/machine.c and
kaffe/kaffevm/kaffe.def.  Be sure to compile with --with-engine=intrp.
machine.c contains the loop that iterates through the bytecodes in a
method and interprets them.  kaffe.def contains the "definition" of
each bytecode.  The function "virtualMachine()" in machine.c is called 
once for each method invocation.  (So, for a really simple profiler,
you can just print method info at the top of virtualMachine())

If you want static information about bytecodes in a method, then
JavaClass or some other off-line analysis package might be a better

If you want to analyze the run-time performance of JIT'd code, you'll
have to rummage around in kaffe/kaffevm/jit/*.*.

> Has anyone attempted to do such a project with or without success.

I have a set of hacks for an old version of Kaffe that record each
method entry/exit and who called it.  The dynamic number of *bytecode*
instructions executed on a per-method basis, and it records the number
of times each bytecode is interpreted (e.g., 10,000 newarray, etc...)

If anyone's interested, I can send out the code for maintaining the
profiling info.  A number of hacks to the interpreter loop need to be
incorporated, they would have to be moved from my mostly
unrecognizable interpreter loop, but I could do that with a little


----- ----- ---- ---  ---  --   -    -      -         -               -
Pat Tullmann                                       tullmann at
		Your research fills a much needed gap.

More information about the kaffe mailing list