Changes between Version 115 and Version 116 of IR


Ignore:
Timestamp:
12/02/15 14:06:09 (10 years ago)
Author:
zmanchun
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IR

    v115 v116  
    454454* depends clause: `depends [condition] action0, action1, action2, ... `
    455455 * Example: `depends ma_union(ma_comp(reads n, calls inc, <x>)), calls(dec, y))`
    456 
    457  * **absence of depends clause**:
    458 * assigns-or-reads clause
    459  * assigns clause: `assigns [condition] {memory-list}`
    460  * reads clause: `reads [condition] {memory-list}`
    461  * `reads {nothing}` implies `assigns {nothing}`
    462  * `reads {\nothing}` is equivalent to: `reads {\nothing} assigns {\nothing}`
    463  * `assigns {X}` where `X != \nothing`, implies `reads {X}`
    464  * `assigns {X}` is equivalent to:` assigns{X} reads{X}`
     456 * absence of depends clause: there is no information about the dependency of the function, which means that the analysis needs to figure it out by itself.
     457* some facts about assigns-or-reads clause
     458 * `reads nothing` implies `assigns nothing`
     459 * `reads nothing` is equivalent to: `ma_union(reads nothing, assigns nothing)`
     460 * `assigns X` where `X != nothing`, implies `reads X`
     461 * `assigns X` is equivalent to: `ma_union(assigns X, reads X)`
    465462 * absence:
    466463  * absence of `reads` clause: there is no assumption about the read access of the function, i.e., the function could read anything
    467464  * absence of `assigns` clause: similar to the absence of `reads` clause
    468  * `reads/assigns {\nothing}` doesn’t necessarily means that the function never reads or assigns any variable. The function could still reads/assigns its “local” variables, including function parameters and any variable declared inside the function body.
    469 
    470 * For an independent function which has `depends {\nothing}`, usually we also need to specify `reads{nothing}`, for the purpose of reachability analysis.
     465 * `reads/assigns nothing` doesn’t necessarily means that the function never reads or assigns any variable. The function could still reads/assigns its “local” variables, including function parameters and any variable declared inside the function body.
     466
     467* For an independent function which has `depends nothing`, usually we also need to specify `reads nothing`, for the purpose of reachability analysis.
    471468e.g.,
    472469{{{
    473470/* Returns the size of the given bundle b. */
    474 bundle_size(Bundle b; Int)
    475   depends {\nothing}
    476   reads {\nothing}
     471bundle_size(Bundle b): Integer
     472  depends nothing
     473  reads b
    477474  ;
    478475}}}
     
    480477* Example of a function declaration with contracts:
    481478{{{
    482 atomic_f sendRecv(Int cmd, Pointer buf; Int)
    483   depends [eq(cmd, SEND)] {write(buf)}
    484   depends [eq(cmd, RECV)] {access(deref(buf))}
    485   assigns [eq(cmd, SEND)] {\nothing}
    486   assigns [eq(cmd, RECV)] {deref(buf)}
    487   reads {deref(buf)}
     479atomic_f sendRecv(Int cmd, Pointer buf): Integer
     480  depends [eq(cmd, SEND)] writes(buf)
     481  depends [eq(cmd, RECV)] access(deref(buf))
     482  assigns [eq(cmd, SEND)] nothing
     483  assigns [eq(cmd, RECV)] deref(buf)
     484  reads deref(buf)
    488485{
    489 L0:
     486  begin choose
    490487  when (eq(cmd, SEND))
    491      send(deref(buf), ...); goto L1;
     488     do CALL send, <buf, ...>; goto L1;
    492489  when (eq(cmd, RECV))
    493     deref(buf):=recv(...); goto L1;
     490    do CALL recv, <buf, ...>; goto L1;
    494491  when (and(neq(cmd, SEND), neq(cmd, RECV)))
    495     ; goto L1;
     492    do NOOP; goto L1;
     493  end choose
    496494L1:
    497495}