[Fb-contrib-commit] SF.net SVN: fb-contrib:[1118] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2009-03-01 03:20:46
|
Revision: 1118
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1118&view=rev
Author: dbrosius
Date: 2009-03-01 03:20:41 +0000 (Sun, 01 Mar 2009)
Log Message:
-----------
tighten up UAA, fix 1934619
Modified Paths:
--------------
trunk/fb-contrib/samples/UAA_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java
Modified: trunk/fb-contrib/samples/UAA_Sample.java
===================================================================
--- trunk/fb-contrib/samples/UAA_Sample.java 2009-02-28 04:17:09 UTC (rev 1117)
+++ trunk/fb-contrib/samples/UAA_Sample.java 2009-03-01 03:20:41 UTC (rev 1118)
@@ -1,4 +1,3 @@
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -8,8 +7,8 @@
public class UAA_Sample {
- private Set<String> in = new HashSet<String>();
- private Set<String> out = new HashSet<String>();
+ private final Set<String> in = new HashSet<String>();
+ private final Set<String> out = new HashSet<String>();
public Set<String> testLocalSet(Set<String> in) {
Set<String> out = new HashSet<String>();
@@ -88,4 +87,28 @@
System.out.println("Hmm");
}
}
+
+ public void testFP1934619_A(final List<String> out, final Set<String> currentParents)
+ {
+ for (String currentOid : currentParents)
+ {
+ out.add(currentOid);
+ if (currentOid.indexOf("xx") > -1) {
+ continue;
+ }
+ out.add("don't forget me");
+ }
+ }
+
+ public void testFP1934619_B(final List<String> out, final Set<String> currentParents)
+ {
+ for (String currentOid : currentParents)
+ {
+ if (currentOid.indexOf("xx") > -1)
+ {
+ throw new RuntimeException("enough is enough");
+ }
+ out.add(currentOid);
+ }
+ }
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2009-02-28 04:17:09 UTC (rev 1117)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2009-03-01 03:20:41 UTC (rev 1118)
@@ -54,7 +54,7 @@
}
}
- private BugReporter bugReporter;
+ private final BugReporter bugReporter;
private OpcodeStack stack;
/** register/field to alias register/field */
private Map<Comparable<?>, Comparable<?>> userValues;
@@ -138,6 +138,8 @@
.addSourceLine(this, loopPC));
}
it.remove();
+ } else if ((loop.getEndPC() > pc) && (loop.addPC < (pc - 5)) && (loop.addPC > 0)) {
+ it.remove();
}
}
@@ -185,9 +187,7 @@
if (uValue != null) {
LoopInfo loop = loops.get(uValue);
if (loop != null) {
- if (loop.inConditionalRange(pc))
- loop.foundAdd(-1);
- else if (loop.isInLoop(pc, false)) {
+ if (loop.isInLoop(pc)) {
if (this.getCodeByte(getNextPC()) == POP) {
loop.foundAdd(pc);
}
@@ -202,12 +202,11 @@
if (uValue != null) {
LoopInfo loop = loops.get(uValue);
if (loop != null) {
- if (loop.inConditionalRange(pc))
- loop.foundAdd(-1);
- else if (loop.isInLoop(pc, false))
+ if (loop.isInLoop(pc)) {
if (this.getCodeByte(getNextPC()) == POP) {
loop.foundAdd(pc);
}
+ }
}
}
}
@@ -244,12 +243,8 @@
}
}
- if (!loopFound)
- {
- LoopInfo loop = findLoop(pc, true);
- if (loop != null) {
- loop.addConditionalRange(pc, getBranchTarget());
- }
+ if (!loopFound) {
+ removeLoop(pc);
}
}
}
@@ -269,10 +264,7 @@
}
}
} else if (((seen > IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL)) {
- LoopInfo loop = findLoop(pc, true);
- if (loop != null) {
- loop.addConditionalRange(pc, getBranchOffset() > 0 ? getBranchTarget() : loop.end);
- }
+ removeLoop(pc);
} else if (seen == CHECKCAST) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
@@ -359,21 +351,29 @@
return null;
}
- private LoopInfo findLoop(int pc, boolean ignoreConditionals) {
+ private LoopInfo findLoop(int pc) {
for (LoopInfo loop : loops.values()) {
- if (loop.isInLoop(pc, ignoreConditionals))
+ if (loop.isInLoop(pc))
return loop;
}
return null;
}
+ private void removeLoop(int pc) {
+ Iterator<LoopInfo> it = loops.values().iterator();
+ while (it.hasNext()) {
+ if (it.next().isInLoop(pc)) {
+ it.remove();
+ }
+ }
+ }
+
static class LoopInfo
{
- private int start;
- private int end;
+ private final int start;
+ private final int end;
private int addPC;
- private Map<Integer, Integer> conditionalRanges = new HashMap<Integer, Integer>();
public LoopInfo(int loopStart, int loopEnd)
{
@@ -381,33 +381,12 @@
end = loopEnd;
addPC = 0;
}
-
- public void addConditionalRange(int condStart, int condEnd)
+
+ public boolean isInLoop(int pc)
{
- conditionalRanges.put(Integer14.valueOf(condStart), Integer14.valueOf(condEnd));
+ return ((pc >= start) && (pc <= end));
}
- public boolean inConditionalRange(int pc) {
- for (Map.Entry<Integer, Integer> entry : conditionalRanges.entrySet())
- {
- if ((pc >= entry.getKey().intValue()) && pc <= entry.getValue().intValue())
- return true;
- }
-
- return false;
- }
-
- public boolean isInLoop(int pc, boolean ignoreConditionals)
- {
- if ((pc < start) || (pc > end))
- return false;
-
- if (ignoreConditionals)
- return true;
-
- return !inConditionalRange(pc);
- }
-
public void foundAdd(int pc) {
if (addPC == 0)
addPC = pc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|