Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [625] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-09-03 20:51:03
|
Revision: 625 http://svn.sourceforge.net/fb-contrib/?rev=625&view=rev Author: dbrosius Date: 2006-09-03 13:50:45 -0700 (Sun, 03 Sep 2006) Log Message: ----------- filter out tricky false positives due to trinaries in ISB Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2006-08-27 00:47:59 UTC (rev 624) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2006-09-03 20:50:45 UTC (rev 625) @@ -99,18 +99,22 @@ || "java/lang/StringBuilder".equals(calledClass)) && "append".equals(getNameConstantOperand()) && getSigConstantOperand().startsWith("(Ljava/lang/String;)")) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - Object cons = itm.getConstant(); - if ((cons instanceof String) && (itm.getRegisterNumber() < 0)) { - if (((String)cons).length() == 0) { - bugReporter.reportBug( - new BugInstance(this, "ISB_EMPTY_STRING_APPENDING", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } + if (stack.getStackDepth() > 1) { + OpcodeStack.Item sbItm = stack.getStackItem(1); + if ((sbItm != null) && (sbItm.getUserValue() == null)) + { + OpcodeStack.Item itm = stack.getStackItem(0); + Object cons = itm.getConstant(); + if ((cons instanceof String) && (itm.getRegisterNumber() < 0)) { + if (((String)cons).length() == 0) { + bugReporter.reportBug( + new BugInstance(this, "ISB_EMPTY_STRING_APPENDING", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-01-03 22:55:40
|
Revision: 766 http://svn.sourceforge.net/fb-contrib/?rev=766&view=rev Author: dbrosius Date: 2007-01-03 14:55:37 -0800 (Wed, 03 Jan 2007) Log Message: ----------- Bug 1626633: visitCode(obj) needs to call super.visitCode(obj) not, super.visit(obj) Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-01-02 18:24:44 UTC (rev 765) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-01-03 22:55:37 UTC (rev 766) @@ -69,7 +69,7 @@ if (obj.getCode() != null) { stack.resetForMethodEntry(this); sawLDCEmpty = false; - super.visit(obj); + super.visitCode(obj); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-17 07:43:47
|
Revision: 861 http://svn.sourceforge.net/fb-contrib/?rev=861&view=rev Author: dbrosius Date: 2007-02-16 23:43:47 -0800 (Fri, 16 Feb 2007) Log Message: ----------- revert - that was a disaster Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-17 06:41:09 UTC (rev 860) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-17 07:43:47 UTC (rev 861) @@ -75,11 +75,25 @@ @Override public void sawOpcode(final int seen) { - boolean markAsSBToString = false; try { stack.mergeJumps(this); - if (seen == INVOKEVIRTUAL) { + if (seen == INVOKESPECIAL) { + String calledClass = getClassConstantOperand(); + if (("java/lang/StringBuffer".equals(calledClass) + || "java/lang/StringBuilder".equals(calledClass)) + && "<init>".equals(getNameConstantOperand()) + && "()V".equals(getSigConstantOperand())) { + OpcodeStack.Item itm = getStringBufferItemAt(2); + if ((itm != null) && (itm.getUserValue() == null)) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } else if (seen == INVOKEVIRTUAL) { if (sawLDCEmpty) { String calledClass = getClassConstantOperand(); if (("java/lang/StringBuffer".equals(calledClass) @@ -104,52 +118,12 @@ } } } - } else { - String calledClass = getClassConstantOperand(); - if (("java/lang/StringBuffer".equals(calledClass) - || "java/lang/StringBuilder".equals(calledClass))) { - if (("toString".equals(getNameConstantOperand()) - && "()Ljava/lang/String;".equals(getSigConstantOperand()))) { - markAsSBToString = true; - } else if (("append".equals(getNameConstantOperand()) - && (("(Ljava/lang/String;)L" + calledClass + ";").equals(getSigConstantOperand())))) { - if (stack.getStackDepth() > 1) { - OpcodeStack.Item itm = stack.getStackItem(0); - Boolean sbVal = (Boolean)itm.getUserValue(); - if ((sbVal != null) && sbVal.booleanValue()) { - bugReporter.reportBug( - new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } - } } - } else if (seen == INVOKESPECIAL) { - String calledClass = getClassConstantOperand(); - if (("java/lang/StringBuffer".equals(calledClass) - || "java/lang/StringBuilder".equals(calledClass)) - && "<init>".equals(getNameConstantOperand()) - && "(Ljava/lang/String;)V".equals(getSigConstantOperand())) { - if (stack.getStackDepth() > 1) { - OpcodeStack.Item itm = stack.getStackItem(0); - Boolean sbVal = (Boolean)itm.getUserValue(); - if ((sbVal != null) && sbVal.booleanValue()) { - bugReporter.reportBug( - new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } } else if (seen == GOTO) { int depth = stack.getStackDepth(); for (int i = 0; i < depth; i++) { OpcodeStack.Item itm = stack.getStackItem(i); - itm.setUserValue(Boolean.FALSE); + itm.setUserValue(Boolean.TRUE); } } else if (seen == LDC) { Constant c = getConstantRefOperand(); @@ -161,12 +135,6 @@ } } finally { stack.sawOpcode(this, seen); - if (markAsSBToString) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - itm.setUserValue(Boolean.TRUE); - } - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-17 08:20:21
|
Revision: 862 http://svn.sourceforge.net/fb-contrib/?rev=862&view=rev Author: dbrosius Date: 2007-02-17 00:20:21 -0800 (Sat, 17 Feb 2007) Log Message: ----------- attempt #2: fix fp sb.append(ISB_Sample.getBigger(a + b, d)); Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-17 07:43:47 UTC (rev 861) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-17 08:20:21 UTC (rev 862) @@ -75,6 +75,7 @@ @Override public void sawOpcode(final int seen) { + Boolean nestedSB = null; try { stack.mergeJumps(this); @@ -85,12 +86,8 @@ && "<init>".equals(getNameConstantOperand()) && "()V".equals(getSigConstantOperand())) { OpcodeStack.Item itm = getStringBufferItemAt(2); - if ((itm != null) && (itm.getUserValue() == null)) { - bugReporter.reportBug( - new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + if (itm != null) { + nestedSB = Boolean.TRUE; } } } else if (seen == INVOKEVIRTUAL) { @@ -119,11 +116,36 @@ } } } + String calledClass = getClassConstantOperand(); + if (("java/lang/StringBuffer".equals(calledClass) + || "java/lang/StringBuilder".equals(calledClass))) { + String methodName = getNameConstantOperand(); + if ("append".equals(methodName)) { + OpcodeStack.Item itm = getStringBufferItemAt(1); + nestedSB = (itm == null) ? null : (Boolean)itm.getUserValue(); + + if (stack.getStackDepth() > 0) { + itm = stack.getStackItem(0); + if (itm.getUserValue() != null) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + + } + } + } else if ("toString".equals(methodName)) { + OpcodeStack.Item itm = getStringBufferItemAt(0); + nestedSB = (itm == null) ? null : (Boolean)itm.getUserValue(); + } + } + } else if (seen == GOTO) { int depth = stack.getStackDepth(); for (int i = 0; i < depth; i++) { OpcodeStack.Item itm = stack.getStackItem(i); - itm.setUserValue(Boolean.TRUE); + itm.setUserValue(Boolean.FALSE); } } else if (seen == LDC) { Constant c = getConstantRefOperand(); @@ -135,6 +157,12 @@ } } finally { stack.sawOpcode(this, seen); + if (nestedSB != null) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + itm.setUserValue(nestedSB); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-19 01:52:10
|
Revision: 915 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=915&view=rev Author: dbrosius Date: 2007-09-18 18:52:13 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Look for new StringBuffer(a + "1") Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 01:40:44 UTC (rev 914) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 01:52:13 UTC (rev 915) @@ -88,6 +88,11 @@ OpcodeStack.Item itm = getStringBufferItemAt(2); if (itm != null) { nestedSB = Boolean.TRUE; + } else { + itm = getStringBufferItemAt(1); + if (itm != null) { + nestedSB = Boolean.TRUE; + } } } } else if (seen == INVOKEVIRTUAL) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-19 04:45:52
|
Revision: 916 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=916&view=rev Author: dbrosius Date: 2007-09-18 21:45:54 -0700 (Tue, 18 Sep 2007) Log Message: ----------- find new StringBuilder(a + "1") Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 01:52:13 UTC (rev 915) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 04:45:54 UTC (rev 916) @@ -81,18 +81,27 @@ if (seen == INVOKESPECIAL) { String calledClass = getClassConstantOperand(); + String signature = getSigConstantOperand(); if (("java/lang/StringBuffer".equals(calledClass) || "java/lang/StringBuilder".equals(calledClass)) - && "<init>".equals(getNameConstantOperand()) - && "()V".equals(getSigConstantOperand())) { - OpcodeStack.Item itm = getStringBufferItemAt(2); - if (itm != null) { - nestedSB = Boolean.TRUE; - } else { - itm = getStringBufferItemAt(1); + && "<init>".equals(getNameConstantOperand())) { + if ("()V".equals(signature)) { + OpcodeStack.Item itm = getStringBufferItemAt(2); if (itm != null) { nestedSB = Boolean.TRUE; } + } else if ("(Ljava/lang/String;)V".equals(signature)) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + nestedSB = (Boolean)itm.getUserValue(); + if (nestedSB != null) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } } } else if (seen == INVOKEVIRTUAL) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-09-19 05:03:25
|
Revision: 917 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=917&view=rev Author: dbrosius Date: 2007-09-18 22:03:28 -0700 (Tue, 18 Sep 2007) Log Message: ----------- It's not good enough to find the nestedSB useritem, the value has to be true (TRINARY fix) Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 04:45:54 UTC (rev 916) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-09-19 05:03:28 UTC (rev 917) @@ -94,7 +94,7 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); nestedSB = (Boolean)itm.getUserValue(); - if (nestedSB != null) { + if ((nestedSB != null) && nestedSB.booleanValue()) { bugReporter.reportBug( new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", NORMAL_PRIORITY) .addClass(this) @@ -140,7 +140,8 @@ if (stack.getStackDepth() > 0) { itm = stack.getStackItem(0); - if (itm.getUserValue() != null) { + Boolean uValue = (Boolean)itm.getUserValue(); + if ((uValue != null) && uValue.booleanValue()) { bugReporter.reportBug( new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) .addClass(this) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |