Java Code Examples for proguard.classfile.instruction.InstructionConstants#OP_FRETURN

The following examples show how to use proguard.classfile.instruction.InstructionConstants#OP_FRETURN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BranchTargetFinder.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
{
    // Mark the instruction.
    instructionMarks[offset] |= INSTRUCTION;

    // Check if this is the first instruction of a subroutine.
    checkSubroutine(offset);

    byte opcode = simpleInstruction.opcode;
    if (opcode == InstructionConstants.OP_IRETURN ||
        opcode == InstructionConstants.OP_LRETURN ||
        opcode == InstructionConstants.OP_FRETURN ||
        opcode == InstructionConstants.OP_DRETURN ||
        opcode == InstructionConstants.OP_ARETURN ||
        opcode == InstructionConstants.OP_ATHROW)
    {
        // Mark the branch origin.
        markBranchOrigin(offset);

        // Mark the next instruction.
        markAfterBranchOrigin(offset + simpleInstruction.length(offset));
    }
}
 
Example 2
Source File: StackSizeComputer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
{
    byte opcode = simpleInstruction.opcode;

    // Some simple instructions exit from the current instruction block.
    exitInstructionBlock =
        opcode == InstructionConstants.OP_IRETURN ||
        opcode == InstructionConstants.OP_LRETURN ||
        opcode == InstructionConstants.OP_FRETURN ||
        opcode == InstructionConstants.OP_DRETURN ||
        opcode == InstructionConstants.OP_ARETURN ||
        opcode == InstructionConstants.OP_RETURN  ||
        opcode == InstructionConstants.OP_ATHROW;
}
 
Example 3
Source File: SideEffectInstructionChecker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
{
    byte opcode = simpleInstruction.opcode;

    // Check for instructions that might cause side effects.
    if (opcode == InstructionConstants.OP_IASTORE      ||
        opcode == InstructionConstants.OP_LASTORE      ||
        opcode == InstructionConstants.OP_FASTORE      ||
        opcode == InstructionConstants.OP_DASTORE      ||
        opcode == InstructionConstants.OP_AASTORE      ||
        opcode == InstructionConstants.OP_BASTORE      ||
        opcode == InstructionConstants.OP_CASTORE      ||
        opcode == InstructionConstants.OP_SASTORE      ||
        opcode == InstructionConstants.OP_ATHROW       ||
        opcode == InstructionConstants.OP_MONITORENTER ||
        opcode == InstructionConstants.OP_MONITOREXIT  ||
        (includeReturnInstructions &&
         (opcode == InstructionConstants.OP_IRETURN ||
          opcode == InstructionConstants.OP_LRETURN ||
          opcode == InstructionConstants.OP_FRETURN ||
          opcode == InstructionConstants.OP_DRETURN ||
          opcode == InstructionConstants.OP_ARETURN ||
          opcode == InstructionConstants.OP_RETURN)))
    {
        // These instructions always cause a side effect.
        hasSideEffects = true;
    }

}
 
Example 4
Source File: ReachableCodeMarker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
{
    byte opcode = simpleInstruction.opcode;
    if (opcode == InstructionConstants.OP_IRETURN ||
        opcode == InstructionConstants.OP_LRETURN ||
        opcode == InstructionConstants.OP_FRETURN ||
        opcode == InstructionConstants.OP_DRETURN ||
        opcode == InstructionConstants.OP_ARETURN ||
        opcode == InstructionConstants.OP_RETURN  ||
        opcode == InstructionConstants.OP_ATHROW)
    {
        next = false;
    }
}
 
Example 5
Source File: GotoReturnReplacer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
{
    // Check if the instruction is an unconditional goto instruction.
    byte opcode = branchInstruction.opcode;
    if (opcode == InstructionConstants.OP_GOTO ||
        opcode == InstructionConstants.OP_GOTO_W)
    {
        // Check if the goto instruction points to a return instruction.
        int targetOffset = offset + branchInstruction.branchOffset;

        if (!codeAttributeEditor.isModified(offset) &&
            !codeAttributeEditor.isModified(targetOffset))
        {
            Instruction targetInstruction = InstructionFactory.create(codeAttribute.code,
                                                                      targetOffset);
            switch (targetInstruction.opcode)
            {
                case InstructionConstants.OP_IRETURN:
                case InstructionConstants.OP_LRETURN:
                case InstructionConstants.OP_FRETURN:
                case InstructionConstants.OP_DRETURN:
                case InstructionConstants.OP_ARETURN:
                case InstructionConstants.OP_RETURN:
                    // Replace the goto instruction by the return instruction.
                    Instruction returnInstruction =
                         new SimpleInstruction(targetInstruction.opcode);
                    codeAttributeEditor.replaceInstruction(offset,
                                                           returnInstruction);

                    // Visit the instruction, if required.
                    if (extraInstructionVisitor != null)
                    {
                        extraInstructionVisitor.visitBranchInstruction(clazz, method, codeAttribute, offset, branchInstruction);
                    }

                    break;
            }
        }
    }
}
 
Example 6
Source File: MethodInliner.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
{
    // Are we inlining this instruction?
    if (inlining)
    {
        // Replace any return instructions by branches to the end of the code.
        switch (simpleInstruction.opcode)
        {
            case InstructionConstants.OP_IRETURN:
            case InstructionConstants.OP_LRETURN:
            case InstructionConstants.OP_FRETURN:
            case InstructionConstants.OP_DRETURN:
            case InstructionConstants.OP_ARETURN:
            case InstructionConstants.OP_RETURN:
                // Are we not at the last instruction?
                if (offset < codeAttribute.u4codeLength-1)
                {
                    // Replace the return instruction by a branch instruction.
                    Instruction branchInstruction =
                        new BranchInstruction(InstructionConstants.OP_GOTO_W,
                                              codeAttribute.u4codeLength - offset);

                    codeAttributeComposer.appendInstruction(offset,
                                                            branchInstruction.shrink());
                }
                else
                {
                    // Just leave out the instruction, but put in a label,
                    // for the sake of any other branch instructions.
                    codeAttributeComposer.appendLabel(offset);
                }

                return;
        }
    }

    codeAttributeComposer.appendInstruction(offset, simpleInstruction.shrink());
}
 
Example 7
Source File: TailRecursionSimplifier.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction)
{
    // Is it a method invocation?
    switch (constantInstruction.opcode)
    {
        case InstructionConstants.OP_INVOKEVIRTUAL:
        case InstructionConstants.OP_INVOKESPECIAL:
        case InstructionConstants.OP_INVOKESTATIC:
        {
            // Is it a recursive call?
            clazz.constantPoolEntryAccept(constantInstruction.constantIndex, recursionChecker);

            if (recursionChecker.isRecursive())
            {
                // Is the next instruction a return?
                int nextOffset =
                    offset + constantInstruction.length(offset);

                Instruction nextInstruction =
                    InstructionFactory.create(codeAttribute.code, nextOffset);

                switch (nextInstruction.opcode)
                {
                    case InstructionConstants.OP_IRETURN:
                    case InstructionConstants.OP_LRETURN:
                    case InstructionConstants.OP_FRETURN:
                    case InstructionConstants.OP_DRETURN:
                    case InstructionConstants.OP_ARETURN:
                    case InstructionConstants.OP_RETURN:
                    {
                        // Isn't the recursive call inside a try/catch block?
                        codeAttribute.exceptionsAccept(clazz, method, offset, recursionChecker);

                        if (recursionChecker.isRecursive())
                        {
                            if (DEBUG)
                            {
                                System.out.println("TailRecursionSimplifier: ["+
                                                   clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz)+"], inlining "+constantInstruction.toString(offset));
                            }

                            // Append a label.
                            codeAttributeComposer.appendLabel(offset);

                            storeParameters(clazz, method);

                            // Branch back to the start of the method.
                            int gotoOffset = offset + 1;
                            codeAttributeComposer.appendInstruction(gotoOffset,
                                                                    new BranchInstruction(InstructionConstants.OP_GOTO, -gotoOffset));

                            // The original return instruction will be
                            // removed elsewhere, if possible.

                            // Remember that the code has changed.
                            inlinedAny = true;

                            if (extraTailRecursionVisitor != null)
                            {
                                extraTailRecursionVisitor.visitConstantInstruction(clazz, method, codeAttribute, offset, constantInstruction);
                            }

                            // The invocation itself is no longer necessary.
                            return;
                        }
                    }
                }
            }

            break;
        }
    }

    // Copy the instruction.
    codeAttributeComposer.appendInstruction(offset, constantInstruction.shrink());
}