From 028e2cabbfb392f0a2891fa652b3eb6ef0fc64f1 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 6 Apr 2011 20:20:12 +0000 Subject: [PATCH] get back some of the speed we are losing from bug fixes... --- Robust/src/Analysis/Disjoint/Canonical.java | 33 +++++++++++++++++++++ Robust/src/Analysis/Disjoint/TaintSet.java | 26 ++++++++++++---- Robust/src/Analysis/Pointer/Edge.java | 5 ++-- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/Robust/src/Analysis/Disjoint/Canonical.java b/Robust/src/Analysis/Disjoint/Canonical.java index a4a07b66..391cdd1b 100644 --- a/Robust/src/Analysis/Disjoint/Canonical.java +++ b/Robust/src/Analysis/Disjoint/Canonical.java @@ -1336,6 +1336,12 @@ abstract public class Canonical { return out; } + + public static TaintSet addPTR( TaintSet ts, + Taint t ) { + return add(ts, t); + } + public static TaintSet union( TaintSet ts1, TaintSet ts2 ) { assert ts1 != null; @@ -1391,6 +1397,33 @@ abstract public class Canonical { return out; } + public static TaintSet unionPTR( TaintSet ts1, + TaintSet ts2 ) { + assert ts1 != null; + assert ts2 != null; + assert ts1.isCanonical(); + assert ts2.isCanonical(); + + CanonicalOp op = + new CanonicalOp( CanonicalOp.TAINTSET_UNION_TAINTSET, + ts1, + ts2 ); + + Canonical result = op2result.get( op ); + if( result != null ) { + return (TaintSet) result; + } + + // otherwise, no cached result... + TaintSet out = new TaintSet(); + + out.taints.addAll(ts1.taints); + out.taints.addAll(ts2.taints); + out= (TaintSet) Canonical.makeCanonical(out); + op2result.put( op, out ); + return out; + } + public static TaintSet unionORpreds( TaintSet ts1, TaintSet ts2 ) { assert ts1 != null; diff --git a/Robust/src/Analysis/Disjoint/TaintSet.java b/Robust/src/Analysis/Disjoint/TaintSet.java index b0750343..902bc498 100644 --- a/Robust/src/Analysis/Disjoint/TaintSet.java +++ b/Robust/src/Analysis/Disjoint/TaintSet.java @@ -91,17 +91,19 @@ public class TaintSet extends Canonical { } public TaintSet add(Taint t) { - TaintSet newt=new TaintSet(); + return Canonical.addPTR(this, t); + /* TaintSet newt=new TaintSet(); newt.taints.addAll(taints); newt.taints.add(t); - return (TaintSet) Canonical.makeCanonical(newt); + return (TaintSet) Canonical.makeCanonical(newt);*/ } public TaintSet merge(TaintSet ts) { - TaintSet newt=new TaintSet(); + return Canonical.unionPTR(this, ts); + /* TaintSet newt=new TaintSet(); newt.taints.addAll(taints); newt.taints.addAll(ts.taints); - return (TaintSet) Canonical.makeCanonical(newt); + return (TaintSet) Canonical.makeCanonical(newt);*/ } protected TaintSet() { @@ -172,6 +174,20 @@ public class TaintSet extends Canonical { } public String toString() { - return taints.toString(); + String s = "taints["; + + Iterator tItr = taints.iterator(); + while( tItr.hasNext() ) { + Taint t = tItr.next(); + if (t.toString().indexOf("applyCavity")!=-1) { + s += t.toString(); + if( tItr.hasNext() ) { + s += ",\\n"; + } + } + } + s += "]"; + return s; + // return taints.toString(); } } diff --git a/Robust/src/Analysis/Pointer/Edge.java b/Robust/src/Analysis/Pointer/Edge.java index 73497932..e8239036 100644 --- a/Robust/src/Analysis/Pointer/Edge.java +++ b/Robust/src/Analysis/Pointer/Edge.java @@ -238,8 +238,9 @@ public class Edge { } //Neither is null //Do a set comparison - - return ts1.getTaints().containsAll(ts2.getTaints()); + //do merge + equals...faster than subset... + TaintSet tsmerge=ts1.merge(ts2); + return tsmerge.equals(ts1); } public static boolean subsumes(int status1, int status2) { -- 2.34.1