Search in sources :

Example 6 with SegmentNode

use of soot.jimple.spark.geom.dataRep.SegmentNode in project soot by Sable.

the class PtInsIntervalManager method addNewFigure.

public SegmentNode addNewFigure(int code, RectangleNode pnew) {
    SegmentNode p;
    if (code == ALL_TO_ALL) {
        // Directly clean all the existing intervals
        if (header[0] != null && header[0].I2 == 0)
            return null;
        p = new SegmentNode();
        p.I1 = p.I2 = 0;
        p.L = Constants.MAX_CONTEXTS;
        for (int i = 0; i < Divisions; ++i) {
            size[i] = 0;
            header[i] = null;
        }
    } else {
        if (code == ALL_TO_MANY || code == ONE_TO_ONE) {
            p = header[ALL_TO_MANY];
            while (p != null) {
                if ((p.I2 <= pnew.I2) && (p.I2 + p.L >= pnew.I2 + pnew.L))
                    return null;
                p = p.next;
            }
        }
        if (code == MANY_TO_ALL || code == ONE_TO_ONE) {
            p = header[MANY_TO_ALL];
            while (p != null) {
                if ((p.I1 <= pnew.I1) && (p.I1 + p.L >= pnew.I1 + pnew.L))
                    return null;
                p = p.next;
            }
        }
        // Be careful of this!
        if (code == ONE_TO_ONE) {
            p = header[ONE_TO_ONE];
            while (p != null) {
                if (p.I1 - p.I2 == pnew.I1 - pnew.I2) {
                    // On the same line
                    if (p.I1 <= pnew.I1 && p.I1 + p.L >= pnew.I1 + pnew.L)
                        return null;
                }
                p = p.next;
            }
        }
        // Insert the new interval immediately, and we delay the merging until necessary
        p = new SegmentNode(pnew);
        if (code == ALL_TO_MANY)
            clean_garbage_all_to_many(p);
        else if (code == MANY_TO_ALL)
            clean_garbage_many_to_all(p);
        else
            clean_garbage_one_to_one(p);
    }
    hasNewObject = true;
    size[code]++;
    p.next = header[code];
    header[code] = p;
    return p;
}
Also used : SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Example 7 with SegmentNode

use of soot.jimple.spark.geom.dataRep.SegmentNode in project soot by Sable.

the class PtInsIntervalManager method clean_garbage_all_to_many.

private void clean_garbage_all_to_many(SegmentNode mp) {
    SegmentNode p, q, list;
    int num;
    long right, left;
    list = header[0];
    p = q = null;
    num = 0;
    left = mp.I2;
    right = mp.I2 + mp.L;
    while (list != null) {
        if (list.I2 >= left) {
            if (list.I2 <= right) {
                if (list.I2 + list.L > right) {
                    // We extend mp to the right
                    right = list.I2 + list.L;
                }
                list = list.next;
                continue;
            }
        } else if (list.I2 + list.L >= left) {
            // We extend mp to the left
            left = list.I2;
            list = list.next;
            continue;
        }
        // Because the unprocessed points-to tuples are headed at the list
        if (q == null) {
            p = q = list;
        } else {
            q.next = list;
            q = list;
        }
        ++num;
        list = list.next;
    }
    mp.I2 = left;
    mp.L = right - left;
    if (q != null)
        q.next = null;
    header[0] = p;
    size[0] = num;
}
Also used : SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Example 8 with SegmentNode

use of soot.jimple.spark.geom.dataRep.SegmentNode in project soot by Sable.

the class PtInsIntervalManager method clean_garbage_one_to_one.

/*
	 * Eliminate the redundant ONE_TO_ONE figures
	 */
private void clean_garbage_one_to_one(SegmentNode predator) {
    SegmentNode p, q, list;
    int num;
    list = header[ONE_TO_ONE];
    p = q = null;
    num = 0;
    while (list != null) {
        long L = list.L;
        if ((predator.I2 - predator.I1 == list.I2 - list.I1) && predator.I1 <= list.I1 && (predator.I1 + predator.L >= list.I2 + L))
            // So we ignore it
            ;
        else {
            if (q == null) {
                p = q = list;
            } else {
                q.next = list;
                q = list;
            }
            ++num;
        }
        list = list.next;
    }
    if (q != null)
        q.next = null;
    header[ONE_TO_ONE] = p;
    size[ONE_TO_ONE] = num;
}
Also used : SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Example 9 with SegmentNode

use of soot.jimple.spark.geom.dataRep.SegmentNode in project soot by Sable.

the class PtInsIntervalManager method flush.

public void flush() {
    hasNewObject = false;
    for (int i = 0; i < Divisions; ++i) {
        SegmentNode p = header[i];
        while (p != null && p.is_new == true) {
            p.is_new = false;
            p = p.next;
        }
    }
}
Also used : SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Example 10 with SegmentNode

use of soot.jimple.spark.geom.dataRep.SegmentNode in project soot by Sable.

the class PtInsIntervalManager method mergeFigures.

public void mergeFigures(int upperSize) {
    if (size[ONE_TO_ONE] > upperSize && header[ONE_TO_ONE].is_new == true) {
        // After the merging, we must propagate this interval, thus it has to be a new interval
        SegmentNode p = generate_all_to_many(header[ONE_TO_ONE]);
        clean_garbage_all_to_many(p);
        p.next = header[ALL_TO_MANY];
        header[ALL_TO_MANY] = p;
        header[ONE_TO_ONE] = null;
        size[ALL_TO_MANY]++;
        size[ONE_TO_ONE] = 0;
    }
    if (size[MANY_TO_ALL] > upperSize && header[MANY_TO_ALL].is_new == true) {
        header[MANY_TO_ALL] = generate_many_to_all(header[MANY_TO_ALL]);
        size[MANY_TO_ALL] = 1;
    }
    if (size[ALL_TO_MANY] > upperSize && header[ALL_TO_MANY].is_new == true) {
        header[0] = generate_all_to_many(header[ALL_TO_MANY]);
        size[ALL_TO_MANY] = 1;
    }
}
Also used : SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Aggregations

SegmentNode (soot.jimple.spark.geom.dataRep.SegmentNode)51 PlainConstraint (soot.jimple.spark.geom.dataRep.PlainConstraint)24 AllocNode (soot.jimple.spark.pag.AllocNode)12 HashMap (java.util.HashMap)6 Map (java.util.Map)6 RectangleNode (soot.jimple.spark.geom.dataRep.RectangleNode)5 SootMethod (soot.SootMethod)3 GeomPointsTo (soot.jimple.spark.geom.geomPA.GeomPointsTo)3 StringConstantNode (soot.jimple.spark.pag.StringConstantNode)3 ClassConstantNode (soot.jimple.spark.pag.ClassConstantNode)2