Mercurial > hg > Members > kono > jpf-core
diff src/main/gov/nasa/jpf/search/heuristic/UserHeuristic.java @ 21:caa0924e093d
reshuffled Event hierarchy, introducing SystemEvent, with CheckEvent and
ControlEvent being subclasses of SystemEvent
added Loggable.setLogLevel
changed old UserHeuristic to use a Verify.heuristicValue instead of a
hardwired "Main" class with hardwired fields (which was just an outdated
leftover). Call Verify.setHeuristicValue() to control state priorities from the
SUT.
This also fixes the bug that UserHeuristic was not properly checking for
"Main" resolution.
author | Peter Mehlitz <pcmehlitz@gmail.com> |
---|---|
date | Fri, 10 Apr 2015 20:53:11 -0700 |
parents | 61d41facf527 |
children |
line wrap: on
line diff
--- a/src/main/gov/nasa/jpf/search/heuristic/UserHeuristic.java Mon Apr 06 12:08:03 2015 -0700 +++ b/src/main/gov/nasa/jpf/search/heuristic/UserHeuristic.java Fri Apr 10 20:53:11 2015 -0700 @@ -20,41 +20,21 @@ import gov.nasa.jpf.Config; import gov.nasa.jpf.vm.ClassLoaderInfo; import gov.nasa.jpf.vm.ElementInfo; +import gov.nasa.jpf.vm.JPF_gov_nasa_jpf_vm_Verify; import gov.nasa.jpf.vm.VM; /** - * heuristic state prioritizer that uses fields of the Main class under test - * to determine priorities (i.e. priorities can be set by the program under test) - * - * <2do> pcm - does this still make sense in light of MJI ? If we keep it, this - * has to be moved to the Verify interface! + * heuristic state prioritizer that is controlled by the system under test, which can + * use Verify.get/set/resetHeuristicSearchValue() to compute priorities */ public class UserHeuristic extends SimplePriorityHeuristic { - static final int defaultValue = 1000; - public UserHeuristic (Config config, VM vm) { super(config, vm); } @Override protected int computeHeuristicValue () { - - // <2do> pcm - BAD, this is WAY too hardwired - ClassLoaderInfo systemLoader = ClassLoaderInfo.getCurrentSystemClassLoader(); - ElementInfo ei = systemLoader.getElementInfo("Main"); - if (ei != null) { - // this code is ugly because of the Reference interface - ElementInfo b = ei.getObjectField("buffer"); - - if (b != null) { - int current = b.getIntField("current"); - int capacity = b.getIntField("capacity"); - - return (capacity - current); - } - } - - return defaultValue; + return JPF_gov_nasa_jpf_vm_Verify.heuristicSearchValue; } }