[Fb-contrib-commit] fb-contrib/src/com/mebigfatguy/fbcontrib/detect BloatedSynchronizedBlock.java,1.
Brought to you by:
dbrosius
|
From: Dave B. <dbr...@us...> - 2006-02-01 06:47:57
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16894/src/com/mebigfatguy/fbcontrib/detect Modified Files: BloatedSynchronizedBlock.java Log Message: unsafe aliases aren't just items that are return values of this calls, but also of methods returned from methods calls on other unsafe aliases Index: BloatedSynchronizedBlock.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- BloatedSynchronizedBlock.java 31 Jan 2006 02:14:26 -0000 1.14 +++ BloatedSynchronizedBlock.java 1 Feb 2006 06:47:47 -0000 1.15 @@ -42,7 +42,7 @@ private int syncPC; private boolean isStatic; private int minSafeCodeLength; - private boolean thisCallOccurred; + private boolean unsafeCallOccurred; /** * constructs a BSB detector given the reporter to report bugs on @@ -76,8 +76,9 @@ syncPC = -1; isStatic = obj.isStatic(); unsafeAliases.clear(); + unsafeAliases.add(new Integer(0)); branchInfo.clear(); - thisCallOccurred = false; + unsafeCallOccurred = false; stack.resetForMethodEntry(this); } @@ -91,7 +92,7 @@ try { stack.mergeJumps(this); - if (thisCallOccurred && ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3)))) { + if (unsafeCallOccurred && ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3)))) { int storeReg = astoreReg(seen); if (storeReg >= 0) unsafeAliases.add(new Integer(storeReg)); @@ -106,22 +107,22 @@ int parmCount = Type.getArgumentTypes(methodSig).length; if (stack.getStackDepth() > parmCount) { OpcodeStack.Item itm = stack.getStackItem(parmCount); - thisCallOccurred = (itm.getRegisterNumber() == 0); + unsafeCallOccurred = unsafeAliases.contains(itm.getRegisterNumber()); } else - thisCallOccurred = false; + unsafeCallOccurred = false; } else - thisCallOccurred = false; + unsafeCallOccurred = false; } else if (seen == INVOKESTATIC) - thisCallOccurred = (getDottedClassConstantOperand().equals(this.getClassContext().getJavaClass().getClassName())); + unsafeCallOccurred = (getDottedClassConstantOperand().equals(this.getClassContext().getJavaClass().getClassName())); else if ((seen >= IFEQ) && (seen <= GOTO)) { Integer from = new Integer(getPC()); Integer to = new Integer(getBranchTarget()); branchInfo.put(from, to); - thisCallOccurred = false; + unsafeCallOccurred = false; } else - thisCallOccurred = false; + unsafeCallOccurred = false; if (seen == MONITORENTER) { if (syncPC < 0) { @@ -139,7 +140,7 @@ syncPC = -1; else if (syncPC >= 0) { //TODO: probably static calls are unsafe only if the monitor is on a static - boolean unsafe = thisCallOccurred; + boolean unsafe = unsafeCallOccurred; unsafe |= ((seen == PUTFIELD) || (seen == GETFIELD) || (seen == GETSTATIC) || (seen == PUTSTATIC)); unsafe |= (!isStatic) && ((seen == ALOAD_0) || (seen == ASTORE_0)); int aloadReg = aloadReg(seen); |