Repository navigation
Compile once, reuse everywhere: shared generic bodies, cached front-end work, outlined by-name dispatch - #645
Merged
Merged
Conversation
…on the injected set
…unter the injected set shifts
…uasort, uksort, natsort, natcasesort) Fixes #612
…ass's property no longer changes another class's private slot
…ength, so prelude bodies do not inline the program's function count
…ers do, epics by payoff
… variant is compiled once and reused from the object cache
…-byte word read out of bounds
…mutable state, copy runtime helpers up to 2 KB
…art in prog/ so only the shared objects travel
…eporting success over a short file
…(per-writer temp names, size-checked puts, one clang --version per process)
…e file on each compile
… disk, re-probing once when a link fails
…xing every gated file per compile
…ellified copy instead of a thunk per function per element type Fixes #638
…allback bodies stop carrying the program's call table A site whose arguments are plain locals passes their slots (a by-reference callee binds the caller's variable as before); a prelude site with element or property arguments passes values, as php calls an internal function's callback, and a by-reference callee there throws php's 'must be passed by reference, value given'. usort/uksort drop from 205 KB of IR each to a shared body.
…llback dispatch uasort's comparator wrapper bound the elements by reference; a by-reference comparator then corrupted the array instead of getting php's 'must be passed by reference, value given'.
…lude and runtime and were exceeded on every case
…ags on build, refuse only passed by-ref params, give dispatchers the call site - analyze/link/demand entries unwritten for 14 days are pruned when a new one is stored - build probes its link flags (a failed link there is usually the program's own; a retry reran ThinLTO) - a by-value callback dispatch refuses a by-reference parameter only when it is passed - by-name dispatchers take the call site's line and file, so an error raised in them points at the caller - plain-local dispatch excludes the same reference-backed locals the erased-invoke helper does
…in a by-name call (#642)
…hp drops them Fixes #641
The spread thunk read element k into parameter numFixed+k: a variadic tail got a scalar (max/min crashed, max over a string pack answered the first element), an omitted parameter got 0 instead of its default, and string keys bound by position. It now calls the function with the pack as a spread, which takes defaults, variadics and named keys like a direct call; a codegen builtin is sent to its same-named PHP body, since builtins index arguments positionally. Fixes #636 Fixes #637 Fixes #639 Fixes #640
…read fails to compile
…ch is not involved
…the positional emitter Fixes #644
…ad thunk binding through the callee Fixes #575
…mentCountError for surplus arguments - 17 stdlib functions gain php's missing parameters (context, use_include_path, options) and php's parameter names; strrchr before_needle, strspn length, str_word_count characters and file_get_contents offset/length work - 6 prelude functions gain theirs; openssl padding/digest_algo/serial_hex throw when given a value they cannot honour, pcntl_waitpid leaves resource_usage empty - an internal function called with more arguments than it declares throws php's ArgumentCountError; names the emitter answers by argument count (array_keys) are exempt, their declarations stay short on purpose - lowering no longer fills defaults into a call the emitter answers inline, so such a body can declare php's optional parameters once the pin has this Fixes #643
Fiber::__mcRun, __mc_array_map_zip and prelude closures spreading into a callable by name carried the program's dispatch inline; a spread never binds a reference, so its fixed values and pack go to a by-value dispatcher from any frame. ws_tls program part 7.74 -> 7.68 MB, inline arms outside dispatchers 0.
A cache entry that could not be removed (read-only cache) was read back by the retry, which then linked with the same stale flags.
…lified copy The copy was released after the call and leaked whenever the callee threw (2 KB per throw for a 64-int pack). The thunk's spread fill decodes each element by the buffer's own hint, so the raw pack reads right; a position past its end now stays 0 for the default instead of decoding a stray word into null (explode's limit).
The emitter releases some values only after a call returns: a variadic pack rebuilt into the callee's typed vec, a co-owning typed copy of a cell array. An unwind skipped those releases, so a spread into a variadic function, method, static method or constructor that throws leaked the pack (132 MB per 200k throws of a 64-int pack). A frame that may own such temps keeps a short list of (value, releaser): pushed before the call, popped after its release, drained first by every landing pad of the frame (cleanup, raising and catch). @main keeps it for its catch pads, and the by-name thunks and dispatchers get a pad of their own. The spread fill now reports the variadic tail it rebuilds, so the by-name spread path also stops leaking it on a normal return. Fixes #647
blacktrs
added a commit
that referenced
this pull request
Nov 11, 2026
Keeps this branch's diagnostics sink beside main's prelude-demand stats step (#645).
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.
Why
A compile spends most of its time redoing work that does not depend on the program: clang re-optimizes the same large prelude bodies for every program, the analyzer re-parses the prelude, link flags are re-probed, and every by-name call site inlines the whole program's call table. This PR removes that repeated work (roadmap E1 + E2 in
docs/design/compile-speed-roadmap.md) and fixes the dynamic-call bugs found on the way.What changes for a user
inc_decwarm compile 0.52 → 0.23 s. symfony-console warm 29 → 14 s (output identical to php). Program part ofws_tls_backpressure: clang 8.25 → 6.0 s.manticore cache/manticore cache clearshows and empties the object cache and the new side caches.intdivby name (intdiv() called by a run-time name with a spread pack throws "Call to undefined function intdiv()". #638), a spread into a builtin with a PHP body (strrev() called with a spread argument fails to compile. #644), the variadic uncaught-handler crash (A variadic closure forwarding to $this->{$m}(...$args), installed as the exception handler, crashes (SIGBUS) when an exception is uncaught. #575).ArgumentCountError(An internal function called with more arguments than it accepts returns normally instead of throwing ArgumentCountError. #643). An internal function's callback that takes a parameter by reference throws php's "must be passed by reference, value given" (Zend warns).ArrayObject/ArrayIteratorsort methods (ArrayObject::ksort() and its sibling sort methods are missing: calling one traps with "Call to undefined method". #612).How
linkonce_odrprelude/runtime bodies are cut into their own parts (ShareSplit), keyed by their exact IR text in the object cache, so a body compiled for one program is reused by every program that emits the same text. Made possible by removing program-specific names from those bodies (app module token, per-file prelude parse, stable closure and dynf ids). Gate:tests/generic/run.sh(identity and variant-hit floors),tests/generic/cache.sh.__mir_dyncall_*dispatchers, so prelude callback bodies (usort, uksort, uasort) no longer embed the program's table and become shareable.tests/ir_budgetceilings re-blessed (the old ones were exceeded on every case) and two cases added.Bootstrap
No new syntax in
src/.array_keyskeeps its one-parameter declaration untilBOOTSTRAP_VERSIONincludes this PR's lowering fix (an older compiler fills defaults into that inline builtin call); noted on #643.Testing
xfail.shno XPASS,tests/cli,tests/analyze,tests/generic/*,tests/ir_budget13/13; compiler bit-identical across generations (checked before the issue fixes).linux-target.yml/ci.ymlrun for the first time here.tools/difftest.sh.Fixes #575
Fixes #612
Fixes #636
Fixes #637
Fixes #638
Fixes #639
Fixes #640
Fixes #641
Fixes #643
Fixes #644
Fixes #647