Examples of ControlFlowGraph


Examples of com.strobel.assembler.flowanalysis.ControlFlowGraph

        }

        private void preProcess() {
            final InstructionCollection instructions = _instructions;
            final List<ExceptionHandler> handlers = _exceptionHandlers;
            final ControlFlowGraph cfg = ControlFlowGraphBuilder.build(instructions, handlers);

            cfg.computeDominance();
            cfg.computeDominanceFrontier();

            for (int i = 0; i < handlers.size(); i++) {
                final ExceptionHandler handler = handlers.get(i);

                if (handler.isFinally()) {
View Full Code Here

Examples of com.strobel.assembler.flowanalysis.ControlFlowGraph

    public static List<ExceptionHandler> run(final InstructionCollection instructions, final List<ExceptionTableEntry> tableEntries) {
        VerifyArgument.notNull(instructions, "instructions");
        VerifyArgument.notNull(tableEntries, "tableEntries");

        final ExceptionHandlerMapper builder = new ExceptionHandlerMapper(instructions, tableEntries);
        final ControlFlowGraph cfg = builder.build();

        final List<ExceptionHandler> handlers = new ArrayList<>();
        final Map<ExceptionTableEntry, ControlFlowNode> handlerStartNodes = new IdentityHashMap<>();

        for (final ExceptionTableEntry entry : builder._tableEntries) {
            final Instruction handlerStart = instructions.atOffset(entry.getHandlerOffset());
            final ControlFlowNode handlerStartNode = builder.findNode(handlerStart);

            if (handlerStartNode == null) {
                throw new IllegalStateException(
                    format(
                        "Could not find entry node for handler at offset %d.",
                        handlerStart.getOffset()
                    )
                );
            }

            if (handlerStartNode.getIncoming().isEmpty()) {
                builder.createEdge(cfg.getEntryPoint(), handlerStartNode, JumpType.Normal);
            }

            handlerStartNodes.put(entry, handlerStartNode);
        }

        cfg.computeDominance();
        cfg.computeDominanceFrontier();

        for (final ExceptionTableEntry entry : builder._tableEntries) {
            final ControlFlowNode handlerStart = handlerStartNodes.get(entry);
            final List<ControlFlowNode> dominatedNodes = new ArrayList<>();
View Full Code Here

Examples of com.strobel.assembler.flowanalysis.ControlFlowGraph

        calculateIncomingJumps();
        createNodes();
        createRegularControlFlow();
        createExceptionalControlFlow();

        return new ControlFlowGraph(_nodes.toArray(new ControlFlowNode[_nodes.size()]));
    }
View Full Code Here

Examples of com.strobel.assembler.flowanalysis.ControlFlowGraph

            return Collections.emptyList();
        }

        Map<ExceptionHandler, Pair<Set<ControlFlowNode>, Set<ControlFlowNode>>> handlerContents = null;
        Map<Instruction, SubroutineInfo> subroutineMap = null;
        ControlFlowGraph cfg = null;

        for (Instruction p = first(instructions);
             p != null;
             p = p.getNext()) {

            if (!p.getOpCode().isJumpToSubroutine()) {
                continue;
            }

            final boolean isLive = !_removed.contains(p);

            if (cfg == null) {
                cfg = ControlFlowGraphBuilder.build(instructions, _exceptionHandlers);
                cfg.computeDominance();
                cfg.computeDominanceFrontier();

                subroutineMap = new IdentityHashMap<>();
                handlerContents = new IdentityHashMap<>();

                for (final ExceptionHandler handler : _exceptionHandlers) {
View Full Code Here

Examples of com.strobel.assembler.flowanalysis.ControlFlowGraph

        if (body.isEmpty() || block.getEntryGoto() == null) {
            return;
        }

        final ControlFlowGraph graph = buildGraph(body, (Label) block.getEntryGoto().getOperand());

        graph.computeDominance();
        graph.computeDominanceFrontier();

        final Set<ControlFlowNode> cfNodes = new LinkedHashSet<>();
        final List<ControlFlowNode> graphNodes = graph.getNodes();

        for (int i = 3; i < graphNodes.size(); i++) {
            cfNodes.add(graphNodes.get(i));
        }

        final List<Node> newBody = findConditions(cfNodes, graph.getEntryPoint());

        block.getBody().clear();
        block.getBody().addAll(newBody);
    }
View Full Code Here

Examples of com.strobel.assembler.flowanalysis.ControlFlowGraph

        if (body.isEmpty() || block.getEntryGoto() == null) {
            return;
        }

        final ControlFlowGraph graph = buildGraph(body, (Label) block.getEntryGoto().getOperand());

        graph.computeDominance();
        graph.computeDominanceFrontier();

        final Set<ControlFlowNode> cfNodes = new LinkedHashSet<>();
        final List<ControlFlowNode> graphNodes = graph.getNodes();

        for (int i = 3; i < graphNodes.size(); i++) {
            cfNodes.add(graphNodes.get(i));
        }

        final List<Node> newBody = findLoops(cfNodes, graph.getEntryPoint(), false);

        block.getBody().clear();
        block.getBody().addAll(newBody);
    }
View Full Code Here

Examples of com.strobel.assembler.flowanalysis.ControlFlowGraph

                    }
                }
            }
        }

        return new ControlFlowGraph(cfNodes.toArray(new ControlFlowNode[cfNodes.size()]));
    }
View Full Code Here

Examples of org.apache.bcel.verifier.structurals.ControlFlowGraph

            currentMethodStatic = methods[i].isStatic();
            if (isValid(method)) {
                // analyse the code of the method to create the frame
                // information about every instruction
                ControlFlowGraph cfg = new ControlFlowGraph(method);
                analyse(clazz, method, cfg, icv, ev);
                // add intercepting code
                rewrite(method, cfg);
                // make last optional check for consistency
                clazz.replaceMethod(methods[i], method.getMethod());
View Full Code Here

Examples of org.apache.bcel.verifier.structurals.ControlFlowGraph

            // //////////// DFA BEGINS HERE ////////////////
            if (!(mg.isAbstract() || mg.isNative())) { // IF mg HAS CODE (See
                // pass 2)

                ControlFlowGraph cfg = new ControlFlowGraph(mg);

                // Build the initial frame situation for this method.
                Frame f = new Frame(mg.getMaxLocals(), mg.getMaxStack());
                if (!mg.isStatic()) {
                    if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)) {
                        Frame._this = new UninitializedObjectType(new ObjectType(jc.getClassName()));
                        f.getLocals().set(0, Frame._this);
                    } else {
                        Frame._this = null;
                        f.getLocals().set(0, new ObjectType(jc.getClassName()));
                    }
                }
                Type[] argtypes = mg.getArgumentTypes();
                int twoslotoffset = 0;
                for (int j = 0; j < argtypes.length; j++) {
                    if (argtypes[j] == Type.SHORT || argtypes[j] == Type.BYTE
                            || argtypes[j] == Type.CHAR
                            || argtypes[j] == Type.BOOLEAN)
                    {
                        argtypes[j] = Type.INT;
                    }
                    f.getLocals().set(twoslotoffset + j
                            + (mg.isStatic() ? 0 : 1),
                            argtypes[j]);
                    if (argtypes[j].getSize() == 2) {
                        twoslotoffset++;
                        f.getLocals().set(twoslotoffset + j
                                + (mg.isStatic() ? 0 : 1),
                                Type.UNKNOWN);
                    }
                }
                circulationPump(cfg, cfg.contextOf(mg.getInstructionList()
                        .getStart()), f, icv, ev);
            }
        } catch (VerifierConstraintViolatedException ce) {
            ce.extendMessage("Constraint violated in method '"
                    + methods[method_no] + "':\n", "");
View Full Code Here

Examples of org.apache.bcel.verifier.structurals.ControlFlowGraph

            currentMethodStatic = methods[i].isStatic();
            if (isValid(method)) {
                // analyse the code of the method to create the frame
                // information about every instruction
                ControlFlowGraph cfg = new ControlFlowGraph(method);
                analyse(clazz, method, cfg, icv, ev);
                // add intercepting code
                rewrite(method, cfg);
                // make last optional check for consistency
                clazz.replaceMethod(methods[i], method.getMethod());
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.