Package org.jacoco.core.internal.instr
Class MethodInstrumenter
- java.lang.Object
-
- org.objectweb.asm.MethodVisitor
-
- org.jacoco.core.internal.flow.MethodProbesVisitor
-
- org.jacoco.core.internal.instr.MethodInstrumenter
-
class MethodInstrumenter extends MethodProbesVisitor
This method adapter inserts probes as requested by theMethodProbesVisitor
events.
-
-
Field Summary
Fields Modifier and Type Field Description private IProbeInserter
probeInserter
-
Constructor Summary
Constructors Constructor Description MethodInstrumenter(org.objectweb.asm.MethodVisitor mv, IProbeInserter probeInserter)
Create a new instrumenter instance for the given method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private org.objectweb.asm.Label
createIntermediate(org.objectweb.asm.Label label)
private org.objectweb.asm.Label[]
createIntermediates(org.objectweb.asm.Label[] labels)
private int
getInverted(int opcode)
private void
insertIntermediateProbe(org.objectweb.asm.Label label, IFrame frame)
private void
insertIntermediateProbes(org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels, IFrame frame)
void
visitInsnWithProbe(int opcode, int probeId)
Visits a zero operand instruction with a probe.void
visitJumpInsnWithProbe(int opcode, org.objectweb.asm.Label label, int probeId, IFrame frame)
Visits a jump instruction.void
visitLookupSwitchInsnWithProbes(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels, IFrame frame)
Visits a LOOKUPSWITCH instruction with optional probes for each target label.void
visitProbe(int probeId)
Visits an unconditional probe that should be inserted at the current position.void
visitTableSwitchInsnWithProbes(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels, IFrame frame)
Visits a TABLESWITCH instruction with optional probes for each target label.-
Methods inherited from class org.jacoco.core.internal.flow.MethodProbesVisitor
accept
-
Methods inherited from class org.objectweb.asm.MethodVisitor
getDelegate, visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFieldInsn, visitFrame, visitIincInsn, visitInsn, visitInsnAnnotation, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLocalVariable, visitLocalVariableAnnotation, visitLookupSwitchInsn, visitMaxs, visitMethodInsn, visitMethodInsn, visitMultiANewArrayInsn, visitParameter, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation, visitTypeInsn, visitVarInsn
-
-
-
-
Field Detail
-
probeInserter
private final IProbeInserter probeInserter
-
-
Constructor Detail
-
MethodInstrumenter
public MethodInstrumenter(org.objectweb.asm.MethodVisitor mv, IProbeInserter probeInserter)
Create a new instrumenter instance for the given method.- Parameters:
mv
- next method visitor in the chainprobeInserter
- call-back to insert probes where required
-
-
Method Detail
-
visitProbe
public void visitProbe(int probeId)
Description copied from class:MethodProbesVisitor
Visits an unconditional probe that should be inserted at the current position.- Overrides:
visitProbe
in classMethodProbesVisitor
- Parameters:
probeId
- id of the probe to insert
-
visitInsnWithProbe
public void visitInsnWithProbe(int opcode, int probeId)
Description copied from class:MethodProbesVisitor
Visits a zero operand instruction with a probe. This event is used only for instructions that terminate the method. Therefore the probe must be inserted before the actual instruction.- Overrides:
visitInsnWithProbe
in classMethodProbesVisitor
- Parameters:
opcode
- the opcode of the instruction to be visited. This opcode is either IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN or ATHROW.probeId
- id of the probe- See Also:
MethodVisitor.visitInsn(int)
-
visitJumpInsnWithProbe
public void visitJumpInsnWithProbe(int opcode, org.objectweb.asm.Label label, int probeId, IFrame frame)
Description copied from class:MethodProbesVisitor
Visits a jump instruction. A probe with the given id should be inserted in a way that it is executed only when the jump to the given label is executed.- Overrides:
visitJumpInsnWithProbe
in classMethodProbesVisitor
- Parameters:
opcode
- the opcode of the type instruction to be visited. This opcode is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, IFNULL or IFNONNULL.label
- the operand of the instruction to be visited. This operand is a label that designates the instruction to which the jump instruction may jump.probeId
- id of the probeframe
- stackmap frame status after the execution of the jump instruction. The instance is only valid with the call of this method.- See Also:
MethodVisitor.visitJumpInsn(int, Label)
-
getInverted
private int getInverted(int opcode)
-
visitTableSwitchInsnWithProbes
public void visitTableSwitchInsnWithProbes(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels, IFrame frame)
Description copied from class:MethodProbesVisitor
Visits a TABLESWITCH instruction with optional probes for each target label. Implementations can be optimized based on the fact that the same target labels will always have the same probe id within a call to this method. The probe id for each label can be obtained withLabelInfo.getProbeId(Label)
.- Overrides:
visitTableSwitchInsnWithProbes
in classMethodProbesVisitor
- Parameters:
min
- the minimum key value.max
- the maximum key value.dflt
- beginning of the default handler block.labels
- beginnings of the handler blocks.labels[i]
is the beginning of the handler block for themin + i
key.frame
- stackmap frame status after the execution of the switch instruction. The instance is only valid with the call of this method.- See Also:
MethodVisitor.visitTableSwitchInsn(int, int, Label, Label[])
-
visitLookupSwitchInsnWithProbes
public void visitLookupSwitchInsnWithProbes(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels, IFrame frame)
Description copied from class:MethodProbesVisitor
Visits a LOOKUPSWITCH instruction with optional probes for each target label. Implementations can be optimized based on the fact that the same target labels will always have the same probe id within a call to this method. The probe id for each label can be obtained withLabelInfo.getProbeId(Label)
.- Overrides:
visitLookupSwitchInsnWithProbes
in classMethodProbesVisitor
- Parameters:
dflt
- beginning of the default handler block.keys
- the values of the keys.labels
- beginnings of the handler blocks.labels[i]
is the beginning of the handler block for thekeys[i]
key.frame
- stackmap frame status after the execution of the switch instruction. The instance is only valid with the call of this method.- See Also:
MethodVisitor.visitLookupSwitchInsn(Label, int[], Label[])
-
createIntermediates
private org.objectweb.asm.Label[] createIntermediates(org.objectweb.asm.Label[] labels)
-
createIntermediate
private org.objectweb.asm.Label createIntermediate(org.objectweb.asm.Label label)
-
insertIntermediateProbe
private void insertIntermediateProbe(org.objectweb.asm.Label label, IFrame frame)
-
insertIntermediateProbes
private void insertIntermediateProbes(org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels, IFrame frame)
-
-