Skip to content

Commit

Permalink
generalized async calls to allow their atomic action specification to be
Browse files Browse the repository at this point in the history
left mover
  • Loading branch information
Shaz Qadeer committed Sep 6, 2016
1 parent ba4f9fa commit 8d5cdd2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Source/Concurrency/CivlRefinement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ public override Block VisitBlock(Block node)
public override Cmd VisitCallCmd(CallCmd node)
{
CallCmd callCmd = (CallCmd) base.VisitCallCmd(node);
if (callCmd.IsAsync && civlTypeChecker.procToActionInfo.ContainsKey(node.Proc))
{
ActionInfo actionInfo = civlTypeChecker.procToActionInfo[node.Proc];
Debug.Assert(actionInfo.IsLeftMover);
if (actionInfo.createdAtLayerNum < layerNum)
{
callCmd.IsAsync = false;
}
}
callCmd.Proc = VisitProcedure(callCmd.Proc);
callCmd.callee = callCmd.Proc.Name;
absyMap[callCmd] = node;
Expand Down
6 changes: 5 additions & 1 deletion Source/Concurrency/CivlTypeChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,11 @@ public override Cmd VisitCallCmd(CallCmd node)
ActionInfo actionInfo = procToActionInfo[node.Proc];
if (node.IsAsync && actionInfo is AtomicActionInfo)
{
Error(node, "Target of async call cannot be an atomic action");
AtomicActionInfo atomicActionInfo = actionInfo as AtomicActionInfo;
if (!atomicActionInfo.IsLeftMover)
{
Error(node, "Target of async call must be a left mover");
}
}
int calleeLayerNum = procToActionInfo[node.Proc].createdAtLayerNum;
if (enclosingProcLayerNum < calleeLayerNum ||
Expand Down
14 changes: 14 additions & 0 deletions Test/civl/async1.bpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %boogie -noinfer -useArrayTheory "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
var {:layer 0} x: int;

procedure {:yields} {:layer 0,1} Incr();
ensures {:left} |{ L: x := x + 1; return true; }|;

procedure {:yields} {:layer 1} AsyncIncr()
ensures {:left} |{ L: x := x + 1; return true; }|;
{
yield;
async call Incr();
yield;
}
2 changes: 2 additions & 0 deletions Test/civl/async1.bpl.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Boogie program verifier finished with 2 verified, 0 errors

0 comments on commit 8d5cdd2

Please sign in to comment.