Skip to content

Commit

Permalink
Update checker with new fpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasAlaif committed Oct 25, 2023
1 parent 741284e commit 348623d
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions mir-state-analysis/src/coupling_graph/check/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub(crate) fn check<'tcx>(mut cg: CgAnalysis<'_, '_, 'tcx>, mut fpcs_cursor: Fre
fpcs_cursor.set_bound_non_empty();
let mut fpcs = Fpcs {
summary: fpcs_cursor.initial_state().clone(),
apply_pre_effect: false,
bottom: false,
repackings: Vec::new(),
repacker: rp,
Expand Down Expand Up @@ -89,16 +90,25 @@ pub(crate) fn check<'tcx>(mut cg: CgAnalysis<'_, '_, 'tcx>, mut fpcs_cursor: Fre
fpcs_cursor.unset_bound();

// Repacks
for op in fpcs_after.repacks {
for op in fpcs_after.repacks_middle {
op.update_free(&mut fpcs.summary, false, rp);
}
// Couplings bound set
let bound: Box<dyn Fn(Place<'tcx>) -> CapabilityKind> = Box::new(cg_state.mk_capability_upper_bound());
fpcs.bound.borrow_mut().0 = Some(unsafe { std::mem::transmute(bound) });
// Consistency
fpcs.summary.consistency_check(rp);
// Statement
// Statement pre
assert!(fpcs.repackings.is_empty());
fpcs.apply_pre_effect = true;
fpcs.visit_terminator(data.terminator(), loc);
// Repacks
for op in fpcs_after.repacks {
op.update_free(&mut fpcs.summary, false, rp);
}
// Statement post
assert!(fpcs.repackings.is_empty());
fpcs.apply_pre_effect = false;
fpcs.visit_terminator(data.terminator(), loc);
assert!(fpcs.repackings.is_empty());
// Consistency
Expand Down Expand Up @@ -169,16 +179,26 @@ impl<'a, 'tcx> CouplingState<'a, 'tcx> {
fpcs_cursor.unset_bound();

// Repacks
for op in fpcs_after.repacks {
for op in fpcs_after.repacks_middle {
op.update_free(&mut fpcs.summary, false, rp);
}
// Couplings bound set
let bound: Box<dyn Fn(Place<'tcx>) -> CapabilityKind> = Box::new(self.mk_capability_upper_bound());
fpcs.bound.borrow_mut().0 = Some(unsafe { std::mem::transmute(bound) }); // Extend lifetimes (safe since we unset it later)
// Consistency
fpcs.summary.consistency_check(rp);
// Statement
// Statement pre
assert!(fpcs.repackings.is_empty());
fpcs.apply_pre_effect = true;
fpcs.visit_statement(stmt, loc);
assert!(fpcs.repackings.is_empty());
// Repacks
for op in fpcs_after.repacks {
op.update_free(&mut fpcs.summary, false, rp);
}
// Statement post
assert!(fpcs.repackings.is_empty());
fpcs.apply_pre_effect = false;
fpcs.visit_statement(stmt, loc);
assert!(fpcs.repackings.is_empty());
// Consistency
Expand Down

0 comments on commit 348623d

Please sign in to comment.