| Version 11 (modified by , 12 years ago) ( diff ) |
|---|
Contract Reduction Language
$depends clause
The following contractual clause may appear in a function contract in the same places that $ensures or $requires clauses can appear:
$depends e ;
where e is an expression of boolean type. For each process p, the e can be evaluated in the context of p. If e evaluates to true, then p must be included in an ample set containing a call to this function.
The following boolean expressions may be used as constituents in the boolean expression e:
$reaches(void * obj)- holds iff the memory unit pointed to by
objis reachable fromp. This means there is a path from the variables on the call stack ofpto the memory unit, following array elements, struct members, and pointer dereferences, pointer arithmetic.
- holds iff the memory unit pointed to by
$reachesRegion(void * obj)- holds iff any of the memory units reachable from
obj(including the object pointed to byobjitself) is reachable fromp
- holds iff any of the memory units reachable from
$writes(void * obj)- holds iff the memory unit pointed to by
objis not only reachable frompbut if it is possible thatp(or a process spawned byp) could write to that memory unit at some point now or in the future.
- holds iff the memory unit pointed to by
$writesRegion(void * obj)- like above but true if any of the memory units in the reachable region specified by
objmay be written to
- like above but true if any of the memory units in the reachable region specified by
Default: if there is $depends clause present:
- if the body of the function is not provided, i.e., the function is a system function, the verifier will assume that execution of the function may read and/or modify any memory unit that it can reach, and decide on the partial order reduction appropriately
- if the body of the function is present, the statements comprising the body may be analyzed to further restrict the reduction.
Function specifiers
Both $atomic and $atom may be used as function specifiers. They designate that any call to the function is to be treated atomically or atom-ly, respectively.
$assigns clause
As in other contract specification language, this clause is used to specify a set of existing memory units. The claim is that if an existing memory unit is not in the set, it will not be modified in the course of the function call.
The argument following the $assigns token is a comma-separated list. The elements of the list may be left-hand-side expressions, or an expression of the form
$region(ptr)
where ptr is expression which has a pointer type. It denotes the set of all memory units reachable from that pointer, beginning with and including the memory unit pointer to by ptr.
Example:
$assigns x,a[i][j],$region(list->head);
Examples
- The following means that any process that can reach the memory unit of
commshould be in the ample set if the current process ($self) is to be chosen in the ample set.void comm_deque($comm comm, ....) $depend $access(void * obj); ;
- The following means that any process that can reach any of the memory units reachable from
aor write any of the memory units reachable fromanow or in the future should be in the ample set if the current process ($self) is to be chosen in the ample set.void strcpy(char *a, char *b) $depend $accessRegion(a) || $writeRegion(b); ;
- The following means that the current process itself can form the ample set.
int $comm_size($comm, ...) $depend $false; ;
- The following means that if the argument
countis equal to zero, then the current process forms the ample set, otherwise, any process that can reach the memory unit of objectcommshould be in the ample set.void comm_deque($comm comm, int count ....) $depend count==0 ? $false : $access(comm); ;
