Repository navigation
Conversation
…callbacks, and tools/ownflow_dump.php to run it on MIR stopped before InsertMemoryOps
…nside try, unresolved gotos and out-of-range break levels throw; add tests/flow fixtures with tools/ownflow_check.sh
… for InsertMemoryOps, classifyTemp arms for EmitLlvm); corpus IR byte-identical
…GEN), FFI-call drift row, ctx trimmed to what is read (moduleFns)
…t is a sentinel, not null (a nullable typed array is a cell natively and came back NaN-boxed)
…nd MANTICORE_OWNFLOW=1
…place: a typed array returned through array<K,V>|null came back NaN-boxed
…o, as the one-hop coalesce does: $n->type->element ?? X handed back a null object
…chain coalesce is fixed
…th out of the body, before each loop-leaving break/continue too, and an if/else never unplants such an exit box-back: the slot left the loop raw and var_dump($v) past it read a string pointer as a float
…local, or an erased conditional's arm, moves), a live representation mismatch fails the build with function, name and line, self-copies take no +1, the trace env is read once, and a forced round clears stale insertions
…body also stores to it: a break taken before the store left the element raw in a slot read as a cell
…the return took no +1 on moves the owned arm that ran and drops the rest by identity; the pass no longer guesses which erased returns the emitter retains
# Conflicts: # src/Compile/Mir/Passes/EmitLlvmExpr.php # src/Compile/Mir/Passes/EmitLlvmModule.php
…name-level rc track, the transfer veto and the element-share scan are deleted (container moves and buffer-only shares are decided in the pass)
…s a return takes no +1 on (Return_::ownArms), and a bare-array free function returns +1 on every path so its caller's local owns the result (erasedarr class)
… the other owned locals die at return, the taken arm stays readable by getReturn()
…turn convention and container moves
…ocal release ops had no emitter and are deleted
… static method and closure returns +1 (Ownership::returnRetain decides, the emitter executes), callers own erased results; container stores move a local only when it is dead, else the container takes its own +1
…in / returnBorrowsObj), not the deleted emitter copies
…-callable callees; a live container store takes its +1 on the read itself; a concrete array rebind of an erased-result local shares its release class
…kes the local a cell (if/else, loop, switch, try): the join typed unknown read a string as an array; an erased-array result boxed into that cell is owned
…retained through a probe-boxed copy: the tag retain was a no-op on a raw buffer, so $c[] = $f ? $r : [] freed $r's array with the container
…n its own family (the receiver's ancestors, interfaces and module descendants), not from every method of that name
…lass too (erasedbuf)
… &&, ||, and, or, ?:, ??, ??=) is a cell: expression joins read the one joinDisagrees predicate
…narrowing reconciles its local that way, and the alias store cloned an array payload and dropped the original on every call (php-cs-fixer Token::equals with an array $other)
…r drops a freed stream as an object cell (musl SIGSEGV)
…-site cleanup landing pads (#25)
… helpers self-route on the frame header, so a join of the two is no representation mismatch
…ot drop walks elements by the static nesting
…ts name gives the slot, so an accumulator has one element repr on every path
…mon-supertype walk climbs an interface's extends list
…n Aware-extends-Iterator slot finds its iterator class as the emitter does
…after the call, which may end elsewhere (backtrace push, invoke in a try)
…se class, so a by-ref-suspect call no longer makes it owned and dropped on every call
…e clone dispatch's pass-through arm retains to match
…oto) outside its own handlers; a throw out of it chains the pending exception, a return discards it (#40)
…bel inside a finally no longer redefines its block and a goto stays inside its copy
…s cleanups before the fatal, so the unwound frames' destructors run first as in php
…ead of always the region start
…or; ehLower notes its first-chunk phi assumption
…ght as its previous and the frame's other locals are still dropped; chaining falls back to none when the prelude lacks __mc_finally_chain
…yCatch_: clones run before OwnershipFlow sets them
… boundary, and the trampoline's CFI ends any unwind that reaches the fiber stack's base
… instead of inlining each release, cutting self-build IR 4.6% and clang time
…a destructor that caught its own throw during the forced unwind no longer hands the fatal a cleared or wrong @__mir_thrown
…g prelude body fails the build instead of silently not chaining
This was referenced Oct 6, 2026
Closed
blacktrs
added a commit
that referenced
this pull request
Oct 7, 2026
…114) * Remove the Zend cold seed; docs follow the pinned-release bootstrap The compiler bootstraps from BOOTSTRAP_VERSION (#112), so the seed has no consumer left. Removed: bin/compile, tools/compile_files_mir.php, bin/build --seed/--auto-seed, gate.sh MC_ZEND_SEED, install.sh's Zend fallback, and the dead tools composer_data_smoke.sh, typecheck_scan.sh, split_ll.php, docker/iopoll/diag.sh, docker/symfony_probe.sh. selfhost_stability.sh rebuilds through the manifest path instead of Zend; composer.json drops the php requirement (the installer downloads the release or builds from the pin). Docs: every guide, README and design note audited against the tree — seed instructions removed or marked historical, ABI references point at MemoryAbi::VERSION (18), memory-abi.md gains the 64-byte descriptor (json_fn), the v14 BIGINT box and the v18 native buffer block, pass tables gain NarrowScalarGuards, ResolveMethodFcc, ResolveOverloads, SpillFreshBases and OwnershipFlow. * docs/design: ownership flow, native buffers and stage0 bootstrap notes Three shipped designs had no design note: per-program-point ownership (OwnershipFlow, #15/#104), the native fixed-width buffer runtime behind SplFixedArray and Manticore\Ds (#108), and the pinned-release bootstrap (#112/#114). Each is derived from the code it cites; AGENTS.md links the stage0 note.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ownership of rc locals is now decided per program point by a static dataflow, instead of "one flavor per local name, else leak it forever". The old name-level machinery is gone.
What changed
New analysis (MIR)
Mir\Flow\Forward+Lattice: a generic structured forward dataflow over tree-shaped MIR (if/loops/switch/match/try/goto/break N), with edge callbacks naming the predecessor.Mir\Ownership: one classifier for "is this value +1" (store side and temp side), shared by the pass and the emitter. It replaces the twin predicates that had to agree character for character.OwnershipFlowpass (replaces the rc track ofInsertMemoryOps, which keeps only the arena scope):Emitter: executes the planned ops (
drop/own_retain/own_shareand fields on StoreLocal, Return_, Foreach_, LoadLocal) and no longer decides ownership for locals. The following are deleted:rcObjLocals, the transfer and element-share vetoes;Conventions
arrayreturn (function, method, static, closure, first-class callable) is +1 on every path, decided from the declaration, so linkonce copies and stdlib agree. Callers own the result.Representation agreement (InferTypes): one join predicate (
joinDisagrees) for statement and expression-arm joins; an erased value meeting another kind makes the local a cell. Foreach bindings are boxed back on every loop exit. A base-, interface- or union-typed read of a property declared only in subclasses is the join of their declarations.Arena (hybrid mode)
Fixed on the way (several are pre-existing on main):
emitCellArrayToTypedmoved elements the source still owned), which crashed ~⅓ of compiles of one test;??on a raw NULL leaf, a nullable typed array through a cell.Later tasks landed on this branch
string &throwsTypeError); a by-ref write that retypes aforeachvalue variable no longer double-frees.catchvariable are released on overwrite; cell-element overwrite/unsetdrops by hint; conditional array arms join to cell elements; libraries declare stdlib from.sig.finallyon every exit (break/continue/return/throw) and exception chaining when a throw leavesfinally; 9.3 per-frame cleanup pads (owned locals of unwound frames are released, destructors of unwound frames run in php order, an uncaught throw force-unwinds before the fatal); 9.4finallyon break/continue/return.classImplementsTiface-extends, closure capture to an unresolved-receiver call, clone port).2714fbaemerged in (incl.dab9dc2bbucket-index copy andcbf73c0akey-before-base forisset/??); both ABI 15 lineages reconciled to ABI 16.Numbers
ce0c4435: 1640 / 0. CI atce0c4435: pending on all 6 (linux arm64/amd64, alpine arm64/amd64, arm64-native-runner, macos-arm64).cbf73c0a; self-build user +1.1% in a noisy A/B (+5.7% before the cold-helper optimisation); peak RSS +4% vscbf73c0a. Branch vs main: max RSS +12% (open, over budget).Closes
Fixes #17, Fixes #20, Fixes #21, Fixes #24, Fixes #25, Fixes #26, Fixes #31, Fixes #40, Fixes #42, Fixes #68, Fixes #77
The repros are promoted into
tests/aot/cases/. #67 (array_eq_nested_lists_null_rows) is fixed on macOS only; it stays an xfail on Alpine, so it is not closed here.Not in this PR (tracked)
Tasks 10 and 11 move to a new PR off main. Details:
docs/ROADMAP.md("Ownership redesign — what PR #15 leaves open").send()slot (Leak: a fresh value passed to Generator::send() is never released #22, Generator send slot is never cleared: next() after send() hands the sent value again #44);yieldleak (Leak: every heap value a generator yields into a foreach is never released #23); generator finished by an exception not marked finished (A generator finished by an uncaught exception is not marked finished #43); generatorfinally-return retval leak.libclass_smokecross-module class constant;\Ffi\Ptrin an untyped slot; cleanup pads for temps and__main;isset/??base-before-key on object/string bases; fiber argument's throwing destructor timing.