Esempio n. 1
0
    internal override void Walk()
    {
        CCTypeSet cts = Stack.Peek(0);

        Stack.Peek(1).CheckInt();
        CCTypeSet mv = null;

        foreach (CCType tos in cts)
        {
            tos.xType.CheckExtends(owner);
            CCType tos2 = tos.GetEmbedded(
                owner.GetArrayElementType());
            CCTypeSet vt = new CCTypeSet(tos2);
            if (vt != null)
            {
                if (mv == null)
                {
                    mv = vt;
                }
                else
                {
                    mv = CCTypeSet.Merge(mv, vt);
                }
            }
        }
        if (mv != null)
        {
            next.MergeStack(Stack.Pop(2).Push(mv));
        }
    }
Esempio n. 2
0
    internal override void Walk()
    {
        CCTypeSet cts = Stack.Peek(0);

        Stack.Peek(1).CheckInt();
        CCTypeSet mv = null;

        foreach (CCType tos in cts)
        {
            tos.xType.CheckExtends(owner);
            CCTypeSet sv = new CCTypeSet(tos.GetEmbedded(eltType));
            if (mv == null)
            {
                mv = sv;
            }
            else
            {
                mv = CCTypeSet.Merge(mv, sv);
            }
        }
        if (mv != null)
        {
            next.MergeStack(Stack.Pop(2).Push(mv));
        }
    }
Esempio n. 3
0
    internal override void Walk()
    {
        CCTypeSet cts = Stack.Peek(0);

        Stack.Peek(1).CheckInt();
        CCTypeSet mv = null;

        foreach (CCType tos in cts)
        {
            tos.xType.CheckExtends(owner);
            CCType    tos2 = tos.GetEmbedded(owner);
            CCStruct  cs   = CCStruct.Lookup(tos2);
            CCTypeSet vt   = cs.Get(owner.fieldInverseMapping[off]);
            if (vt != null)
            {
                if (mv == null)
                {
                    mv = vt;
                }
                else
                {
                    mv = CCTypeSet.Merge(mv, vt);
                }
            }
        }
        if (mv != null)
        {
            next.MergeStack(Stack.Pop(2).Push(mv));
        }
    }
Esempio n. 4
0
    internal void Merge(int index, CCTypeSet cts)
    {
        /*
         * Escape analysis: we must not write in a field of
         * a structure a value that pertains to a descendent
         * allocator node.
         */
        CCNodeEntry oa = owner.allocationNode;

        if (oa != null)
        {
            foreach (CCType ct in cts)
            {
                if (oa.IsDescendentOf(ct.allocationNode))
                {
                    continue;
                }
                throw new Exception(string.Format("reference to local instance of type {0} may escape through writing in field of type {1}", ct, owner));
            }
        }

        CCTypeSet octs = fields[index];
        CCTypeSet ncts;

        if (octs == null)
        {
            ncts = cts;
        }
        else
        {
            ncts = CCTypeSet.Merge(octs, cts);
        }
        if (!object.ReferenceEquals(octs, ncts))
        {
            SortedSet <CCNode> rn = regNodes[index];
            if (rn != null)
            {
                foreach (CCNode node in rn)
                {
                    node.MarkUpdate();
                }
            }
        }
    }
Esempio n. 5
0
    internal override void Walk()
    {
        /*
         * For all possible types of the TOS:
         *
         *  1. Verify that the accessor is usable on that type.
         *
         *  2. Obtain the right CCStruct, and get the types
         *     that may be thus obtained. The "right CCStruct"
         *     is the one for the CCType that matches the
         *     element type, and the allocation node and variant
         *     of the type found on the stack.
         *
         *  3. Merge all resulting types.
         */
        CCTypeSet cts = Stack.Peek(0);
        CCTypeSet mv  = null;

        foreach (CCType tos in cts)
        {
            tos.xType.CheckExtends(owner);
            CCType    tos2 = tos.GetEmbedded(owner);
            CCStruct  cs   = CCStruct.Lookup(tos2);
            CCTypeSet vt   = cs.Get(owner.fieldInverseMapping[off]);
            if (vt != null)
            {
                if (mv == null)
                {
                    mv = vt;
                }
                else
                {
                    mv = CCTypeSet.Merge(mv, vt);
                }
            }
        }
        if (mv != null)
        {
            next.MergeStack(Stack.Pop().Push(mv));
        }
    }
Esempio n. 6
0
    internal static CCStack Merge(CCStack s1, CCStack s2)
    {
        if (object.ReferenceEquals(s1, s2))
        {
            return(s1);
        }
        int n1 = s1.Depth;
        int n2 = s2.Depth;

        if (n1 != n2)
        {
            throw new Exception(string.Format("stack merge depth mismatch ({0} / {1})", n1, n2));
        }

        /*
         * Find the common root (it may be null). We retain in
         * 'root' the topmost element at which the two stacks have
         * equal contents.
         */
        StackElt e1 = s1.tos, e2 = s2.tos;
        StackElt root = null;

        for (;;)
        {
            /*
             * When we have reached the same StackElt instance,
             * no further divergence may occur.
             */
            if (object.ReferenceEquals(e1, e2))
            {
                if (root == null)
                {
                    root = e1;
                }
                break;
            }
            if (e1.cts.Equals(e2.cts))
            {
                if (root == null)
                {
                    root = e1;
                }
            }
            else
            {
                root = null;
            }
            e1 = e1.upper;
            e2 = e2.upper;
        }

        int rootRank = (root == null) ? -1 : root.rank;

        /*
         * If the root has maximal rank, then the two stacks are
         * identical.
         */
        if (rootRank == n1 - 1)
        {
            return(s1);
        }

        /*
         * Everything above the root must be instantiated anew. We
         * create the instances in a top-down fashion, fixing links
         * on the way.
         */
        StackElt tos = null;
        StackElt e3  = null;

        e1 = s1.tos;
        e2 = s2.tos;
        for (int i = n1 - 1; i > rootRank; i--)
        {
            StackElt e4 = new StackElt(null,
                                       CCTypeSet.Merge(e1.cts, e2.cts));
            e4.rank = i;
            if (e3 == null)
            {
                tos = e4;
            }
            else
            {
                e3.upper = e4;
            }
            e3 = e4;
            e1 = e1.upper;
            e2 = e2.upper;
        }
        e3.upper = root;

        return(new CCStack(tos));
    }