From bd5eee6485e94af774e8db1d6ae20748391aaca2 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Tue, 9 Jun 2020 14:24:37 -0700 Subject: [PATCH] Adding happens-before push back. --- .../nasa/jpf/listener/DPORStateReducer.java | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/src/main/gov/nasa/jpf/listener/DPORStateReducer.java b/src/main/gov/nasa/jpf/listener/DPORStateReducer.java index bf9ecfa..823bd52 100644 --- a/src/main/gov/nasa/jpf/listener/DPORStateReducer.java +++ b/src/main/gov/nasa/jpf/listener/DPORStateReducer.java @@ -1072,10 +1072,42 @@ public class DPORStateReducer extends ListenerAdapter { // Memorize visited TransitionEvent object while performing backward DFS to avoid getting caught up in a cycle HashSet visited = new HashSet<>(); // Update backtrack set recursively - updateBacktrackSetRecursive(execution, currentChoice, execution, conflictChoice, currRWSet, visited); +// updateBacktrackSetRecursive(execution, currentChoice, execution, conflictChoice, currRWSet, visited); + int hbChoice = currentChoice; + updateBacktrackSetRecursive(execution, currentChoice, execution, conflictChoice, execution, hbChoice, currRWSet, visited); } - private void updateBacktrackSetRecursive(Execution execution, int currentChoice, Execution conflictExecution, int conflictChoice, +// private void updateBacktrackSetRecursive(Execution execution, int currentChoice, +// Execution conflictExecution, int conflictChoice, +// ReadWriteSet currRWSet, HashSet visited) { +// // Halt when we have found the first read/write conflicts for all memory locations +// if (currRWSet.isEmpty()) { +// return; +// } +// TransitionEvent confTrans = conflictExecution.getExecutionTrace().get(conflictChoice); +// // Halt when we have visited this transition (in a cycle) +// if (visited.contains(confTrans)) { +// return; +// } +// visited.add(confTrans); +// // Explore all predecessors +// for (Predecessor predecessor : confTrans.getPredecessors()) { +// // Get the predecessor (previous conflict choice) +// conflictChoice = predecessor.getChoice(); +// conflictExecution = predecessor.getExecution(); +// // Check if a conflict is found +// if (isConflictFound(execution, currentChoice, conflictExecution, conflictChoice, currRWSet)) { +// createBacktrackingPoint(execution, currentChoice, conflictExecution, conflictChoice); +// } +// // Continue performing DFS if conflict is not found +// updateBacktrackSetRecursive(execution, currentChoice, conflictExecution, conflictChoice, currRWSet, visited); +// } +// } + + // TODO: This is the version of the method with pushing up happens-before transitions + private void updateBacktrackSetRecursive(Execution execution, int currentChoice, + Execution conflictExecution, int conflictChoice, + Execution hbExecution, int hbChoice, ReadWriteSet currRWSet, HashSet visited) { // Halt when we have found the first read/write conflicts for all memory locations if (currRWSet.isEmpty()) { @@ -1092,12 +1124,18 @@ public class DPORStateReducer extends ListenerAdapter { // Get the predecessor (previous conflict choice) conflictChoice = predecessor.getChoice(); conflictExecution = predecessor.getExecution(); + // Push up one happens-before transition + int pushedChoice = hbChoice; + Execution pushedExecution = hbExecution; // Check if a conflict is found if (isConflictFound(execution, currentChoice, conflictExecution, conflictChoice, currRWSet)) { - createBacktrackingPoint(execution, currentChoice, conflictExecution, conflictChoice); + createBacktrackingPoint(pushedExecution, pushedChoice, conflictExecution, conflictChoice); + pushedChoice = conflictChoice; + pushedExecution = conflictExecution; } // Continue performing DFS if conflict is not found - updateBacktrackSetRecursive(execution, currentChoice, conflictExecution, conflictChoice, currRWSet, visited); + updateBacktrackSetRecursive(execution, currentChoice, conflictExecution, conflictChoice, + pushedExecution, pushedChoice, currRWSet, visited); } } -- 2.34.1