com.mentorgen.tools.profile.instrument
Class PerfMethodAdapter

java.lang.Object
  extended by org.objectweb.asm.jip.MethodAdapter
      extended by com.mentorgen.tools.profile.instrument.PerfMethodAdapter
All Implemented Interfaces:
MethodVisitor

public class PerfMethodAdapter
extends MethodAdapter

This class is responsible for instrumenting a method to call the profiler in order for performance data to be gathered. The basic idea is that the profiler is called when a method starts and when it exists which allows the profiler to gather performance data (note that a method can be exited from when an exception is thrown as well as when return is called). The one big caveate is static initializers. They are not called as part of the flow of the program — they are called by the classloader. Since they whole premise of the profiler is built on the idea of a orderly call stack, static initializers are not instrumented.

Author:
Andrew Wilcox

Field Summary
 
Fields inherited from class org.objectweb.asm.jip.MethodAdapter
mv
 
Constructor Summary
PerfMethodAdapter(MethodVisitor visitor, java.lang.String className, java.lang.String methodName)
           
 
Method Summary
 void visitCode()
          Starts the visit of the method's code, if any (i.e.
 void visitInsn(int inst)
          Visits a zero operand instruction.
 void visitLabel(Label label)
          Visits a label.
 void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
          Visits a method instruction.
 void visitTryCatchBlock(Label start, Label end, Label handler, java.lang.String type)
          Visits a try catch block.
 
Methods inherited from class org.objectweb.asm.jip.MethodAdapter
visitAnnotation, visitAnnotationDefault, visitAttribute, visitEnd, visitFieldInsn, visitIincInsn, visitIntInsn, visitJumpInsn, visitLdcInsn, visitLineNumber, visitLocalVariable, visitLookupSwitchInsn, visitMaxs, visitMultiANewArrayInsn, visitParameterAnnotation, visitTableSwitchInsn, visitTypeInsn, visitVarInsn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerfMethodAdapter

public PerfMethodAdapter(MethodVisitor visitor,
                         java.lang.String className,
                         java.lang.String methodName)
Method Detail

visitCode

public void visitCode()
Description copied from interface: MethodVisitor
Starts the visit of the method's code, if any (i.e. non abstract method).

Specified by:
visitCode in interface MethodVisitor
Overrides:
visitCode in class MethodAdapter

visitInsn

public void visitInsn(int inst)
Description copied from interface: MethodVisitor
Visits a zero operand instruction.

Specified by:
visitInsn in interface MethodVisitor
Overrides:
visitInsn in class MethodAdapter
Parameters:
inst - the opcode of the instruction to be visited. This opcode is either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S, LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER, or MONITOREXIT.

visitMethodInsn

public void visitMethodInsn(int opcode,
                            java.lang.String owner,
                            java.lang.String name,
                            java.lang.String desc)
Description copied from interface: MethodVisitor
Visits a method instruction. A method instruction is an instruction that invokes a method.

Specified by:
visitMethodInsn in interface MethodVisitor
Overrides:
visitMethodInsn in class MethodAdapter
Parameters:
opcode - the opcode of the type instruction to be visited. This opcode is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.
owner - the internal name of the method's owner class (see getInternalName).
name - the method's name.
desc - the method's descriptor (see Type).

visitTryCatchBlock

public void visitTryCatchBlock(Label start,
                               Label end,
                               Label handler,
                               java.lang.String type)
Description copied from interface: MethodVisitor
Visits a try catch block.

Specified by:
visitTryCatchBlock in interface MethodVisitor
Overrides:
visitTryCatchBlock in class MethodAdapter
Parameters:
start - beginning of the exception handler's scope (inclusive).
end - end of the exception handler's scope (exclusive).
handler - beginning of the exception handler's code.
type - internal name of the type of exceptions handled by the handler, or null to catch any exceptions (for "finally" blocks).

visitLabel

public void visitLabel(Label label)
Description copied from interface: MethodVisitor
Visits a label. A label designates the instruction that will be visited just after it.

Specified by:
visitLabel in interface MethodVisitor
Overrides:
visitLabel in class MethodAdapter
Parameters:
label - a Label object.