Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [697] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2006-11-30 06:05:11
|
Revision: 697
http://svn.sourceforge.net/fb-contrib/?rev=697&view=rev
Author: dbrosius
Date: 2006-11-29 22:05:11 -0800 (Wed, 29 Nov 2006)
Log Message:
-----------
initial checkin BAS
Added Paths:
-----------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-11-30 06:05:11 UTC (rev 697)
@@ -0,0 +1,77 @@
+package com.mebigfatguy.fbcontrib.detect;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.bcel.classfile.Code;
+
+import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.BytecodeScanningDetector;
+import edu.umd.cs.findbugs.ba.ClassContext;
+
+/**
+ * looks for variable assignments at a scope larger than its use. In this case,
+ * the assignment can be pushed down into the smaller scope to reduce the performance
+ * impact of that assignment.
+ */
+public class BloatedAssignmentScope extends BytecodeScanningDetector
+{
+ private BugReporter bugReporter;
+ private Map<Integer, Integer> regToLocationMap;
+ private Map<Integer, Integer> scopeBlockMap;
+
+ /**
+ * constructs a BLT detector given the reporter to report bugs on
+
+ * @param bugReporter the sync of bug reports
+ */
+ public BloatedAssignmentScope(BugReporter bugReporter) {
+ this.bugReporter = bugReporter;
+ }
+
+ /**
+ * implements the visitor to create and the clear the register to location map
+ *
+ * @param classContext the context object of the currently parsed class
+ */
+ @Override
+ public void visitClassContext(ClassContext classContext) {
+ try {
+ regToLocationMap = new HashMap<Integer, Integer>();
+ scopeBlockMap = new HashMap<Integer, Integer>();
+ super.visitClassContext(classContext);
+ } finally {
+ regToLocationMap = null;
+ scopeBlockMap = null;
+ }
+ }
+
+ /**
+ * implements the visitor to reset the register to location map
+ *
+ * @param obj the context object of the currently parsed code block
+ */
+ @Override
+ public void visitCode(Code obj) {
+ regToLocationMap.clear();
+ scopeBlockMap.clear();
+ super.visitCode(obj);
+ }
+
+ /**
+ * implements the visitor to look for variables assigned out side of the scope
+ * in which they are used.
+ *
+ * @param seen the opcode of the currently parsed instruction
+ */
+ @Override
+ public void sawOpcode(int seen) {
+ if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) {
+ int reg = RegisterUtils.getAStoreReg(this, seen);
+ } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) {
+ int reg = RegisterUtils.getALoadReg(this, seen);
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-03 10:21:19
|
Revision: 700
http://svn.sourceforge.net/fb-contrib/?rev=700&view=rev
Author: dbrosius
Date: 2006-12-03 02:21:09 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
if a scope block target is the same as another block it must be a compound conditional, so merge the blocks, and move already recorded load stores to the parent
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 09:52:26 UTC (rev 699)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 10:21:09 UTC (rev 700)
@@ -133,8 +133,13 @@
} else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) {
int target = getBranchTarget();
if (target > getPC()) {
- ScopeBlock sb = new ScopeBlock(getPC(), target);
- rootScopeBlock.addChild(sb);
+ ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, target);
+ if (sb != null) {
+ sb.pushUpLoadStores();
+ } else {
+ sb = new ScopeBlock(getPC(), target);
+ rootScopeBlock.addChild(sb);
+ }
} else {
ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC());
if (sb != null)
@@ -164,11 +169,36 @@
}
return null;
}
+
+ /**
+ * returns an existing scope block that has the same target as the one looked for
+ *
+ * @param sb the scope block to start with
+ * @param target the target to look for
+ *
+ * @return the scope block found or null
+ */
+ private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int target) {
+ if (sb.finishLocation == target)
+ return sb;
+ if (sb.children != null)
+ {
+ for (ScopeBlock child : sb.children) {
+ ScopeBlock targetBlock = findScopeBlockWithTarget(child, target);
+ if (targetBlock != null)
+ return targetBlock;
+ }
+ }
+
+ return null;
+ }
+
/** holds the description of a scope { } block, be it a for, if, while block
*/
private class ScopeBlock
{
+ private ScopeBlock parent;
private int startLocation;
private int finishLocation;
private boolean isLoop;
@@ -182,6 +212,7 @@
* @param finish the end of the block
*/
public ScopeBlock(int start, int finish) {
+ parent = null;
startLocation = start;
finishLocation = finish;
isLoop = false;
@@ -254,6 +285,8 @@
* @param child the scope block to add to the tree
*/
public void addChild(ScopeBlock newChild) {
+ newChild.parent = this;
+
if (children != null) {
for (ScopeBlock child : children) {
if ((newChild.startLocation > child.startLocation) && (newChild.finishLocation < child.finishLocation)) {
@@ -339,5 +372,27 @@
return false;
}
+
+ /**
+ * push all loads and stores to this block up to the parent
+ */
+ public void pushUpLoadStores() {
+ if (parent != null) {
+ if (loads != null) {
+ if (parent.loads != null)
+ parent.loads.putAll(loads);
+ else
+ parent.loads = loads;
+ }
+ if (stores != null) {
+ if (parent.stores != null)
+ parent.stores.putAll(stores);
+ else
+ parent.stores = stores;
+ }
+ loads = null;
+ stores = null;
+ }
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-03 10:21:51
|
Revision: 701
http://svn.sourceforge.net/fb-contrib/?rev=701&view=rev
Author: dbrosius
Date: 2006-12-03 02:21:49 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
remove unused
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 10:21:09 UTC (rev 700)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 10:21:49 UTC (rev 701)
@@ -25,7 +25,6 @@
public class BloatedAssignmentScope extends BytecodeScanningDetector
{
BugReporter bugReporter;
- private Map<Integer, Integer> regToLocationMap;
private Set<Integer> ignoreRegs;
private ScopeBlock rootScopeBlock;
@@ -46,11 +45,9 @@
@Override
public void visitClassContext(ClassContext classContext) {
try {
- regToLocationMap = new HashMap<Integer, Integer>();
ignoreRegs = new HashSet<Integer>();
super.visitClassContext(classContext);
} finally {
- regToLocationMap = null;
ignoreRegs = null;
}
}
@@ -64,7 +61,6 @@
public void visitCode(Code obj) {
try {
- regToLocationMap.clear();
ignoreRegs.clear();
Method method = getMethod();
if (!method.isStatic())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-03 10:42:29
|
Revision: 702
http://svn.sourceforge.net/fb-contrib/?rev=702&view=rev
Author: dbrosius
Date: 2006-12-03 02:42:28 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
if a block starts and ends after another block, THAT is when it is part of a compound condition, in which case combine the two blocks, and push the load and stores up to the parent
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 10:21:49 UTC (rev 701)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 10:42:28 UTC (rev 702)
@@ -129,7 +129,7 @@
} else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) {
int target = getBranchTarget();
if (target > getPC()) {
- ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, target);
+ ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
if (sb != null) {
sb.pushUpLoadStores();
} else {
@@ -174,14 +174,14 @@
*
* @return the scope block found or null
*/
- private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int target) {
- if (sb.finishLocation == target)
+ private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start, int target) {
+ if ((sb.startLocation < start) && (sb.finishLocation <= target))
return sb;
if (sb.children != null)
{
for (ScopeBlock child : sb.children) {
- ScopeBlock targetBlock = findScopeBlockWithTarget(child, target);
+ ScopeBlock targetBlock = findScopeBlockWithTarget(child, start, target);
if (targetBlock != null)
return targetBlock;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-03 16:49:48
|
Revision: 703
http://svn.sourceforge.net/fb-contrib/?rev=703&view=rev
Author: dbrosius
Date: 2006-12-03 08:49:37 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
forward branching GOTO or GOTO_W's shouldn't be considered scope definitions
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 10:42:28 UTC (rev 702)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 16:49:37 UTC (rev 703)
@@ -129,6 +129,9 @@
} else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) {
int target = getBranchTarget();
if (target > getPC()) {
+ if ((seen == GOTO) || (seen == GOTO_W))
+ return;
+
ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
if (sb != null) {
sb.pushUpLoadStores();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-03 17:18:05
|
Revision: 704
http://svn.sourceforge.net/fb-contrib/?rev=704&view=rev
Author: dbrosius
Date: 2006-12-03 09:17:52 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
handle elseif's correctly
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 16:49:37 UTC (rev 703)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 17:17:52 UTC (rev 704)
@@ -129,16 +129,21 @@
} else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) {
int target = getBranchTarget();
if (target > getPC()) {
- if ((seen == GOTO) || (seen == GOTO_W))
- return;
-
- ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
- if (sb != null) {
- sb.pushUpLoadStores();
- } else {
- sb = new ScopeBlock(getPC(), target);
- rootScopeBlock.addChild(sb);
- }
+ if ((seen == GOTO) || (seen == GOTO_W)) {
+ ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), getNextPC());
+ if (sb != null) {
+ sb = new ScopeBlock(getPC(), target);
+ rootScopeBlock.addChild(sb);
+ }
+ } else {
+ ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
+ if (sb != null) {
+ sb.pushUpLoadStores();
+ } else {
+ sb = new ScopeBlock(getPC(), target);
+ rootScopeBlock.addChild(sb);
+ }
+ }
} else {
ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC());
if (sb != null)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-04 00:45:56
|
Revision: 706
http://svn.sourceforge.net/fb-contrib/?rev=706&view=rev
Author: dbrosius
Date: 2006-12-03 16:45:50 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
forward branching gotos not associated with elseifs, are treated as loops
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 17:25:11 UTC (rev 705)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 00:45:50 UTC (rev 706)
@@ -134,6 +134,10 @@
if (sb != null) {
sb = new ScopeBlock(getPC(), target);
rootScopeBlock.addChild(sb);
+ } else {
+ sb = new ScopeBlock(getPC(), target);
+ sb.setLoop();
+ rootScopeBlock.addChild(sb);
}
} else {
ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-04 02:30:27
|
Revision: 707
http://svn.sourceforge.net/fb-contrib/?rev=707&view=rev
Author: dbrosius
Date: 2006-12-03 18:30:27 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
fix findScopeBlock
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 00:45:50 UTC (rev 706)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 02:30:27 UTC (rev 707)
@@ -168,9 +168,9 @@
if ((pc > sb.getStart()) && (pc < sb.getFinish())) {
if (sb.children != null) {
for (ScopeBlock child : sb.children) {
- sb = findScopeBlock(child, pc);
- if (sb != null)
- return sb;
+ ScopeBlock foundSb = findScopeBlock(child, pc);
+ if (foundSb != null)
+ return foundSb;
}
}
return sb;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-04 04:46:36
|
Revision: 709
http://svn.sourceforge.net/fb-contrib/?rev=709&view=rev
Author: dbrosius
Date: 2006-12-03 20:46:31 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
fix case where if statement immediately follows a loop.
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 02:38:36 UTC (rev 708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 04:46:31 UTC (rev 709)
@@ -141,7 +141,7 @@
}
} else {
ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
- if (sb != null) {
+ if ((sb != null) && (!sb.isLoop)) {
sb.pushUpLoadStores();
} else {
sb = new ScopeBlock(getPC(), target);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-04 05:34:27
|
Revision: 710
http://svn.sourceforge.net/fb-contrib/?rev=710&view=rev
Author: dbrosius
Date: 2006-12-03 21:34:26 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
if a compound if test is found, update the scope block range
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 04:46:31 UTC (rev 709)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 05:34:26 UTC (rev 710)
@@ -143,6 +143,8 @@
ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
if ((sb != null) && (!sb.isLoop)) {
sb.pushUpLoadStores();
+ sb.startLocation = getPC();
+ sb.finishLocation = target;
} else {
sb = new ScopeBlock(getPC(), target);
rootScopeBlock.addChild(sb);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-08 16:12:03
|
Revision: 711
http://svn.sourceforge.net/fb-contrib/?rev=711&view=rev
Author: dbrosius
Date: 2006-12-08 08:11:06 -0800 (Fri, 08 Dec 2006)
Log Message:
-----------
don't push up scope blocks, believing that the block is a complex conditional guard if the block in question already has children
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 05:34:26 UTC (rev 710)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-08 16:11:06 UTC (rev 711)
@@ -141,10 +141,10 @@
}
} else {
ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
- if ((sb != null) && (!sb.isLoop)) {
+ if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) {
sb.pushUpLoadStores();
- sb.startLocation = getPC();
- sb.finishLocation = target;
+ sb.setStart(getPC());
+ sb.setFinish(target);
} else {
sb = new ScopeBlock(getPC(), target);
rootScopeBlock.addChild(sb);
@@ -255,7 +255,26 @@
public int getFinish() {
return finishLocation;
}
+
+ /**
+ * sets the start pc of the block
+ * @param start the start pc
+ */
+ public void setStart(int start) {
+ startLocation = start;
+ }
+
+ /**
+ * sets the finish pc of the block
+ * @param finish the finish pc
+ */
+ public void setFinish(int finish) {
+ finishLocation = finish;
+ }
+ public boolean hasChildren() {
+ return children != null;
+ }
/**
* sets that this block is a loop
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-10 04:13:14
|
Revision: 714
http://svn.sourceforge.net/fb-contrib/?rev=714&view=rev
Author: dbrosius
Date: 2006-12-09 20:13:12 -0800 (Sat, 09 Dec 2006)
Log Message:
-----------
add copyright
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-09 00:00:18 UTC (rev 713)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-10 04:13:12 UTC (rev 714)
@@ -1,3 +1,21 @@
+/*
+ * fb-contrib - Auxilliary detectors for Java programs
+ * Copyright (C) 2005-2006 Dave Brosius
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
package com.mebigfatguy.fbcontrib.detect;
import java.util.ArrayList;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-10 09:14:44
|
Revision: 718
http://svn.sourceforge.net/fb-contrib/?rev=718&view=rev
Author: dbrosius
Date: 2006-12-10 01:14:38 -0800 (Sun, 10 Dec 2006)
Log Message:
-----------
don't create a scope block on a GOTO at the end of an if block (before an else)
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-10 07:16:06 UTC (rev 717)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-10 09:14:38 UTC (rev 718)
@@ -149,11 +149,8 @@
if (target > getPC()) {
if ((seen == GOTO) || (seen == GOTO_W)) {
ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), getNextPC());
- if (sb != null) {
+ if (sb == null) {
sb = new ScopeBlock(getPC(), target);
- rootScopeBlock.addChild(sb);
- } else {
- sb = new ScopeBlock(getPC(), target);
sb.setLoop();
rootScopeBlock.addChild(sb);
}
@@ -207,7 +204,7 @@
* @return the scope block found or null
*/
private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start, int target) {
- if ((sb.startLocation < start) && (sb.finishLocation <= target))
+ if ((sb.startLocation < start) && (sb.finishLocation >= start) && (sb.finishLocation <= target))
return sb;
if (sb.children != null)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-10 09:25:19
|
Revision: 719
http://svn.sourceforge.net/fb-contrib/?rev=719&view=rev
Author: dbrosius
Date: 2006-12-10 01:25:19 -0800 (Sun, 10 Dec 2006)
Log Message:
-----------
the ResultSet.wasNull method is problematic, so if a method uses it, don't report.
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-10 09:14:38 UTC (rev 718)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-10 09:25:19 UTC (rev 719)
@@ -45,6 +45,7 @@
BugReporter bugReporter;
private Set<Integer> ignoreRegs;
private ScopeBlock rootScopeBlock;
+ private boolean dontReport;
/**
* constructs a BAS detector given the reporter to report bugs on
@@ -90,9 +91,11 @@
}
rootScopeBlock = new ScopeBlock(0, obj.getLength());
+ dontReport = false;
super.visitCode(obj);
- rootScopeBlock.findBugs();
+ if (!dontReport)
+ rootScopeBlock.findBugs();
} finally {
rootScopeBlock = null;
@@ -170,7 +173,11 @@
if (sb != null)
sb.setLoop();
}
- }
+ } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEVIRTUAL)) {
+ if ("wasNull".equals(getNameConstantOperand())
+ && "()Z".equals(getSigConstantOperand()))
+ dontReport = true;
+ }
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-10 10:18:42
|
Revision: 720
http://svn.sourceforge.net/fb-contrib/?rev=720&view=rev
Author: dbrosius
Date: 2006-12-10 02:18:38 -0800 (Sun, 10 Dec 2006)
Log Message:
-----------
don't report catch block stores
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-10 09:25:19 UTC (rev 719)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-10 10:18:38 UTC (rev 720)
@@ -26,6 +26,7 @@
import java.util.Set;
import org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.CodeException;
import org.apache.bcel.classfile.Method;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
@@ -45,6 +46,7 @@
BugReporter bugReporter;
private Set<Integer> ignoreRegs;
private ScopeBlock rootScopeBlock;
+ private Set<Integer> catchHandlers;
private boolean dontReport;
/**
@@ -65,9 +67,11 @@
public void visitClassContext(ClassContext classContext) {
try {
ignoreRegs = new HashSet<Integer>();
+ catchHandlers = new HashSet<Integer>();
super.visitClassContext(classContext);
} finally {
ignoreRegs = null;
+ catchHandlers = null;
}
}
@@ -91,6 +95,15 @@
}
rootScopeBlock = new ScopeBlock(0, obj.getLength());
+ catchHandlers.clear();
+ CodeException[] exceptions = obj.getExceptionTable();
+ if (exceptions != null) {
+ for (CodeException ex : exceptions) {
+ catchHandlers.add(Integer.valueOf(ex.getHandlerPC()));
+ }
+ }
+
+
dontReport = false;
super.visitCode(obj);
@@ -121,12 +134,15 @@
|| ((seen >= FSTORE_0) && (seen <= FSTORE_1))
|| ((seen >= DSTORE_0) && (seen <= DSTORE_1))) {
int reg = RegisterUtils.getStoreReg(this, seen);
- if (!ignoreRegs.contains(Integer.valueOf(reg))) {
+ Integer iReg = Integer.valueOf(reg);
+ if (catchHandlers.contains(getPC()))
+ ignoreRegs.add(iReg);
+ if (!ignoreRegs.contains(iReg)) {
ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC());
if (sb != null)
sb.addStore(reg, getPC());
else
- ignoreRegs.add(Integer.valueOf(reg));
+ ignoreRegs.add(iReg);
}
} else if ((seen == ALOAD)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-12 07:43:05
|
Revision: 722
http://svn.sourceforge.net/fb-contrib/?rev=722&view=rev
Author: dbrosius
Date: 2006-12-11 23:36:16 -0800 (Mon, 11 Dec 2006)
Log Message:
-----------
create a scope block for the end of if block goto temporarily, so that an unguarded else is blocked. But if a scope block is found to this goto block, then remove it, as we've found an else if
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-12 04:35:24 UTC (rev 721)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-12 07:36:16 UTC (rev 722)
@@ -171,14 +171,27 @@
if (sb == null) {
sb = new ScopeBlock(getPC(), target);
sb.setLoop();
+ sb.setGoto();
rootScopeBlock.addChild(sb);
+ } else {
+ sb = new ScopeBlock(getPC(), target);
+ sb.setGoto();
+ rootScopeBlock.addChild(sb);
}
} else {
ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) {
- sb.pushUpLoadStores();
- sb.setStart(getPC());
- sb.setFinish(target);
+ if (sb.isGoto()) {
+ ScopeBlock parent = sb.getParent();
+ if (parent != null)
+ parent.removeChild(sb);
+ sb = new ScopeBlock(getPC(), target);
+ rootScopeBlock.addChild(sb);
+ } else {
+ sb.pushUpLoadStores();
+ sb.setStart(getPC());
+ sb.setFinish(target);
+ }
} else {
sb = new ScopeBlock(getPC(), target);
rootScopeBlock.addChild(sb);
@@ -227,8 +240,10 @@
* @return the scope block found or null
*/
private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start, int target) {
- if ((sb.startLocation < start) && (sb.finishLocation >= start) && (sb.finishLocation <= target))
- return sb;
+ if ((sb.startLocation < start) && (sb.finishLocation >= start)) {
+ if ((sb.finishLocation <= target) || (sb.isGoto() && !sb.isLoop()))
+ return sb;
+ }
if (sb.children != null)
{
@@ -250,6 +265,7 @@
private int startLocation;
private int finishLocation;
private boolean isLoop;
+ private boolean isGoto;
private Map<Integer, Integer> loads;
private Map<Integer, Integer> stores;
private List<ScopeBlock> children;
@@ -264,6 +280,7 @@
startLocation = start;
finishLocation = finish;
isLoop = false;
+ isGoto = false;
loads = null;
stores = null;
children = null;
@@ -278,6 +295,15 @@
return "Start=" + startLocation + " Finish=" + finishLocation + " Loop=" + isLoop + " Loads=" + loads + " Stores=" + stores;
}
+ /**
+ * returns the scope blocks parent
+ *
+ * @return the parent of this scope block
+ */
+ public ScopeBlock getParent() {
+ return parent;
+ }
+
/** returns the start of the block
*
* @return the start of the block
@@ -319,6 +345,31 @@
public void setLoop() {
isLoop = true;
}
+
+ /**
+ * returns whether this scope block is a loop
+ *
+ * @returns whether this block is a loop
+ */
+ public boolean isLoop() {
+ return isLoop;
+ }
+
+ /**
+ * sets that this block was caused from a goto, (an if block exit)
+ */
+ public void setGoto() {
+ isGoto = true;
+ }
+
+ /**
+ * returns whether this block was caused from a goto
+ *
+ * @returns whether this block was caused by a goto
+ */
+ public boolean isGoto() {
+ return isGoto;
+ }
/**
* adds the register as a store in this scope block
@@ -376,6 +427,15 @@
children.add(newChild);
}
+ /**
+ * removes a child from this node
+ * @param child the child to remove
+ */
+ public void removeChild(ScopeBlock child) {
+ if (children != null)
+ children.remove(child);
+ }
+
/**
* report stores that occur at scopes higher than associated loads that are not involved with loops
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-12 07:58:25
|
Revision: 723
http://svn.sourceforge.net/fb-contrib/?rev=723&view=rev
Author: dbrosius
Date: 2006-12-11 23:50:42 -0800 (Mon, 11 Dec 2006)
Log Message:
-----------
if a dup occurs before a store, assume it's a load as well.
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-12 07:36:16 UTC (rev 722)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-12 07:50:42 UTC (rev 723)
@@ -48,6 +48,7 @@
private ScopeBlock rootScopeBlock;
private Set<Integer> catchHandlers;
private boolean dontReport;
+ private boolean sawDup;
/**
* constructs a BAS detector given the reporter to report bugs on
@@ -105,6 +106,7 @@
dontReport = false;
+ sawDup = false;
super.visitCode(obj);
if (!dontReport)
@@ -135,16 +137,19 @@
|| ((seen >= DSTORE_0) && (seen <= DSTORE_1))) {
int reg = RegisterUtils.getStoreReg(this, seen);
Integer iReg = Integer.valueOf(reg);
- if (catchHandlers.contains(getPC()))
+ int pc = getPC();
+ if (catchHandlers.contains(pc))
ignoreRegs.add(iReg);
if (!ignoreRegs.contains(iReg)) {
- ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC());
- if (sb != null)
- sb.addStore(reg, getPC());
+ ScopeBlock sb = findScopeBlock(rootScopeBlock, pc);
+ if (sb != null) {
+ sb.addStore(reg, pc);
+ if (sawDup)
+ sb.addLoad(reg, pc);
+ }
else
ignoreRegs.add(iReg);
}
-
} else if ((seen == ALOAD)
|| (seen == ILOAD)
|| (seen == LLOAD)
@@ -206,7 +211,9 @@
if ("wasNull".equals(getNameConstantOperand())
&& "()Z".equals(getSigConstantOperand()))
dontReport = true;
- }
+ }
+
+ sawDup = (seen == DUP);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-13 04:40:05
|
Revision: 725
http://svn.sourceforge.net/fb-contrib/?rev=725&view=rev
Author: dbrosius
Date: 2006-12-12 20:40:01 -0800 (Tue, 12 Dec 2006)
Log Message:
-----------
add switch blocks as scope blocks, don't add the goto's at the end of the case blocks.
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-12 15:17:26 UTC (rev 724)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-13 04:40:01 UTC (rev 725)
@@ -19,6 +19,7 @@
package com.mebigfatguy.fbcontrib.detect;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -47,6 +48,7 @@
private Set<Integer> ignoreRegs;
private ScopeBlock rootScopeBlock;
private Set<Integer> catchHandlers;
+ private Set<Integer> switchTargets;
private boolean dontReport;
private boolean sawDup;
@@ -69,10 +71,12 @@
try {
ignoreRegs = new HashSet<Integer>();
catchHandlers = new HashSet<Integer>();
+ switchTargets = new HashSet<Integer>();
super.visitClassContext(classContext);
} finally {
ignoreRegs = null;
catchHandlers = null;
+ switchTargets = null;
}
}
@@ -104,7 +108,7 @@
}
}
-
+ switchTargets.clear();
dontReport = false;
sawDup = false;
super.visitCode(obj);
@@ -172,17 +176,20 @@
int target = getBranchTarget();
if (target > getPC()) {
if ((seen == GOTO) || (seen == GOTO_W)) {
- ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), getNextPC());
- if (sb == null) {
- sb = new ScopeBlock(getPC(), target);
- sb.setLoop();
- sb.setGoto();
- rootScopeBlock.addChild(sb);
- } else {
- sb = new ScopeBlock(getPC(), target);
- sb.setGoto();
- rootScopeBlock.addChild(sb);
- }
+ Integer nextPC = Integer.valueOf(getNextPC());
+ if (!switchTargets.contains(nextPC)) {
+ ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), getNextPC());
+ if (sb == null) {
+ sb = new ScopeBlock(getPC(), target);
+ sb.setLoop();
+ sb.setGoto();
+ rootScopeBlock.addChild(sb);
+ } else {
+ sb = new ScopeBlock(getPC(), target);
+ sb.setGoto();
+ rootScopeBlock.addChild(sb);
+ }
+ }
} else {
ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target);
if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) {
@@ -207,6 +214,25 @@
if (sb != null)
sb.setLoop();
}
+ } else if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) {
+ int pc = getPC();
+ int[] offsets = getSwitchOffsets();
+ List<Integer> targets = new ArrayList<Integer>();
+ for (int i = 0; i < offsets.length; i++)
+ targets.add(Integer.valueOf(offsets[i] + pc));
+ Integer defOffset = Integer.valueOf(getDefaultSwitchOffset() + pc);
+ if (!targets.contains(defOffset))
+ targets.add(defOffset);
+ Collections.sort(targets);
+
+ Integer lastTarget = targets.get(0);
+ for (int i = 1; i < targets.size(); i++) {
+ Integer nextTarget = targets.get(i);
+ ScopeBlock sb = new ScopeBlock(lastTarget.intValue(), nextTarget.intValue());
+ rootScopeBlock.addChild(sb);
+ lastTarget = nextTarget;
+ }
+ switchTargets.addAll(targets);
} else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEVIRTUAL)) {
if ("wasNull".equals(getNameConstantOperand())
&& "()Z".equals(getSigConstantOperand()))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-14 06:40:37
|
Revision: 729
http://svn.sourceforge.net/fb-contrib/?rev=729&view=rev
Author: dbrosius
Date: 2006-12-13 22:40:36 -0800 (Wed, 13 Dec 2006)
Log Message:
-----------
When looking for a scope block with target, if one is found, don't automatically return it, but look for smaller children first.
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-14 00:05:21 UTC (rev 728)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-14 06:40:36 UTC (rev 729)
@@ -273,9 +273,10 @@
* @return the scope block found or null
*/
private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start, int target) {
+ ScopeBlock parentBlock = null;
if ((sb.startLocation < start) && (sb.finishLocation >= start)) {
if ((sb.finishLocation <= target) || (sb.isGoto() && !sb.isLoop()))
- return sb;
+ parentBlock = sb;
}
if (sb.children != null)
@@ -287,7 +288,7 @@
}
}
- return null;
+ return parentBlock;
}
/** holds the description of a scope { } block, be it a for, if, while block
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-16 09:06:20
|
Revision: 731
http://svn.sourceforge.net/fb-contrib/?rev=731&view=rev
Author: dbrosius
Date: 2006-12-16 01:06:19 -0800 (Sat, 16 Dec 2006)
Log Message:
-----------
if a variable is used in a parent scope, don't report on it at a child scope.
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-16 07:34:52 UTC (rev 730)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-16 09:06:19 UTC (rev 731)
@@ -114,7 +114,7 @@
super.visitCode(obj);
if (!dontReport)
- rootScopeBlock.findBugs();
+ rootScopeBlock.findBugs(new HashSet<Integer>());
} finally {
rootScopeBlock = null;
@@ -473,40 +473,50 @@
/**
* report stores that occur at scopes higher than associated loads that are not involved with loops
*/
- public void findBugs() {
+ public void findBugs(Set<Integer> parentUsedRegs) {
if (isLoop)
return;
+ Set<Integer> usedRegs = new HashSet<Integer>(parentUsedRegs);
+ if (stores != null)
+ usedRegs.addAll(stores.keySet());
+ if (loads != null)
+ usedRegs.addAll(loads.keySet());
+
if (stores != null) {
if (loads != null)
stores.keySet().removeAll(loads.keySet());
+ stores.keySet().removeAll(parentUsedRegs);
- if (children != null) {
- for (Map.Entry<Integer, Integer> entry : stores.entrySet()) {
- int childUseCount = 0;
- boolean inLoop = false;
- for (ScopeBlock child : children) {
- if (child.usesReg(entry.getKey())) {
- if (child.isLoop) {
- inLoop = true;
- break;
- }
- childUseCount++;
- }
- }
- if ((!inLoop) && (childUseCount == 1)) {
- bugReporter.reportBug(new BugInstance(BloatedAssignmentScope.this, "BAS_BLOATED_ASSIGNMENT_SCOPE", NORMAL_PRIORITY)
- .addClass(BloatedAssignmentScope.this)
- .addMethod(BloatedAssignmentScope.this)
- .addSourceLine(BloatedAssignmentScope.this, entry.getValue()));
- }
- }
- }
+ if (stores.size() > 0) {
+ if (children != null) {
+ for (Map.Entry<Integer, Integer> entry : stores.entrySet()) {
+ int childUseCount = 0;
+ boolean inLoop = false;
+ Integer reg = entry.getKey();
+ for (ScopeBlock child : children) {
+ if (child.usesReg(reg)) {
+ if (child.isLoop) {
+ inLoop = true;
+ break;
+ }
+ childUseCount++;
+ }
+ }
+ if ((!inLoop) && (childUseCount == 1)) {
+ bugReporter.reportBug(new BugInstance(BloatedAssignmentScope.this, "BAS_BLOATED_ASSIGNMENT_SCOPE", NORMAL_PRIORITY)
+ .addClass(BloatedAssignmentScope.this)
+ .addMethod(BloatedAssignmentScope.this)
+ .addSourceLine(BloatedAssignmentScope.this, entry.getValue()));
+ }
+ }
+ }
+ }
}
if (children != null) {
for (ScopeBlock child : children) {
- child.findBugs();
+ child.findBugs(usedRegs);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-17 06:39:27
|
Revision: 732
http://svn.sourceforge.net/fb-contrib/?rev=732&view=rev
Author: dbrosius
Date: 2006-12-16 22:32:52 -0800 (Sat, 16 Dec 2006)
Log Message:
-----------
when removing child scopes, always push up the load/stores
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-16 09:06:19 UTC (rev 731)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-17 06:32:52 UTC (rev 732)
@@ -195,6 +195,7 @@
if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) {
if (sb.isGoto()) {
ScopeBlock parent = sb.getParent();
+ sb.pushUpLoadStores();
if (parent != null)
parent.removeChild(sb);
sb = new ScopeBlock(getPC(), target);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-19 13:42:01
|
Revision: 742
http://svn.sourceforge.net/fb-contrib/?rev=742&view=rev
Author: dbrosius
Date: 2006-12-19 05:41:48 -0800 (Tue, 19 Dec 2006)
Log Message:
-----------
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-19 08:25:31 UTC (rev 741)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-19 13:41:48 UTC (rev 742)
@@ -30,6 +30,7 @@
import org.apache.bcel.classfile.CodeException;
import org.apache.bcel.classfile.Method;
+import com.mebigfatguy.fbcontrib.utils.Integer14;
import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
import edu.umd.cs.findbugs.BugInstance;
@@ -142,7 +143,7 @@
int reg = RegisterUtils.getStoreReg(this, seen);
Integer iReg = Integer.valueOf(reg);
int pc = getPC();
- if (catchHandlers.contains(pc))
+ if (catchHandlers.contains(Integer14.valueOf(pc)))
ignoreRegs.add(iReg);
if (!ignoreRegs.contains(iReg)) {
ScopeBlock sb = findScopeBlock(rootScopeBlock, pc);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2006-12-22 21:38:27
|
Revision: 760
http://svn.sourceforge.net/fb-contrib/?rev=760&view=rev
Author: dbrosius
Date: 2006-12-22 13:38:07 -0800 (Fri, 22 Dec 2006)
Log Message:
-----------
avoid autoboxing
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-22 21:37:28 UTC (rev 759)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-22 21:38:07 UTC (rev 760)
@@ -510,7 +510,7 @@
bugReporter.reportBug(new BugInstance(BloatedAssignmentScope.this, "BAS_BLOATED_ASSIGNMENT_SCOPE", NORMAL_PRIORITY)
.addClass(BloatedAssignmentScope.this)
.addMethod(BloatedAssignmentScope.this)
- .addSourceLine(BloatedAssignmentScope.this, entry.getValue()));
+ .addSourceLine(BloatedAssignmentScope.this, entry.getValue().intValue()));
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2007-01-28 05:29:59
|
Revision: 781
http://svn.sourceforge.net/fb-contrib/?rev=781&view=rev
Author: dbrosius
Date: 2007-01-27 21:29:58 -0800 (Sat, 27 Jan 2007)
Log Message:
-----------
experiment with removing null assignments from BAS
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2007-01-27 06:09:09 UTC (rev 780)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2007-01-28 05:29:58 UTC (rev 781)
@@ -52,6 +52,7 @@
private Set<Integer> switchTargets;
private boolean dontReport;
private boolean sawDup;
+ private boolean sawNull;
/**
* constructs a BAS detector given the reporter to report bugs on
@@ -112,6 +113,7 @@
switchTargets.clear();
dontReport = false;
sawDup = false;
+ sawNull = false;
super.visitCode(obj);
if (!dontReport)
@@ -145,6 +147,9 @@
int pc = getPC();
if (catchHandlers.contains(Integer14.valueOf(pc)))
ignoreRegs.add(iReg);
+ if (sawNull) {
+ ignoreRegs.add(iReg);
+ }
if (!ignoreRegs.contains(iReg)) {
ScopeBlock sb = findScopeBlock(rootScopeBlock, pc);
if (sb != null) {
@@ -242,6 +247,7 @@
}
sawDup = (seen == DUP);
+ sawNull = (seen == ACONST_NULL);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2007-01-28 05:30:58
|
Revision: 782
http://svn.sourceforge.net/fb-contrib/?rev=782&view=rev
Author: dbrosius
Date: 2007-01-27 21:30:58 -0800 (Sat, 27 Jan 2007)
Log Message:
-----------
cleaner
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2007-01-28 05:29:58 UTC (rev 781)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2007-01-28 05:30:58 UTC (rev 782)
@@ -147,9 +147,9 @@
int pc = getPC();
if (catchHandlers.contains(Integer14.valueOf(pc)))
ignoreRegs.add(iReg);
- if (sawNull) {
+ else if (sawNull)
ignoreRegs.add(iReg);
- }
+
if (!ignoreRegs.contains(iReg)) {
ScopeBlock sb = findScopeBlock(rootScopeBlock, pc);
if (sb != null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|