List of usage examples for org.objectweb.asm.tree InsnList add
public void add(final InsnList insnList)
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodNodeAdapter.java
License:Apache License
public void addBeforeInterceptor(final int interceptorId, final InterceptorDefinition interceptorDefinition, final int apiId) { initInterceptorLocalVariables(interceptorId, interceptorDefinition, apiId); final InsnList instructions = new InsnList(); this.methodVariables.loadInterceptorLocalVariables(instructions, interceptorDefinition, false); final String description = Type.getMethodDescriptor(interceptorDefinition.getBeforeMethod()); instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, Type.getInternalName(interceptorDefinition.getInterceptorBaseClass()), "before", description, true));//from w w w . j a v a 2 s .c o m this.methodNode.instructions.insertBefore(this.methodVariables.getEnterInsnNode(), instructions); }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodNodeAdapter.java
License:Apache License
private void invokeAfterInterceptor(final InsnList instructions, final InterceptorDefinition interceptorDefinition, final boolean throwable) { this.methodVariables.loadInterceptorLocalVariables(instructions, interceptorDefinition, true); final String description = Type.getMethodDescriptor(interceptorDefinition.getAfterMethod()); instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, Type.getInternalName(interceptorDefinition.getInterceptorBaseClass()), "after", description, true)); }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
private void initInterceptorVar(final InsnList instructions, final int interceptorId) { assertInitializedInterceptorLocalVariables(); this.interceptorVarIndex = addLocalVariable("_$PINPOINT$_interceptor", "Lcom/navercorp/pinpoint/bootstrap/interceptor/Interceptor;"); push(instructions, interceptorId);/*from ww w . j a v a2 s .co m*/ instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(InterceptorRegistry.class), "getInterceptor", "(I)" + Type.getDescriptor(Interceptor.class), false)); storeVar(instructions, this.interceptorVarIndex); this.resultVarIndex = addLocalVariable("_$PINPOINT$_result", "Ljava/lang/Object;"); loadNull(instructions); storeVar(instructions, this.resultVarIndex); this.throwableVarIndex = addLocalVariable("_$PINPOINT$_throwable", "Ljava/lang/Throwable;"); loadNull(instructions); storeVar(instructions, this.throwableVarIndex); }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
public void loadInterceptorLocalVariables(final InsnList instructions, final InterceptorDefinition interceptorDefinition, final boolean after) { assertInitializedInterceptorLocalVariables(); loadVar(instructions, this.interceptorVarIndex); instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, Type.getInternalName(interceptorDefinition.getInterceptorBaseClass()))); // target(this) object. loadThis(instructions);//from ww w . j a va 2s .c om final InterceptorType interceptorType = interceptorDefinition.getInterceptorType(); if (interceptorType == InterceptorType.ARRAY_ARGS) { // Object target, Object[] args loadVar(instructions, this.argsVarIndex); } else if (interceptorType == InterceptorType.STATIC) { // Object target, String declaringClassInternalName, String methodName, String parameterDescription, Object[] args loadVar(instructions, this.classNameVarIndex); loadVar(instructions, this.methodNameVarIndex); loadVar(instructions, this.parameterDescriptionVarIndex); loadVar(instructions, this.argsVarIndex); } else if (interceptorType == InterceptorType.API_ID_AWARE) { // Object target, int apiId, Object[] args loadInt(instructions, this.apiIdVarIndex); loadVar(instructions, this.argsVarIndex); } else if (interceptorType == InterceptorType.BASIC) { int interceptorMethodParameterCount = getInterceptorParameterCount(interceptorDefinition); int argumentCount = Math.min(this.argumentTypes.length, interceptorMethodParameterCount); int i = 1; for (; i <= argumentCount; i++) { // Object target, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4 if (i == 1) loadVar(instructions, this.arg0VarIndex); else if (i == 2) loadVar(instructions, this.arg1VarIndex); else if (i == 3) loadVar(instructions, this.arg2VarIndex); else if (i == 4) loadVar(instructions, this.arg3VarIndex); else if (i == 5) loadVar(instructions, this.arg4VarIndex); else loadNull(instructions); } for (; i <= interceptorMethodParameterCount; i++) { loadNull(instructions); } } if (after) { loadVar(instructions, this.resultVarIndex); loadVar(instructions, this.throwableVarIndex); } }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
public void loadInterceptorThrowVar(final InsnList instructions) { assertInitializedInterceptorLocalVariables(); loadVar(instructions, this.throwableVarIndex); instructions.add(new InsnNode(Opcodes.ATHROW)); }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
void storeVar(final InsnList instructions, final int index) { instructions.add(new VarInsnNode(Opcodes.ASTORE, index)); }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
void storeInt(final InsnList instructions, final int index) { instructions.add(new VarInsnNode(Opcodes.ISTORE, index)); }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
void loadNull(final InsnList instructions) { instructions.add(new InsnNode(Opcodes.ACONST_NULL)); }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
void loadVar(final InsnList instructions, final int index) { instructions.add(new VarInsnNode(Opcodes.ALOAD, index)); }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
void loadInt(final InsnList instructions, final int index) { instructions.add(new VarInsnNode(Opcodes.ILOAD, index)); }