Example usage for org.objectweb.asm Opcodes INVOKESTATIC

List of usage examples for org.objectweb.asm Opcodes INVOKESTATIC

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes INVOKESTATIC.

Prototype

int INVOKESTATIC

To view the source code for org.objectweb.asm Opcodes INVOKESTATIC.

Click Source Link

Usage

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

private void loadMMIO() {
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextLLEInternalName, "getMMIO", "()" + memoryDescriptor);
}

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

private void convertVFloatToInt() {
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(Float.class), "floatToRawIntBits", "(F)I");
}

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

private void convertVIntToFloat() {
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(Float.class), "intBitsToFloat", "(I)F");
}

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

private void applyPfxSrcPostfix(VfpuPfxSrcState pfxSrcState, int n, boolean isFloat) {
    if (pfxSrcState == null || pfxSrcState.isUnknown() || !pfxSrcState.pfxSrc.enabled) {
        return;//from w ww .ja  v a 2  s .  co m
    }

    if (pfxSrcState.pfxSrc.abs[n]) {
        if (log.isTraceEnabled() && pfxSrcState.isKnown() && pfxSrcState.pfxSrc.enabled) {
            log.trace(String.format("PFX    %08X - applyPfxSrcPostfix abs(%d)",
                    getCodeInstruction().getAddress(), n));
        }

        if (isFloat) {
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(Math.class), "abs", "(F)F");
        } else {
            loadImm(0x7FFFFFFF);
            mv.visitInsn(Opcodes.IAND);
        }
    }
    if (pfxSrcState.pfxSrc.neg[n]) {
        if (log.isTraceEnabled() && pfxSrcState.isKnown() && pfxSrcState.pfxSrc.enabled) {
            log.trace(String.format("PFX    %08X - applyPfxSrcPostfix neg(%d)",
                    getCodeInstruction().getAddress(), n));
        }

        if (isFloat) {
            mv.visitInsn(Opcodes.FNEG);
        } else {
            loadImm(0x80000000);
            mv.visitInsn(Opcodes.IXOR);
        }
    }
}

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

private void applyPfxDstPostfix(VfpuPfxDstState pfxDstState, int n, boolean isFloat) {
    if (pfxDstState == null || pfxDstState.isUnknown() || !pfxDstState.pfxDst.enabled) {
        return;//  w w  w .j a  va 2 s  .c  o  m
    }

    switch (pfxDstState.pfxDst.sat[n]) {
    case 1:
        if (log.isTraceEnabled() && pfxDstState != null && pfxDstState.isKnown()
                && pfxDstState.pfxDst.enabled) {
            log.trace(String.format("PFX    %08X - applyPfxDstPostfix %d [0:1]",
                    getCodeInstruction().getAddress(), n));
        }
        if (!isFloat) {
            convertVIntToFloat();
        }
        mv.visitLdcInsn(1.0f);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(Math.class), "min", "(FF)F");
        mv.visitLdcInsn(0.0f);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(Math.class), "max", "(FF)F");
        if (!isFloat) {
            convertVFloatToInt();
        }
        break;
    case 3:
        if (log.isTraceEnabled() && pfxDstState != null && pfxDstState.isKnown()
                && pfxDstState.pfxDst.enabled) {
            log.trace(String.format("PFX    %08X - applyPfxDstPostfix %d [-1:1]",
                    getCodeInstruction().getAddress(), n));
        }
        if (!isFloat) {
            convertVIntToFloat();
        }
        mv.visitLdcInsn(1.0f);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(Math.class), "min", "(FF)F");
        mv.visitLdcInsn(-1.0f);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(Math.class), "max", "(FF)F");
        if (!isFloat) {
            convertVFloatToInt();
        }
        break;
    }
}

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

private void visitContinueToAddress(int returnAddress, boolean returnOnUnknownAddress) {
    //      if (x != returnAddress) {
    //          RuntimeContext.jump(x, returnAddress);
    //      }//from   w  ww .  j av a 2  s . co m
    Label continueLabel = new Label();
    Label isReturnAddress = new Label();

    mv.visitInsn(Opcodes.DUP);
    loadImm(returnAddress);
    visitJump(Opcodes.IF_ICMPEQ, isReturnAddress);

    if (returnOnUnknownAddress) {
        visitJump();
    } else {
        loadImm(returnAddress);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, "jump", "(II)V");
        mv.visitJumpInsn(Opcodes.GOTO, continueLabel);
    }

    mv.visitLabel(isReturnAddress);
    mv.visitInsn(Opcodes.POP);
    mv.visitLabel(continueLabel);
}

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

private void visitContinueToAddressInRegister(int reg) {
    //      if (x != cpu.reg) {
    //          RuntimeContext.jump(x, cpu.reg);
    //      }//  w  w  w  .  j  av  a 2s  . c  om
    Label continueLabel = new Label();
    Label isReturnAddress = new Label();

    mv.visitInsn(Opcodes.DUP);
    loadRegister(reg);
    visitJump(Opcodes.IF_ICMPEQ, isReturnAddress);

    loadRegister(reg);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, "jump", "(II)V");
    mv.visitJumpInsn(Opcodes.GOTO, continueLabel);

    mv.visitLabel(isReturnAddress);
    mv.visitInsn(Opcodes.POP);
    mv.visitLabel(continueLabel);
}

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

public void visitCall(int address, int returnAddress, int returnRegister, boolean returnRegisterModified,
        boolean returnOnUnknownAddress) {
    flushInstructionCount(false, false);

    if (preparedCallNativeCodeBlock != null) {
        if (preparedCallNativeCodeBlock.getNativeCodeSequenceClass().equals(Nop.class)) {
            // NativeCodeSequence Nop means nothing to do!
        } else {/*  ww  w . j  av a 2 s  . com*/
            // Call NativeCodeSequence
            if (log.isDebugEnabled()) {
                log.debug(String.format("Inlining call at 0x%08X to %s", getCodeInstruction().getAddress(),
                        preparedCallNativeCodeBlock));
            }

            visitNativeCodeSequence(preparedCallNativeCodeBlock, address, null);
        }
    } else {
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, getClassName(address, instanceIndex),
                getStaticExecMethodName(), getStaticExecMethodDesc());
        visitContinueToAddress(returnAddress, returnOnUnknownAddress);
    }

    preparedCallNativeCodeBlock = null;
}

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

public void visitCall(int returnAddress, int returnRegister) {
    flushInstructionCount(false, false);
    if (returnRegister != _zr) {
        storeRegister(returnRegister, returnAddress);
    }/* ww w  .j  a  v a 2s  . co  m*/
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, "call", "(I)I");
    visitContinueToAddress(returnAddress, false);
}

From source file:jpcsp.Allegrex.compiler.CompilerContext.java

License:Open Source License

public void visitCall(int address, String methodName) {
    flushInstructionCount(false, false);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, getClassName(address, instanceIndex), methodName, "()V");
}