Skip to main content

Crate psync_check

Crate psync_check 

Source
Expand description

cargo psync check: verifies #[psync::graph] rewrites against the compiled bodies of callees.

#[psync::graph] sees only the tokens of the function it rewrites. It judges every call by its name: api.get(..) reads, store.put(..) writes, do_work(x) is unknown. cargo psync check runs the compiler with a custom driver (psync-driver, like clippy-driver) that sees the program after type checking, as MIR:

  1. Summaries. For every function of every crate in the build, the driver computes which effects on the outside world the function performs: file reads and writes (std::fs, tokio::fs, …), sockets, processes, environment variables, and calls into other crates’ APIs, classified by their verbs (delete, list, …). Calls are resolved exactly (trait methods to their impls), callees in the same crate are followed into their bodies, and summaries of dependencies are read from files the driver wrote when it compiled them.
  2. Checks. In every function #[psync::graph] rewrote, the generated code marks each concurrent level and each prefetched loop (maybe_done_at, over_at) with what the macro assumed. The driver compares those assumptions with the summaries and warns where the rewrite runs two conflicting effects at once, performs a write before an earlier exit, or shares interior-mutable state between concurrent chains.

This library holds the parts shared by the driver and the cargo psync front end: the effect model, summary files and findings. It does not link the compiler.

Re-exports§

pub(crate) use Deserialize; 🔒
pub(crate) use Deserialize; 🔒
pub(crate) use Serialize; 🔒
pub(crate) use Serialize; 🔒
pub(crate) use std::collections::BTreeMap; 🔒
pub(crate) use std::path::Path; 🔒

Modules§

env
pdg
Environment variables the front end passes to the driver. Control dependence for a function’s program dependence graph (Ferrante, Ottenstein and Warren, 1987).

Structs§

CallFact
What one call in a #[psync::graph] function does, for the macro.
CrateFindings
The findings of one crate, as written by the driver.
CrateSummaries
Every summary of one crate, keyed by the stable hash of each function’s definition path.
Effect
One effect of a function, with the calls through which it happens.
Finding
One problem found in a rewritten function.
Fix
An insertion that fixes a finding: #[psync::seq] before the statement or loop.
FnSummary
The summary of one function, as stored for other crates.
Resolved
The effects of a deferred trait method: the union over its implementations in the build.

Enums§

Access
How an effect touches its domain.
Domain
Where an effect lands.
Severity
How serious a finding is.

Functions§

conflict
Whether two effects may not run concurrently: one writes, they may reach the same resource, and their targets may be the same (or both are ordered writes on one domain).
facts_text
The facts file the macro reads (PSYNC_FACTS): one call site per line, site \t name \t panics \t opaque \t effects (opaque: some callee could not be seen through), effects separated by \x1e, each domain \x1f access \x1f target. Domains: fs, net, env, process, output, svc:<owner>; accesses r, w, o. A line-based format keeps the macro free of a JSON dependency.
link
Link-time resolution of dyn and generic trait calls over the whole build (closed world): every deferred trait method’s effects are the union of its implementations’ effects, and of what those call through dyn in turn.
paths_overlap
Equal paths, or one is a directory containing the other.
read_all
Read every *.json file in dir as T, skipping files that do not parse.
resolve_call
The final effects of a call site: its own, and those of the trait methods it reaches through dyn.
same_effect 🔒