From: Willem V. <wv...@us...> - 2005-08-16 22:27:41
|
Update of /cvsroot/javapathfinder/javapathfinder/src/gov/nasa/jpf/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21134/src/gov/nasa/jpf/tools Modified Files: IdleFilter.java Log Message: * removed maxStrikes and strikes in idleFilter * now if we loop too much we call it as suspicious straight away rather * than let it go maxStrikes times Index: IdleFilter.java =================================================================== RCS file: /cvsroot/javapathfinder/javapathfinder/src/gov/nasa/jpf/tools/IdleFilter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- IdleFilter.java 16 Aug 2005 06:50:21 -0000 1.2 +++ IdleFilter.java 16 Aug 2005 22:27:33 -0000 1.3 @@ -52,128 +52,124 @@ * marks the state as seen, which prunes the whole search tree underneath it */ public class IdleFilter extends ListenerAdapter { - - static Logger log = JPF.getLogger("gov.nasa.jpf.tools.IdleFilter"); - - static class ThreadStat { - String tname; - int strikes; - int backJumps; - boolean isCleared = false; - - int loopStartPc; - int loopEndPc; - int loopStackDepth; - - ThreadStat (String tname) { - this.tname = tname; - } - } - - DynamicObjectArray threadStats = new DynamicObjectArray(16); - ThreadStat ts; - - int maxStrikes; - int maxBackJumps; - boolean jumpPast; - - //----------------------------------------------------- SearchListener interface - public IdleFilter (Config config) { - maxBackJumps = config.getInt("idle.max_backjumps", 500); - maxStrikes = config.getInt("idle.max_strikes", 1); - jumpPast = config.getBoolean("idle.jump", false); - } - - public void stateAdvanced(Search search) { - ts.backJumps = 0; - ts.isCleared = false; - ts.loopStackDepth = 0; - ts.loopStartPc = ts.loopEndPc = 0; - } + static Logger log = JPF.getLogger("gov.nasa.jpf.tools.IdleFilter"); - public void stateBacktracked(Search search) { - ts.strikes = 0; - ts.backJumps = 0; - ts.isCleared = false; - ts.loopStackDepth = 0; - ts.loopStartPc = ts.loopEndPc = 0; - } - - //----------------------------------------------------- VMListener interface - public void instructionExecuted(VM vm) { - JVM jvm = (JVM)vm; - Instruction insn = jvm.getLastInstruction(); - ThreadInfo ti = jvm.getLastThreadInfo(); + static class ThreadStat { + String tname; + int backJumps; + boolean isCleared = false; + int loopStartPc; + int loopEndPc; + int loopStackDepth; - int tid = ti.getIndex(); - ts = (ThreadStat)threadStats.get(tid); - if (ts == null) { - ts = new ThreadStat(ti.getName()); - threadStats.set(tid,ts); - } - - if (insn.isBackJump()) { - ts.backJumps++; - - int loopStackDepth = ti.countStackFrames(); - int loopPc = jvm.getNextInstruction().getPosition(); - - if ((loopStackDepth != ts.loopStackDepth) || (loopPc != ts.loopStartPc)) { - // new loop, reset - ts.isCleared = false; - ts.loopStackDepth = loopStackDepth; - ts.loopStartPc = loopPc; - ts.loopEndPc = insn.getPosition(); - ts.backJumps = 0; - } else { - if (!ts.isCleared) { - if (ts.backJumps > maxBackJumps) { - - ti.yield(); // this breaks the executePorStep loop - ts.strikes++; - - if (ts.strikes > maxStrikes) { + ThreadStat(String tname) { + this.tname = tname; + } + } - MethodInfo mi = insn.getMethod(); - ClassInfo ci = mi.getClassInfo(); - int line = mi.getLineNumber(insn); - String file = ci.getSourceFileName(); + DynamicObjectArray threadStats = new DynamicObjectArray(16); + ThreadStat ts; + int maxBackJumps; + boolean jumpPast; - if (jumpPast) { - Instruction next = insn.getNext(); - ti.setPC(next); + //----------------------------------------------------- SearchListener interface - log.warning("WARNING: IdleFilter jumped past loop in: " + ti.getName() + - "\n\tat " + ci.getName() + "." + mi.getName() + - "(" + file + ":" + line + ")"); - } else { - // cut this sucker of - we declare this a visited state - jvm.setIgnoreState(true); - - log.warning("WARNING: IdleFilter pruned thread: " + ti.getName() + - "\n\tat " + ci.getName() + "." + mi.getName() + - "(" + file + ":" + line + ")"); - } - } - } - } - } - - } else if (!ts.isCleared) { - // if we call methods or set array elements inside the loop in question, we - // assume this is not an idle loop and terminate the checks - if ((insn instanceof InvokeInstruction) || (insn instanceof ArrayStoreInstruction)) { - int stackDepth = ti.countStackFrames(); - int pc = insn.getPosition(); + public IdleFilter(Config config) { + maxBackJumps = config.getInt("idle.max_backjumps", 500); + jumpPast = config.getBoolean("idle.jump", false); + } + + public void stateAdvanced(Search search) { + ts.backJumps = 0; + ts.isCleared = false; + ts.loopStackDepth = 0; + ts.loopStartPc = ts.loopEndPc = 0; + } + + public void stateBacktracked(Search search) { + ts.backJumps = 0; + ts.isCleared = false; + ts.loopStackDepth = 0; + ts.loopStartPc = ts.loopEndPc = 0; + } + + //----------------------------------------------------- VMListener interface + public void instructionExecuted(VM vm) { + JVM jvm = (JVM) vm; + Instruction insn = jvm.getLastInstruction(); + ThreadInfo ti = jvm.getLastThreadInfo(); + + int tid = ti.getIndex(); + ts = (ThreadStat) threadStats.get(tid); + if (ts == null) { + ts = new ThreadStat(ti.getName()); + threadStats.set(tid, ts); + } + + if (insn.isBackJump()) { + ts.backJumps++; + + int loopStackDepth = ti.countStackFrames(); + int loopPc = jvm.getNextInstruction().getPosition(); + + if ((loopStackDepth != ts.loopStackDepth) + || (loopPc != ts.loopStartPc)) { + // new loop, reset + ts.isCleared = false; + ts.loopStackDepth = loopStackDepth; + ts.loopStartPc = loopPc; + ts.loopEndPc = insn.getPosition(); + ts.backJumps = 0; + } else { + if (!ts.isCleared) { + if (ts.backJumps > maxBackJumps) { + + ti.yield(); // this breaks the executePorStep loop + MethodInfo mi = insn.getMethod(); + ClassInfo ci = mi.getClassInfo(); + int line = mi.getLineNumber(insn); + String file = ci.getSourceFileName(); + + if (jumpPast) { + Instruction next = insn.getNext(); + ti.setPC(next); + + log + .warning("WARNING: IdleFilter jumped past loop in: " + + ti.getName() + + "\n\tat " + + ci.getName() + + "." + + mi.getName() + + "(" + file + ":" + line + ")"); + } else { + // cut this sucker of - we declare this a visited state + jvm.setIgnoreState(true); + log.warning("WARNING: IdleFilter pruned thread: " + + ti.getName() + "\n\tat " + ci.getName() + + "." + mi.getName() + "(" + file + ":" + + line + ")"); + } + } + } + } + + } else if (!ts.isCleared) { + // if we call methods or set array elements inside the loop in question, we + // assume this is not an idle loop and terminate the checks + if ((insn instanceof InvokeInstruction) + || (insn instanceof ArrayStoreInstruction)) { + int stackDepth = ti.countStackFrames(); + int pc = insn.getPosition(); + + if (stackDepth == ts.loopStackDepth) { + if ((pc >= ts.loopStartPc) && (pc < ts.loopEndPc)) { + ts.isCleared = true; + } + } + } + } + } - if (stackDepth == ts.loopStackDepth) { - if ((pc >= ts.loopStartPc) && (pc < ts.loopEndPc)) { - ts.isCleared = true; - } - } - } - } - } - } |