Examples of OpCode


Examples of com.strobel.assembler.ir.OpCode

            if (end == null || end.getOffset() >= _instructions.get(_instructions.size() - 1).getEndOffset()) {
                continue;
            }

            final OpCode endOpCode = end.getOpCode();

            //
            // Create normal edges from one instruction to the next.
            //
            if (!endOpCode.isUnconditionalBranch()) {
                final Instruction next = end.getNext();

                if (next != null) {
                    createEdge(node, next, JumpType.Normal);
                }
            }

            //
            // Create edges for branch instructions.
            //
            for (Instruction instruction = node.getStart();
                 instruction != null && instruction.getOffset() <= end.getOffset();
                 instruction = instruction.getNext()) {

                final OpCode opCode = instruction.getOpCode();

                if (opCode.getOperandType() == OperandType.BranchTarget) {
                    createEdge(node, instruction.<Instruction>getOperand(0), JumpType.Normal);
                }
                else if (opCode.getOperandType() == OperandType.Switch) {
                    final SwitchInfo switchInfo = instruction.getOperand(0);

                    createEdge(node, switchInfo.getDefaultTarget(), JumpType.Normal);

                    for (final Instruction target : switchInfo.getTargets()) {
View Full Code Here

Examples of com.strobel.assembler.ir.OpCode

import java.util.List;

public final class InstructionHelper {
    public static int getLoadOrStoreSlot(final Instruction instruction) {
        final OpCode code = instruction.getOpCode();

        if (!code.isLoad() && !code.isStore()) {
            return -1;
        }

        if (code.getOpCodeType() == OpCodeType.Macro) {
            return OpCodeHelpers.getLoadStoreMacroArgumentIndex(code);
        }

        final VariableDefinition variable = instruction.getOperand(0);
View Full Code Here

Examples of com.strobel.assembler.ir.OpCode

    public static int getPopDelta(final Instruction instruction, final MethodBody body) {
        VerifyArgument.notNull(instruction, "instruction");
        VerifyArgument.notNull(body, "body");

        final OpCode code = instruction.getOpCode();

        switch (code.getStackBehaviorPop()) {
            case Pop0:
                return 0;

            case Pop1: {
                if (code == OpCode.PUTSTATIC) {
                    final FieldReference field = instruction.getOperand(0);
                    if (field.getFieldType().getSimpleType().isDoubleWord()) {
                        return 2;
                    }
                }
                return 1;
            }

            case Pop2:
                return 1;

            case Pop1_Pop1:
                return 2;

            case Pop1_Pop2:
                return 3;
//                return 2;

            case Pop1_PopA: {
                if (code == OpCode.PUTFIELD) {
                    final FieldReference field = instruction.getOperand(0);
                    if (field.getFieldType().getSimpleType().isDoubleWord()) {
                        return 3;
                    }
                }
                return 2;
            }

            case Pop2_Pop1:
                return 3;
//                return 2;

            case Pop2_Pop2:
                return 4;
//                return 2;

            case PopI4:
                return 1;

            case PopI8:
                return 2;
//                return 1;

            case PopR4:
                return 1;

            case PopR8:
                return 2;
//                return 1;

            case PopA:
                return 1;

            case PopI4_PopI4:
                return 2;

            case PopI4_PopI8:
                return 3;
//                return 2;

            case PopI8_PopI8:
                return 4;
//                return 2;

            case PopR4_PopR4:
                return 2;

            case PopR8_PopR8:
                return 4;
//                return 2;

            case PopI4_PopA:
                return 2;

            case PopI4_PopI4_PopA:
                return 3;

            case PopI8_PopI4_PopA:
                return 4;
//                return 3;

            case PopR4_PopI4_PopA:
                return 3;

            case PopR8_PopI4_PopA:
                return 4;
//                return 3;

            case PopA_PopI4_PopA:
                return 3;

            case PopA_PopA:
                return 2;

            case VarPop: {
                if (code == OpCode.ATHROW) {
                    return 1;
                }

                if (code == OpCode.MULTIANEWARRAY) {
                    return instruction.getOperand(1);
                }

                if (code.getFlowControl() != FlowControl.Call) {
                    break;
                }

                final IMethodSignature signature;
View Full Code Here

Examples of com.strobel.assembler.ir.OpCode

    public static int getPushDelta(final Instruction instruction, final MethodBody body) {
        VerifyArgument.notNull(instruction, "instruction");
        VerifyArgument.notNull(body, "body");

        final OpCode code = instruction.getOpCode();

        switch (code.getStackBehaviorPush()) {
            case Push0:
                return 0;

            case Push1: {
                if (code == OpCode.GETFIELD || code == OpCode.GETSTATIC) {
                    final FieldReference field = instruction.getOperand(0);
                    if (field.getFieldType().getSimpleType().isDoubleWord()) {
                        return 2;
                    }
                }
                return 1;
            }

            case Push1_Push1:
                return 2;

            case Push1_Push1_Push1:
                return 3;

            case Push1_Push2_Push1:
                return 4;
//                return 3;

            case Push2:
                return 2;
//                return 1;

            case Push2_Push2:
                return 4;
//                return 2;

            case Push2_Push1_Push2:
                return 5;
//                return 3;

            case Push2_Push2_Push2:
                return 6;
//                return 3;

            case PushI4:
                return 1;

            case PushI8:
                return 2;
//                return 1;

            case PushR4:
                return 1;

            case PushR8:
                return 2;
//                return 1;

            case PushA:
                return 1;

            case PushAddress:
                return 1;

            case VarPush: {
                if (code.getFlowControl() != FlowControl.Call) {
                    break;
                }

                final IMethodSignature signature;
View Full Code Here

Examples of com.strobel.assembler.ir.OpCode

        //
        // Step 1: Determine which instructions are jump targets.
        //

        for (final Instruction instruction : _instructions) {
            final OpCode opCode = instruction.getOpCode();

            if (opCode.getOperandType() == OperandType.BranchTarget) {
                _hasIncomingJumps[getInstructionIndex(instruction.<Instruction>getOperand(0))] = true;
            }
            else if (opCode.getOperandType() == OperandType.Switch) {
                final SwitchInfo switchInfo = instruction.getOperand(0);

                _hasIncomingJumps[getInstructionIndex(switchInfo.getDefaultTarget())] = true;

                for (final Instruction target : switchInfo.getTargets()) {
View Full Code Here

Examples of com.strobel.assembler.ir.OpCode

            //
            // See how big we can make that block...
            //
            for (; i + 1 < n; i++) {
                final Instruction instruction = instructions.get(i);
                final OpCode opCode = instruction.getOpCode();

                if (opCode.isUnconditionalBranch() /*|| opCode.canThrow()*/ || _hasIncomingJumps[i + 1]) {
                    break;
                }

                final Instruction next = instruction.getNext();

View Full Code Here

Examples of com.strobel.assembler.ir.OpCode

            if (end == null || end.getOffset() >= _instructions.get(_instructions.size() - 1).getEndOffset()) {
                continue;
            }

            final OpCode endOpCode = end.getOpCode();

            //
            // Create normal edges from one instruction to the next.
            //
            if (!endOpCode.isUnconditionalBranch()) {
                final Instruction next = end.getNext();

                if (next != null) {
                    createEdge(node, next, JumpType.Normal);
                }
            }

            //
            // Create edges for branch instructions.
            //
            for (Instruction instruction = node.getStart();
                 instruction != null && instruction.getOffset() <= end.getOffset();
                 instruction = instruction.getNext()) {

                final OpCode opCode = instruction.getOpCode();

                if (opCode.getOperandType() == OperandType.BranchTarget) {
                    final ControlFlowNode handlerBlock = findInnermostHandlerBlock(node.getEnd().getOffset());

                    if (handlerBlock.getNodeType() == ControlFlowNodeType.FinallyHandler) {
                        createEdge(node, instruction.<Instruction>getOperand(0), JumpType.LeaveTry);
                    }
                    else {
                        createEdge(node, instruction.<Instruction>getOperand(0), JumpType.Normal);
                    }
                }
                else if (opCode.getOperandType() == OperandType.Switch) {
                    final SwitchInfo switchInfo = instruction.getOperand(0);

                    createEdge(node, switchInfo.getDefaultTarget(), JumpType.Normal);

                    for (final Instruction target : switchInfo.getTargets()) {
View Full Code Here

Examples of com.strobel.assembler.ir.OpCode

        //
        // Step 1: Determine which instructions are jump targets.
        //

        for (final Instruction instruction : _instructions) {
            final OpCode opCode = instruction.getOpCode();

            if (opCode.getOperandType() == OperandType.BranchTarget) {
                _hasIncomingJumps[getInstructionIndex(instruction.<Instruction>getOperand(0))] = true;
            }
            else if (opCode.getOperandType() == OperandType.Switch) {
                final SwitchInfo switchInfo = instruction.getOperand(0);

                _hasIncomingJumps[getInstructionIndex(switchInfo.getDefaultTarget())] = true;

                for (final Instruction target : switchInfo.getTargets()) {
View Full Code Here

Examples of com.strobel.assembler.ir.OpCode

            //
            // See how big we can make that block...
            //
            for (; i + 1 < n; i++) {
                final Instruction instruction = instructions.get(i);
                final OpCode opCode = instruction.getOpCode();

                if (opCode.isBranch() /*|| opCode.canThrow()*/ || _hasIncomingJumps[i + 1]) {
                    break;
                }

                final Instruction next = instruction.getNext();

View Full Code Here

Examples of com.strobel.assembler.ir.OpCode

            if (end == null || end.getOffset() >= _instructions.get(_instructions.size() - 1).getEndOffset()) {
                continue;
            }

            final OpCode endOpCode = end.getOpCode();

            //
            // Create normal edges from one instruction to the next.
            //
            if (!endOpCode.isUnconditionalBranch() || endOpCode.isJumpToSubroutine()) {
                final Instruction next = end.getNext();

                if (next != null) {
                    final boolean isHandlerStart = any(
                        _exceptionHandlers,
                        new Predicate<ExceptionHandler>() {
                            @Override
                            public boolean test(final ExceptionHandler handler) {
                                return handler.getHandlerBlock().getFirstInstruction() == next;
                            }
                        }
                    );

                    if (!isHandlerStart) {
                        createEdge(node, next, JumpType.Normal);
                    }
                }
            }

            //
            // Create edges for branch instructions.
            //
            for (Instruction instruction = node.getStart();
                 instruction != null && instruction.getOffset() <= end.getOffset();
                 instruction = instruction.getNext()) {

                final OpCode opCode = instruction.getOpCode();

                if (opCode.getOperandType() == OperandType.BranchTarget) {
                    createBranchControlFlow(node, instruction, instruction.<Instruction>getOperand(0));
                }
                else if (opCode.getOperandType() == OperandType.Switch) {
                    final SwitchInfo switchInfo = instruction.getOperand(0);

                    createEdge(node, switchInfo.getDefaultTarget(), JumpType.Normal);

                    for (final Instruction target : switchInfo.getTargets()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.