Examples of IBasicBlock


Examples of org.apache.flex.abc.graph.IBasicBlock

        boolean lastBlockWasReachable = true;

        int blockIdx = 0;
        while ( blockIdx < blocks.size() )
        {
            IBasicBlock b = blocks.get(blockIdx);
            boolean isReachable = cfg.isReachable(b);

            // Only advance the block index if the current
            // block is removed.
            int previousBlockCount = blocks.size();

            if ( ! isReachable )
            {
                //  Don't remove unreachable blocks that are the final block in an exception handler,
                //  unless they're also the first block in the exception handler.  The AVM depends on
                //  these blocks under some circumstances.  However, the block's instructions can be
                //  coalesced to a single OP_nop.
                boolean safeToRemove = true;

                for ( ExceptionInfo ex: this.mbi.getExceptions() )
                {
                    IBasicBlock toBlock = this.mbi.getCfg().getBlock(ex.getTo());
                    if ( b.equals(toBlock) )
                    {
                        IBasicBlock fromBlock = this.mbi.getCfg().getBlock(ex.getFrom());

                        int tryFrom = blocks.indexOf(fromBlock);
                        int tryTo   = blocks.indexOf(toBlock);
                        assert tryFrom >= 0 && tryTo >= tryFrom;
View Full Code Here

Examples of org.apache.flex.abc.graph.IBasicBlock

     * instead.
     * @return the block that the label refers to.
     */
    public IBasicBlock getBlock(Label target, boolean throwOnError)
    {
        IBasicBlock result = cfg.getBlock(target);

        if (result == null && throwOnError)
            throw new IllegalArgumentException("Label " + target.toString() + " was referenced, but never defined.");

        return result;
View Full Code Here

Examples of org.apache.flex.abc.graph.IBasicBlock

        // We've seen all the instructions now, so we can compute the blocks that
        // each label corresponds to, and fill in the rest of the graph
        for (Map.Entry<Block, Collection<Label>> entry : successor_labels.entrySet())
            for (Label target_label : entry.getValue())
            {
                IBasicBlock target_block = getBlock(target_label);
                if ( target_block != null )
                    entry.getKey().addSuccessor(target_block);
            }
    }
View Full Code Here

Examples of org.apache.flex.abc.graph.IBasicBlock

            //  Search backwards through the instruction stream; bump any line
            //  number found during this search since the dead block is probably
            //  on the next line.
            for ( int i = this.blocks.indexOf(b) - 1; i >= 0 && result == null; i-- )
            {
                IBasicBlock candidate = this.blocks.get(i);
                result = searchBlock( candidate, ABCConstants.OP_debugline, candidate.size() - 1, SearchDirection.Backward);
            }
        }

        return result != null? result.getImmediate(): -1;
    }
View Full Code Here

Examples of org.apache.flex.abc.graph.IBasicBlock

        //  Search backwards through the instruction stream if necessary.
        if ( result == null )
        {
            for ( int i = this.blocks.indexOf(b) - 1; i >= 0 && result == null; i-- )
            {
                IBasicBlock candidate = this.blocks.get(i);
                result = searchBlock(candidate, ABCConstants.OP_debugfile, candidate.size() - 1, SearchDirection.Backward);
            }
        }

        if (result == null)
            return null;
View Full Code Here

Examples of org.apache.flex.abc.graph.IBasicBlock

    {
        Iterator<IBasicBlock> it = new DepthFirstPreorderIterator(roots);

        while ( it.hasNext() )
        {
            IBasicBlock node = it.next();

            if ( !semi.containsKey(node) )
            {
                vertex.add(node);

                //  Initial assumption: the node's semidominator is itself.
                semi.put(node, semi.size());
                label.put(node, node);

                for (IBasicBlock child : node.getSuccessors())
                {
                    pred.get(child).add(node);
                    if (!semi.containsKey(child))
                    {
                        parent.put(child, node);
View Full Code Here

Examples of org.apache.flex.abc.graph.IBasicBlock

    {
        int lastSemiNumber = semi.size() - 1;

        for (int i = lastSemiNumber; i > 0; i--)
        {
            IBasicBlock w = vertex.get(i);
            IBasicBlock p = this.parent.get(w);

            //  step 2: compute semidominators
            //  for each v in pred(w)...
            int semidominator = semi.get(w);
            for (IBasicBlock v : pred.get(w))
                semidominator = Math.min(semidominator, semi.get(eval(v)));

            semi.put(w, semidominator);
            bucket.get(vertex.get(semidominator)).add(w);

            //  Link w into the forest via its parent, p
            link(p, w);

            //  step 3: implicitly compute idominators
            //  for each v in bucket(parent(w)) ...
            for (IBasicBlock v : bucket.get(p))
            {
                IBasicBlock u = eval(v);

                if (semi.get(u) < semi.get(v))
                    idom.put(v, u);
                else
                    idom.put(v, p);
            }

            bucket.get(p).clear();
        }

        // step 4: explicitly compute idominators
        for (int i = 1; i <= lastSemiNumber; i++)
        {
            IBasicBlock w = vertex.get(i);

            if (idom.get(w) != vertex.get((semi.get(w))))
                idom.put(w, idom.get(idom.get(w)));
        }
    }
View Full Code Here

Examples of org.apache.flex.abc.graph.IBasicBlock

    private void compress(IBasicBlock v)
    {
        Stack<IBasicBlock> worklist = new Stack<IBasicBlock>();
        worklist.add(v);

        IBasicBlock a = this.ancestor.get(v);

        //  Traverse back to the subtree root.
        while ( this.ancestor.containsKey(a) )
        {
            worklist.push(a);
            a = this.ancestor.get(a);
        }

        //  Propagate semidominator information forward.
        IBasicBlock ancestor = worklist.pop();
        int leastSemi = semi.get(label.get(ancestor));

        while ( !worklist.empty() )
        {
            IBasicBlock descendent = worklist.pop();
            int currentSemi = semi.get(label.get(descendent));

            if ( currentSemi > leastSemi)
                label.put(descendent, label.get(ancestor));
            else
View Full Code Here

Examples of org.apache.flex.abc.graph.IBasicBlock

    public IBasicBlock next()
    {
        if (!hasNext())
            throw new NoSuchElementException();

        IBasicBlock next = toDo.pop();
        pushSuccessors(next);
        return next;
    }
View Full Code Here

Examples of org.apache.flex.abc.graph.IBasicBlock

        }

        while ( ! w.isEmpty() )
        {
            Iterator<IBasicBlock> it = w.iterator();
            IBasicBlock x = it.next();
            it.remove();

            for ( IBasicBlock y: df.get(x) )
            {
                if ( !hasAlready.containsKey(y) || hasAlready.get(y).intValue() < iterCount )
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.