Example usage for org.objectweb.asm MethodVisitor visitJumpInsn

List of usage examples for org.objectweb.asm MethodVisitor visitJumpInsn

Introduction

In this page you can find the example usage for org.objectweb.asm MethodVisitor visitJumpInsn.

Prototype

public void visitJumpInsn(final int opcode, final Label label) 

Source Link

Document

Visits a jump instruction.

Usage

From source file:org.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler.java

License:Open Source License

/**
 * @param cv//from   w w  w .  j  a va 2  s .com
 * @param input
 */
private void createPartOfInvokeMethodWithoutAfterThrowingAdviceTypes(final MethodVisitor cv,
        final CompilerInput input) {
    final int returnValueIndex = (input.joinPointInstanceIndex != INDEX_NOTAVAILABLE)
            ? (input.joinPointInstanceIndex + 1)
            : input.callerIndex + 1;
    final int exceptionIndex = returnValueIndex + 1;

    cv.visitInsn(ACONST_NULL);
    cv.visitVarInsn(ASTORE, returnValueIndex);

    Label tryLabel = new Label();
    cv.visitLabel(tryLabel);
    if (!m_requiresProceedMethod) {
        // if no around advice then optimize by invoking the target JP directly and no call to proceed()
        createInlinedJoinPointInvocation(cv, input);
        int stackIndex = returnValueIndex;//use another int since storeType will update it
        AsmHelper.storeType(cv, stackIndex, m_returnType);
        addReturnedValueToJoinPoint(cv, input, returnValueIndex, false);
    } else {
        createInvocationToProceedMethod(cv, input.joinPointInstanceIndex, returnValueIndex);
    }

    createAfterReturningAdviceInvocations(cv, input);

    Label finallyLabel1 = new Label();
    cv.visitLabel(finallyLabel1);

    createAfterFinallyAdviceInvocations(cv, input);

    Label gotoFinallyLabel = new Label();
    cv.visitJumpInsn(GOTO, gotoFinallyLabel);

    Label exceptionLabel = new Label();
    cv.visitLabel(exceptionLabel);
    cv.visitVarInsn(ASTORE, exceptionIndex);

    Label finallyLabel2 = new Label();
    cv.visitLabel(finallyLabel2);

    createAfterFinallyAdviceInvocations(cv, input);

    cv.visitVarInsn(ALOAD, exceptionIndex);
    cv.visitInsn(ATHROW);

    cv.visitLabel(gotoFinallyLabel);

    // unwrap if around advice and return in all cases
    if (m_returnType.getSort() != Type.VOID) {
        if (m_requiresProceedMethod) {
            cv.visitVarInsn(ALOAD, returnValueIndex);
            AsmHelper.unwrapType(cv, m_returnType);
        } else {
            AsmHelper.loadType(cv, returnValueIndex, m_returnType);
        }
    }

    AsmHelper.addReturnStatement(cv, m_returnType);

    cv.visitTryCatchBlock(tryLabel, finallyLabel1, exceptionLabel, null);
    cv.visitTryCatchBlock(exceptionLabel, finallyLabel2, exceptionLabel, null);
}

From source file:org.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler.java

License:Open Source License

/**
 * Create the proceed() method.//from  w w  w.j  a  va 2s .com
 *
 * @param input a slightly different CompilerInput since jp index, is changed and caller and callee are meaningless
 *              in the proceed() method.
 */
private void createProceedMethod(CompilerInput input) {

    MethodVisitor cv = m_cw.visitMethod(ACC_PUBLIC | ACC_FINAL, PROCEED_METHOD_NAME, PROCEED_METHOD_SIGNATURE,
            null, new String[] { THROWABLE_CLASS_NAME });

    if (m_isThisAdvisable) {
        createAroundInterceptorInvocations(cv);
    }

    incrementStackFrameCounter(cv);

    // set up the labels
    Label tryLabel = new Label();
    Label defaultCaseLabel = new Label();
    Label gotoLabel = new Label();
    Label handlerLabel = new Label();
    Label endLabel = new Label();

    int nrOfCases = m_aroundAdviceMethodInfos.length;
    if (m_isThisAdvisable) {
        nrOfCases++;
    }

    Label[] caseLabels = new Label[nrOfCases];
    Label[] returnLabels = new Label[nrOfCases];
    int[] caseNumbers = new int[nrOfCases];
    for (int i = 0; i < caseLabels.length; i++) {
        caseLabels[i] = new Label();
        caseNumbers[i] = i;
    }
    for (int i = 0; i < returnLabels.length; i++) {
        returnLabels[i] = new Label();
    }

    // start try-catch block
    cv.visitLabel(tryLabel);

    // start the switch block and set the stackframe as the param to the switch
    cv.visitVarInsn(ALOAD, 0);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, STACK_FRAME_COUNTER_FIELD_NAME, I);
    cv.visitLookupSwitchInsn(defaultCaseLabel, caseNumbers, caseLabels);

    // add one case for each around advice invocation
    for (int i = 0; i < m_aroundAdviceMethodInfos.length; i++) {
        cv.visitLabel(caseLabels[i]);

        // gather advice info
        AdviceMethodInfo adviceInfo = m_aroundAdviceMethodInfos[i];

        Label endInstanceOflabel = beginRuntimeCheck(cv, input, adviceInfo.getAdviceInfo());

        // get the aspect instance
        adviceInfo.getAspectInfo().getAspectModel().loadAspect(cv, input, adviceInfo.getAspectInfo());

        // load the arguments to the advice
        adviceInfo.getAspectInfo().getAspectModel().createAroundAdviceArgumentHandling(cv, input,
                m_argumentTypes, adviceInfo);

        // invoke the advice method
        cv.visitMethodInsn(INVOKEVIRTUAL, adviceInfo.getAspectInfo().getAspectClassName(),
                adviceInfo.getAdviceInfo().getMethodName(), adviceInfo.getAdviceInfo().getMethodSignature());
        cv.visitVarInsn(ASTORE, 1);

        // we need to handle the case when the advice was skipped due to runtime check
        // that is : if (runtimeCheck) { ret = advice() } else { ret = proceed() }
        if (endInstanceOflabel != null) {
            Label elseInstanceOfLabel = new Label();
            cv.visitJumpInsn(GOTO, elseInstanceOfLabel);
            endRuntimeCheck(cv, adviceInfo.getAdviceInfo(), endInstanceOflabel);
            cv.visitVarInsn(ALOAD, 0);
            cv.visitMethodInsn(INVOKESPECIAL, m_joinPointClassName, PROCEED_METHOD_NAME,
                    PROCEED_METHOD_SIGNATURE);
            cv.visitVarInsn(ASTORE, 1);
            cv.visitLabel(elseInstanceOfLabel);
        }

        cv.visitLabel(returnLabels[i]);

        cv.visitVarInsn(ALOAD, 1);
        cv.visitInsn(ARETURN);
    }

    if (m_isThisAdvisable) {
        int delegationCaseIndex = caseLabels.length - 1;
        cv.visitLabel(caseLabels[delegationCaseIndex]);
        cv.visitVarInsn(ALOAD, 0);
        cv.visitInsn(ICONST_0);
        cv.visitFieldInsn(PUTFIELD, m_joinPointClassName, INTERCEPTOR_INDEX_FIELD_NAME, I);
        cv.visitVarInsn(ALOAD, 0);
        cv.visitMethodInsn(INVOKEVIRTUAL, m_joinPointClassName, PROCEED_METHOD_NAME, PROCEED_METHOD_SIGNATURE);

        cv.visitLabel(returnLabels[delegationCaseIndex]);

        cv.visitInsn(ARETURN);
    }

    // invoke the target join point in the default case
    cv.visitLabel(defaultCaseLabel);

    AsmHelper.prepareWrappingOfPrimitiveType(cv, Type.getReturnType(m_calleeMemberDesc));

    createJoinPointInvocation(cv);

    Type m_returnType = null;
    if (m_joinPointType != JoinPointType.CONSTRUCTOR_CALL_INT) {
        m_returnType = Type.getReturnType(m_calleeMemberDesc);
    } else {
        m_returnType = Type.getType(m_calleeClassSignature);
    }
    AsmHelper.wrapPrimitiveType(cv, m_returnType);
    cv.visitVarInsn(ASTORE, 1);

    // store it in Rtti return value
    addReturnedValueToJoinPoint(cv, input, 1, true);

    // set it as the CALLEE instance for ctor call - TODO refactor somewhere else
    if (m_joinPointType == JoinPointType.CONSTRUCTOR_CALL_INT) {
        cv.visitVarInsn(ALOAD, 0);
        cv.visitVarInsn(ALOAD, 1);
        cv.visitFieldInsn(PUTFIELD, m_joinPointClassName, CALLEE_INSTANCE_FIELD_NAME, m_calleeClassSignature);
    }

    cv.visitLabel(gotoLabel);

    cv.visitVarInsn(ALOAD, 1);
    cv.visitInsn(ARETURN);

    // finally clause
    cv.visitLabel(handlerLabel);
    cv.visitVarInsn(ASTORE, 2);
    cv.visitLabel(endLabel);

    cv.visitVarInsn(ALOAD, 2);
    cv.visitInsn(ATHROW);

    // set up the label table
    cv.visitTryCatchBlock(tryLabel, returnLabels[0], handlerLabel, null);
    for (int i = 1; i < caseLabels.length; i++) {
        Label caseLabel = caseLabels[i];
        Label returnLabel = returnLabels[i];
        cv.visitTryCatchBlock(caseLabel, returnLabel, handlerLabel, null);
    }
    cv.visitTryCatchBlock(defaultCaseLabel, gotoLabel, handlerLabel, null);
    cv.visitTryCatchBlock(handlerLabel, endLabel, handlerLabel, null);
    cv.visitMaxs(0, 0);
}

From source file:org.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler.java

License:Open Source License

/**
 * Adds after returning advice invocations.
 *
 * @param cv/*  w  w  w  .  j ava 2 s . com*/
 * @param input
 */
private void createAfterReturningAdviceInvocations(final MethodVisitor cv, final CompilerInput input) {
    final int returnValueIndex = (input.joinPointInstanceIndex != INDEX_NOTAVAILABLE)
            ? (input.joinPointInstanceIndex + 1)
            : input.callerIndex + 1;

    if (m_isThisAdvisable) {
        createAfterReturningInterceptorInvocations(cv, input.joinPointInstanceIndex, returnValueIndex);
    }

    boolean hasPoppedReturnValueFromStack = false;
    for (int i = m_afterReturningAdviceMethodInfos.length - 1; i >= 0; i--) {
        AdviceMethodInfo advice = m_afterReturningAdviceMethodInfos[i];

        // set the return value index that will be used as arg to advice
        advice.setSpecialArgumentIndex(returnValueIndex);

        String specialArgDesc = advice.getSpecialArgumentTypeDesc();
        if (specialArgDesc == null) {
            // after returning
            createAfterAdviceInvocation(cv, input, advice, INDEX_NOTAVAILABLE);
        } else {
            // after returning <TYPE>
            if (AsmHelper.isPrimitive(m_returnType)) {
                if (m_returnType.getDescriptor().equals(specialArgDesc)) {
                    createAfterAdviceInvocation(cv, input, advice, returnValueIndex);
                }
            } else {
                cv.visitVarInsn(ALOAD, returnValueIndex);

                cv.visitTypeInsn(INSTANCEOF, advice.getSpecialArgumentTypeName());

                Label label = new Label();
                cv.visitJumpInsn(IFEQ, label);

                createAfterAdviceInvocation(cv, input, advice, returnValueIndex);

                cv.visitLabel(label);
            }
        }
    }

    // need the return value in return operation
    if (!m_requiresProceedMethod && hasPoppedReturnValueFromStack) {
        cv.visitVarInsn(ALOAD, returnValueIndex);
    }
}

From source file:org.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler.java

License:Open Source License

/**
 * Handles the if case for runtime check (target instanceof, cflow)
 *
 * @param cv/* w  ww  .  ja v a  2  s .  c o  m*/
 * @param adviceInfo
 * @return the label for endIf or null if the adviceInfo did not required runtime check
 */
private Label beginRuntimeCheck(final MethodVisitor cv, final CompilerInput input,
        final AdviceInfo adviceInfo) {
    Label endRuntimeCheckLabel = null;
    DeploymentModel deploymentModel = adviceInfo.getAspectDeploymentModel();
    if (adviceInfo.hasTargetWithRuntimeCheck() || adviceInfo.getAdviceDefinition().hasCflowOrCflowBelow()
            || DeploymentModel.PER_THIS.equals(deploymentModel)
            || DeploymentModel.PER_TARGET.equals(deploymentModel)) {

        int perObjectCheckType = RuntimeCheckVisitor.NULL_PER_OBJECT_TYPE;

        if (DeploymentModel.PER_THIS.equals(deploymentModel)) {
            perObjectCheckType = RuntimeCheckVisitor.PER_THIS_TYPE;
        } else if (DeploymentModel.PER_TARGET.equals(deploymentModel)) {
            perObjectCheckType = RuntimeCheckVisitor.PER_TARGET_TYPE;
        }

        endRuntimeCheckLabel = new Label();
        // create a specific visitor everytime
        RuntimeCheckVisitor runtimeCheckVisitor = new RuntimeCheckVisitor(cv, adviceInfo.getExpressionInfo(),
                input, perObjectCheckType, adviceInfo.getAspectQualifiedName());
        runtimeCheckVisitor.pushCheckOnStack(adviceInfo);
        cv.visitJumpInsn(IFEQ, endRuntimeCheckLabel);
    }
    return endRuntimeCheckLabel;
}

From source file:org.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler.java

License:Open Source License

/**
 * Handles the around interceptor invocations.
 *
 * @param cv/*from w w w  . j  a v a  2 s .  com*/
 */
private void createAroundInterceptorInvocations(final MethodVisitor cv) {
    cv.visitVarInsn(ALOAD, 0);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, INTERCEPTOR_INDEX_FIELD_NAME, I);
    cv.visitInsn(ICONST_M1);
    Label ifStatementLabel = new Label();
    cv.visitJumpInsn(IF_ICMPEQ, ifStatementLabel);
    cv.visitVarInsn(ALOAD, 0);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, INTERCEPTOR_INDEX_FIELD_NAME, I);
    cv.visitVarInsn(ALOAD, 0);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, NR_OF_AROUND_INTERCEPTORS_FIELD_NAME, I);
    cv.visitJumpInsn(IF_ICMPGE, ifStatementLabel);
    cv.visitVarInsn(ALOAD, 0);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, AROUND_INTERCEPTORS_FIELD_NAME,
            AROUND_ADVICE_ARRAY_CLASS_SIGNATURE);
    cv.visitVarInsn(ALOAD, 0);
    cv.visitInsn(DUP);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, INTERCEPTOR_INDEX_FIELD_NAME, I);
    cv.visitInsn(DUP_X1);
    cv.visitInsn(ICONST_1);
    cv.visitInsn(IADD);
    cv.visitFieldInsn(PUTFIELD, m_joinPointClassName, INTERCEPTOR_INDEX_FIELD_NAME, I);
    cv.visitInsn(AALOAD);
    cv.visitVarInsn(ALOAD, 0);
    cv.visitMethodInsn(INVOKEINTERFACE, AROUND_ADVICE_CLASS_NAME, INTERCEPT_INVOKE_METHOD_NAME,
            AROUND_ADVICE_INVOKE_METHOD_SIGNATURE);
    cv.visitInsn(ARETURN);
    cv.visitLabel(ifStatementLabel);
}

From source file:org.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler.java

License:Open Source License

/**
 * Creates invocations fo the before interceptors.
 *
 * @param cv/*  w  ww  . j a v  a2 s.  co  m*/
 * @param joinPointInstanceIndex
 * @param registerDepth
 */
private void createBeforeInterceptorInvocations(final MethodVisitor cv, final int joinPointInstanceIndex,
        final int registerDepth) {
    final int loopIndex = registerDepth + 1;
    cv.visitInsn(ICONST_0);
    cv.visitVarInsn(ISTORE, loopIndex);
    Label loopStartLabel = new Label();
    cv.visitLabel(loopStartLabel);
    cv.visitVarInsn(ILOAD, loopIndex);
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, NR_OF_BEFORE_INTERCEPTORS_FIELD_NAME, I);
    Label loopCheckCondLabel = new Label();
    cv.visitJumpInsn(IF_ICMPGE, loopCheckCondLabel);
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, BEFORE_INTERCEPTORS_FIELD_NAME,
            BEFORE_ADVICE_ARRAY_CLASS_SIGNATURE);
    cv.visitVarInsn(ILOAD, loopIndex);
    cv.visitInsn(AALOAD);
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitMethodInsn(INVOKEINTERFACE, BEFORE_ADVICE_CLASS_NAME, INTERCEPT_INVOKE_METHOD_NAME,
            BEFORE_ADVICE_INVOKE_METHOD_SIGNATURE);
    cv.visitIincInsn(loopIndex, 1);
    cv.visitJumpInsn(GOTO, loopStartLabel);
    cv.visitLabel(loopCheckCondLabel);
}

From source file:org.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler.java

License:Open Source License

/**
 * Creates invocations fo the after finally interceptors.
 *
 * @param cv//from www  .  j a v  a 2s .co  m
 * @param joinPointInstanceIndex
 * @param registerDepth
 */
private void createAfterInterceptorInvocations(final MethodVisitor cv, final int joinPointInstanceIndex,
        final int registerDepth) {
    final int loopIndex = registerDepth + 1;
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, NR_OF_AFTER_INTERCEPTORS_FIELD_NAME, I);
    cv.visitInsn(ICONST_1);
    cv.visitInsn(ISUB);
    cv.visitVarInsn(ISTORE, loopIndex);
    Label loopLabel1 = new Label();
    cv.visitLabel(loopLabel1);
    cv.visitVarInsn(ILOAD, loopIndex);
    Label loopLabel2 = new Label();
    cv.visitJumpInsn(IFLT, loopLabel2);
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, AFTER_INTERCEPTORS_FIELD_NAME,
            AFTER_ADVICE_ARRAY_CLASS_SIGNATURE);
    cv.visitVarInsn(ILOAD, loopIndex);
    cv.visitInsn(AALOAD);
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitMethodInsn(INVOKEINTERFACE, AFTER_ADVICE_CLASS_NAME, INTERCEPT_INVOKE_METHOD_NAME,
            AFTER_ADVICE_INVOKE_METHOD_SIGNATURE);
    cv.visitIincInsn(loopIndex, -1);
    cv.visitJumpInsn(GOTO, loopLabel1);
    cv.visitLabel(loopLabel2);
}

From source file:org.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler.java

License:Open Source License

/**
 * Creates invocations fo the after returning interceptors.
 *
 * @param cv//from w  ww .  j  a va2 s  . co m
 * @param joinPointInstanceIndex
 * @param returnValueInstanceIndex
 */
private void createAfterReturningInterceptorInvocations(final MethodVisitor cv,
        final int joinPointInstanceIndex, final int returnValueInstanceIndex) {
    final int loopIndex = returnValueInstanceIndex + 1;
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, NR_OF_AFTER_RETURNING_INTERCEPTORS_FIELD_NAME, I);
    cv.visitInsn(ICONST_1);
    cv.visitInsn(ISUB);
    cv.visitVarInsn(ISTORE, loopIndex);
    Label loopLabel1 = new Label();
    cv.visitLabel(loopLabel1);
    cv.visitVarInsn(ILOAD, loopIndex);
    Label loopLabel2 = new Label();
    cv.visitJumpInsn(IFLT, loopLabel2);
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, AFTER_RETURNING_INTERCEPTORS_FIELD_NAME,
            AFTER_RETURNING_ADVICE_ARRAY_CLASS_SIGNATURE);
    cv.visitVarInsn(ILOAD, loopIndex);
    cv.visitInsn(AALOAD);
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitVarInsn(ALOAD, returnValueInstanceIndex);
    cv.visitMethodInsn(INVOKEINTERFACE, AFTER_RETURNING_ADVICE_CLASS_NAME, INTERCEPT_INVOKE_METHOD_NAME,
            AFTER_RETURNING_ADVICE_INVOKE_METHOD_SIGNATURE);
    cv.visitIincInsn(loopIndex, -1);
    cv.visitJumpInsn(GOTO, loopLabel1);
    cv.visitLabel(loopLabel2);
}

From source file:org.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler.java

License:Open Source License

/**
 * Creates invocations fo the after returning interceptors.
 *
 * @param cv//ww w.  ja  va 2s  .  c o m
 * @param joinPointInstanceIndex
 * @param exceptionInstanceIndex
 */
private void createAfterThrowingInterceptorInvocations(final MethodVisitor cv, final int joinPointInstanceIndex,
        final int exceptionInstanceIndex) {
    final int loopIndex = exceptionInstanceIndex + 1;
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, NR_OF_AFTER_THROWING_INTERCEPTORS_FIELD_NAME, I);
    cv.visitInsn(ICONST_1);
    cv.visitInsn(ISUB);
    cv.visitVarInsn(ISTORE, loopIndex);
    Label loopLabel1 = new Label();
    cv.visitLabel(loopLabel1);
    cv.visitVarInsn(ILOAD, loopIndex);
    Label loopLabel2 = new Label();
    cv.visitJumpInsn(IFLT, loopLabel2);
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitFieldInsn(GETFIELD, m_joinPointClassName, AFTER_THROWING_INTERCEPTORS_FIELD_NAME,
            AFTER_THROWING_ADVICE_ARRAY_CLASS_SIGNATURE);
    cv.visitVarInsn(ILOAD, loopIndex);
    cv.visitInsn(AALOAD);
    cv.visitVarInsn(ALOAD, joinPointInstanceIndex);
    cv.visitVarInsn(ALOAD, exceptionInstanceIndex);
    cv.visitMethodInsn(INVOKEINTERFACE, AFTER_THROWING_ADVICE_CLASS_NAME, INTERCEPT_INVOKE_METHOD_NAME,
            AFTER_THROWING_ADVICE_INVOKE_METHOD_SIGNATURE);
    cv.visitIincInsn(loopIndex, -1);
    cv.visitJumpInsn(GOTO, loopLabel1);
    cv.visitLabel(loopLabel2);
}

From source file:org.codehaus.aspectwerkz.transform.inlining.compiler.AspectWerkzAspectModel.java

License:Open Source License

/**
 * Load aspect instance on stack/*from ww w .  j  ava 2 s .c  o  m*/
 *
 * @param cv
 * @param input
 * @param aspectInfo
 */
public void loadAspect(final MethodVisitor cv, final CompilerInput input, final AspectInfo aspectInfo) {
    DeploymentModel deploymentModel = aspectInfo.getDeploymentModel();
    if (DeploymentModel.PER_JVM.equals(deploymentModel) || DeploymentModel.PER_CLASS.equals(deploymentModel)) {
        cv.visitFieldInsn(GETSTATIC, input.joinPointClassName, aspectInfo.getAspectFieldName(),
                aspectInfo.getAspectClassSignature());
    } else if (DeploymentModel.PER_INSTANCE.equals(deploymentModel)) {
        AbstractJoinPointCompiler.loadJoinPointInstance(cv, input);
        cv.visitFieldInsn(GETFIELD, input.joinPointClassName, aspectInfo.getAspectFieldName(),
                aspectInfo.getAspectClassSignature());
    } else if (DeploymentModel.PER_THIS.equals(deploymentModel)) {
        AbstractJoinPointCompiler.loadJoinPointInstance(cv, input);
        cv.visitFieldInsn(GETFIELD, input.joinPointClassName, aspectInfo.getAspectFieldName(),
                aspectInfo.getAspectClassSignature());

        //FIXME see FIXME on aspect instantion
        Label nullCheck = new Label();
        cv.visitJumpInsn(IFNONNULL, nullCheck);
        storeAspectInstance(cv, input, aspectInfo, input.callerIndex);
        cv.visitLabel(nullCheck);

        AbstractJoinPointCompiler.loadJoinPointInstance(cv, input);
        cv.visitFieldInsn(GETFIELD, input.joinPointClassName, aspectInfo.getAspectFieldName(),
                aspectInfo.getAspectClassSignature());
    } else if (DeploymentModel.PER_TARGET.equals(deploymentModel)) {
        AbstractJoinPointCompiler.loadJoinPointInstance(cv, input);
        cv.visitFieldInsn(GETFIELD, input.joinPointClassName, aspectInfo.getAspectFieldName(),
                aspectInfo.getAspectClassSignature());
        //FIXME see FIXME on aspect instantion

        Label nullCheck = new Label();
        cv.visitJumpInsn(IFNONNULL, nullCheck);
        storeAspectInstance(cv, input, aspectInfo, input.calleeIndex);
        cv.visitLabel(nullCheck);

        AbstractJoinPointCompiler.loadJoinPointInstance(cv, input);
        cv.visitFieldInsn(GETFIELD, input.joinPointClassName, aspectInfo.getAspectFieldName(),
                aspectInfo.getAspectClassSignature());
    } else {
        throw new DefinitionException("deployment model [" + deploymentModel + "] is not supported");
    }
}