use of soot.jimple.spark.geom.dataRep.SegmentNode in project soot by Sable.
the class IFigureManager method reclaimRectangleNode.
/**
* Return the rectangle node to cache.
* @param p
* @return
*/
protected static SegmentNode reclaimRectangleNode(SegmentNode p) {
SegmentNode q = p.next;
p.next = rectHeader;
rectHeader = p;
return q;
}
use of soot.jimple.spark.geom.dataRep.SegmentNode in project soot by Sable.
the class HeapInsIntervalManager method addNewFigure.
/*
* pnew.L < 0 is a special case we used to indicate a square: L = L_prime
* This case is specially handled because it is very common in the program.
* And, treating it as a MANY-TO-ALL is loss of precision.
*/
public SegmentNode addNewFigure(int code, RectangleNode pnew) {
SegmentNode p;
if (code == ALL_TO_ALL) {
// Directly clean all the existing intervals unless the all-to-all figure is existing.
if (header[ALL_TO_MANY] != null && header[ALL_TO_MANY].I2 == 0)
return null;
p = new SegmentNode();
code = ALL_TO_MANY;
p.I1 = p.I2 = 0;
p.L = Constants.MAX_CONTEXTS;
for (int i = 0; i < Divisions; ++i) {
size[i] = 0;
header[i] = null;
}
} else {
// This is a all-to-many or one-to-one figure
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;
}
}
// This is a many-to-all or one-to-one figure
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;
}
}
// This is a one-to-one figure
if (code == ONE_TO_ONE) {
p = header[ONE_TO_ONE];
while (p != null) {
// We don't process the case: the input figure is a square but the tested figure is a segment
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);
}
hasNewFigure = true;
size[code]++;
p.next = header[code];
header[code] = p;
return p;
}
use of soot.jimple.spark.geom.dataRep.SegmentNode in project soot by Sable.
the class HeapInsIntervalManager method generate_many_to_all.
/**
* The result is in the form: (p, q, I, 0, L)
*/
private SegmentNode generate_many_to_all(SegmentNode mp) {
long left, right;
SegmentNode p;
left = mp.I1;
right = left + mp.L;
p = mp.next;
while (p != null) {
if (p.I1 < left)
left = p.I1;
long t = p.I1 + p.L;
if (t > right)
right = t;
p = p.next;
}
mp.I1 = left;
mp.I2 = 0;
mp.L = right - left;
mp.next = null;
return mp;
}
use of soot.jimple.spark.geom.dataRep.SegmentNode in project soot by Sable.
the class HeapInsIntervalManager method removeUselessSegments.
public void removeUselessSegments() {
int i;
SegmentNode p, q, temp;
p = header[ONE_TO_ONE];
size[ONE_TO_ONE] = 0;
q = null;
while (p != null) {
boolean contained = false;
long L = p.L;
for (i = 0; i < 2; ++i) {
temp = header[i];
while (temp != null) {
if (temp.I1 == 0 || ((temp.I1 <= p.I1) && (temp.I1 + temp.L >= p.I1 + L))) {
if (temp.I2 == 0 || ((temp.I2 <= p.I2) && (temp.I2 + temp.L >= p.I2 + L))) {
contained = true;
break;
}
}
temp = temp.next;
}
}
temp = p.next;
if (contained == false) {
p.next = q;
q = p;
++size[ONE_TO_ONE];
}
p = temp;
}
header[ONE_TO_ONE] = q;
}
use of soot.jimple.spark.geom.dataRep.SegmentNode in project soot by Sable.
the class HeapInsIntervalManager method mergeFigures.
// This function tries to do the geometric merging
public void mergeFigures(int upperSize) {
if (!hasNewFigure)
return;
/*
* We start the merging from ONE_TO_ONE, because the generated figure may be merged with those figures in MANY_TO_ALL
*/
if (size[ONE_TO_ONE] > upperSize && header[ONE_TO_ONE].is_new == true) {
// We prefer to generate a heap insensitive figure
SegmentNode p = generate_many_to_all(header[ONE_TO_ONE]);
clean_garbage_many_to_all(p);
p.next = header[MANY_TO_ALL];
header[MANY_TO_ALL] = p;
header[ONE_TO_ONE] = null;
size[MANY_TO_ALL]++;
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[ALL_TO_MANY] = generate_all_to_many(header[ALL_TO_MANY]);
size[ALL_TO_MANY] = 1;
}
}
Aggregations