Skip to content

Tags

Tags

v2.0.0

Toggle v2.0.0's commit message
Flow v2.0.0

archive/feat/denotational-mlir

Toggle archive/feat/denotational-mlir's commit message
feat: denotational MLIR emitter for flow evolution blocks (partial #664/

#665/#667)

A `flow` block denotes a first-order system dx/dt = f(x, u, p). The shipped
path desugars it to plain functions, which erases the vector-field structure
before MLIR sees it, so the fusion/AoSoA/specialization passes cannot batch or
vectorize an ensemble of instances.

Adds a new module src/flow/denotational_mlir.py that emits a flow.* dialect
keeping that structure: flow.system with flow.state/flow.param members and one
flow.evolve region per state, derivatives lowered to arith/math for the
supported subset and kept as flow.opaque otherwise. The discrete overlay
(every/when) is flagged with a flow.pending marker so partial output is never
mistaken for the whole system. New module only, wired into nothing yet, so it
does not touch mlir_generator.py or dynamics_dsl.py while those are under edit.

Design and next slices in docs/design/denotational-mlir.md; scope announced in
AGENTS.md. Tests in tests/unit/test_denotational_mlir.py (7 cases).

archive/integrate/perf-batch

Toggle archive/integrate/perf-batch's commit message
docs: add tested Rosetta Code task solutions in Flow (#896)

Eleven canonical Rosetta Code tasks written in Flow, each a single file
with a main that prints the expected output. All compile and run under
FLOW_HOST=python ./flow-driver run.

tests/unit/test_rosetta_examples.py parses and generates C for every
file so the examples stay green. examples/rosetta/README.md lists the
tasks and the run command.

archive/feat/900-pygments-lexer

Toggle archive/feat/900-pygments-lexer's commit message
docs: add a Pygments lexer for Flow (#900)

Add editors/pygments/flow_lexer.py, a pygments.lexer.RegexLexer subclass
FlowLexer covering Flow's real lexical surface: the keyword table from
compiler/src/token.flow, primitive types (i8..i128, u8..u128, f32/f64,
bool, string, span, ptr), @-attributes, # line comments, string literals
with ${...} interpolation, numbers, and operators.

Add tests/unit/test_pygments_lexer.py, guarded by
pytest.importorskip("pygments") so it skips cleanly when pygments is
absent. It tokenizes a representative snippet and checks keywords, types,
comments, strings, interpolation, numbers, operators, and attributes.

This is the in-repo plugin source. Upstreaming to Pygments is deferred
until Flow has a larger community, per their contribution guide.

archive/perf/745-runtime-primitive

Toggle archive/perf/745-runtime-primitive's commit message
fix: pointer arithmetic inherits its base region in region inference (#…

…694)

restrict_candidates() treated `base + off` as fresh disjoint storage, so a
local pointer derived from a parameter by arithmetic was wrongly reported as
safe to mark restrict. A pointer built by arithmetic points into an operand's
storage, so it now inherits the referenced region (TOP when the provenance is
mixed). Pure literal arithmetic stays fresh. This closes an unsound restrict
path before any backend consumed it.

archive/perf/736-incremental-cache

Toggle archive/perf/736-incremental-cache's commit message
perf: make the frontend declaration cache sound (#736)

The cache in module_resolver keyed only on raw source text, so it could
serve declarations from a stale entry after the compiler frontend changed
or after an imported module changed on disk.

Close the staleness holes:

- Fold a salt into every cache key: the schema version, the running Flow
  version, a fingerprint of the frontend source files (lexer, parser,
  resolver, DSL expanders) and the resolution config. Identical source no
  longer reuses declarations produced by a different frontend or config.
  FLOW_CACHE_SALT augments the salt for forced rebuilds and tests.
- Record each module's direct-import content hashes in the entry and
  verify them on load, so an entry misses when a dependency changed.
- Store entries as a schema-tagged dict written atomically, and reject any
  entry whose schema or salt does not match. Any doubt misses and reparses.

Add tests/unit/test_incremental_cache.py covering compiler-salt
invalidation, imported-module invalidation, a corrupt-entry fallback and
the unchanged-rebuild cache hit.

archive/perf/696-move-inference

Toggle archive/perf/696-move-inference's commit message
perf: move a returned record update of a local base (#696)

Flow structs have value semantics, so `return Struct { ..base, f: v }` copied
the whole base into a statement-expression temporary before overriding fields.

When the base is a plain local binding, the return is its last use: nothing
runs after a return, so the base is dead. In that case the update is built in
place on the base and the base is returned, eliding the temporary and its
full-struct copy.

The move is withheld unless it is provably safe:
- the struct is known, so its field list resolves;
- the base is a plain variable, not captured and not a function-value symbol;
- no update value reads the base, so no field is overwritten before it is read.

C returns the base by value into the caller's slot, so value semantics hold.
A by-value parameter is safe to move from because the caller keeps its own copy.

Adds tests/unit/test_move_inference.py and updates the return-position case in
tests/unit/test_copy_elision.py, which previously asserted the retained copy.

archive/feat/731-local-restrict

Toggle archive/feat/731-local-restrict's commit message
perf: emit restrict on proven-disjoint local pointers (#731)

The region analysis added for #694 proves a sound subset of local bindings
disjoint from every parameter and from each other. Its restrict_candidates()
returns that subset. The C backend now marks a local pointer declaration with
the C restrict qualifier when, and only when, its binding is in that set.

Scope is deliberately narrow. Only pointer-typed local declarations are
qualified, and only when proven disjoint. Arrays, spans and every other local
are emitted unchanged. Function-signature parameters are never qualified: the
analysis does not prove two parameters disjoint, so signature restrict waits
on the interprocedural boundary work still open on #694.

The candidate set is computed once per function in _gen_function and consulted
at the local pointer declaration site. A failure in the analysis yields the
empty set, so a local emits no restrict rather than an unsound one.

Adds tests/unit/test_local_restrict.py: a fresh local pointer gets restrict; a
pointer copied from a parameter, a pointer aliasing a local array, and the
parameter itself do not.

archive/feat/694-region-inference

Toggle archive/feat/694-region-inference's commit message
feat: conservative local non-aliasing proofs (#694)

Add a sound intraprocedural region-inference slice that proves a small,
useful set of non-aliasing facts inside one function body with no manual
annotations.

Each binding is assigned an abstract region. Two distinct owned local
variables get distinct regions, so references rooted at different locals
are proven disjoint. A freshly allocated local is proven disjoint from
every parameter, because it is allocated in this frame after the
parameters were bound to caller storage.

The analysis declines wherever it cannot prove disjointness: two
references rooted at parameters (the caller may pass the same buffer for
both), a value of unknown provenance such as a function-call result, a
reassigned or redeclared binding whose region is ambiguous, and two
references rooted at the same variable. It never claims disjointness it
cannot justify, so a False from may_alias is safe to act on.

restrict_candidates exposes the local bindings proven disjoint from every
parameter and from each other. That is the sound subset the C and MLIR
backends may annotate on local pointer temporaries, the hook #731 needs.
Proving two parameters disjoint is out of scope here: it needs the
interprocedural boundary work still open on #694.

Tests cover the two proven facts and the negative cases where aliasing is
possible and the analysis correctly declines.

archive/feat/690-arena-domains

Toggle archive/feat/690-arena-domains's commit message
feat: bind arena memory to the arena instance's declared domain (#690)

Memory bumped from a module-static arena now carries that arena's own
declared @Lifetime(D). The v0 checker already bound arena_alloc's result
to a bare arena parameter and rejected storing it in a longer-lived
location from a domain-annotated function. This reads the arena instance's
declared domain when the arena argument names a module static (written
&arena or arena), so a frame arena bumped into a longer-lived static or an
annotated field is caught, even from a function that declares no domain.

The rule is provable from the arena declaration alone and adds no false
positive: an unannotated static arena defaults to application and never
outlives a target, an arena stored no longer than its own domain is
allowed, and an arena whose provenance is not a named static falls back to
the existing writer-domain rule. Ambiguous provenance stays allowed.

Adds tests/unit/test_arena_domains.py (14 cases, positive and negative).