[Fb-contrib-commit] fb-contrib/src/com/mebigfatguy/fbcontrib/detect BloatedSynchronizedBlock.java,1.
Brought to you by:
dbrosius
From: Dave B. <dbr...@us...> - 2006-01-02 03:41:15
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26877/src/com/mebigfatguy/fbcontrib/detect Modified Files: BloatedSynchronizedBlock.java Log Message: finding BSB at the end of a synchronized block seems very problematic. For now just look for beginning BSB Index: BloatedSynchronizedBlock.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- BloatedSynchronizedBlock.java 2 Jan 2006 02:48:55 -0000 1.1 +++ BloatedSynchronizedBlock.java 2 Jan 2006 03:41:07 -0000 1.2 @@ -34,7 +34,6 @@ private OpcodeStack stack = new OpcodeStack(); private int syncPC; private int lastPC; - private int startSafe; private boolean isStatic; private int minSafeCodeLength; @@ -69,7 +68,6 @@ else syncPC = -1; stack.resetForMethodEntry(this); - startSafe = 0; lastPC = -1; isStatic = obj.isStatic(); } @@ -82,49 +80,23 @@ */ public void sawOpcode(int seen) { try { - if ("BSB_Sample".equals(getClassName())) - System.out.println(Constants.OPCODE_NAMES[seen]); if (seen == MONITORENTER) { - if (syncPC < 0) { + if (syncPC < 0) syncPC = getPC(); - startSafe = this.getNextPC(); - } } - else if (seen == MONITOREXIT) { - if ((startSafe >= 0) && ((getPC() - startSafe) > minSafeCodeLength)) { - bugReporter.reportBug(new BugInstance(this, "BSB_BLOATED_SYNCHRONIZED_BLOCK", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLineRange(this, startSafe, lastPC)); - } + else if (seen == MONITOREXIT) syncPC = -1; - startSafe = -1; - } - else { + else if (syncPC >= 0) { boolean unsafe = ((seen == PUTFIELD) || (seen == GETFIELD)); unsafe |= (!isStatic) && ((seen == ALOAD_0) || (seen == ASTORE_0)); if (unsafe) { - if (syncPC >= 0) { - if ((getPC() - startSafe) > minSafeCodeLength) { - bugReporter.reportBug(new BugInstance(this, "BSB_BLOATED_SYNCHRONIZED_BLOCK", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLineRange(this, startSafe, lastPC)); - } + if ((getPC() - syncPC) > minSafeCodeLength) { + bugReporter.reportBug(new BugInstance(this, "BSB_BLOATED_SYNCHRONIZED_BLOCK", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLineRange(this, syncPC + 1, lastPC)); } - startSafe = -1; syncPC = -1; - } else if (startSafe < 0) { - int depth = stack.getStackDepth(); - int i; - for (i = 0; i < depth; i++) { - OpcodeStack.Item item = stack.getStackItem(i); - if (item.getField() != null) { - break; - } - } - if (i == depth) - startSafe = getPC(); } } lastPC = getPC(); |