php: lists, list and text natives and the manifest walk under PHP (slice 4B of #64) #836
Labels
No labels
loop
queue/failed
queue/queued
ready
status/parked
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
torbscript/language#836
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Step 5 of #64 (backend: PHP), slice 4 of
docs/design/PHP.mdsection 6, part B: storage and the walk of the manifest. Steps 1 to 4 and part A (#702, #727, #735, #761, #804; PR #809) are onmain:compiler/src/backend/php/{emit,body,type,natives,witness,count,writer}.trb,runtime/php/{core,integers,int64}.php,tools/conformance.sh --php,tests/conformance/php.allow,tools/php-output.sh,tools/php-int-vectors.sh, CI jobconformance-php(5.6.40, 7.4.33, 8.4). Todaynatives.trbmaps only the shown forms of numbers, booleans and characters,torb_process_exitand the wrapping pair ofUInt64;body.trbreports aContainerNewof kindListStorageas a finding, so every program that holds aListor builds text through the list natives stays offphp.allow, and nothing proves the table complete. This issue gives PHP the list storage and the list and text natives that go with it, and the walk of the manifest with an explicit deferred list. It is the sibling of the storage half of the JavaScript slice 4B (#724;runtime/javascript/list.mjs,compiler/tests/js-natives.test.trb,tests/conformance/js.deferred).Source
docs/design/PHP.mdsection 2.3 (FixedArray,Buffer), section 3 row K5, section 4 ("Copy on write", "Collections", "The memory limit"), section 6 row 4B and the paragraph "What slice 4A left out", section 7 (the row on the memory of a record and anIntlist).docs/design/JAVASCRIPT-BACKEND.mdsection 6 row 4B and #724 for the shape of the manifest walk and the deferred list;runtime/javascript/list.mjsandcompiler/src/backend/javascript/natives.trb(listed,located,dropping,storing) as the reference of what each list symbol takes;runtime/(the C list and text natives) as the meaning of each symbol.docs/design/NATIVES.md(the manifest,nativeEntries()incompiler/src/backend/c/natives.trb).What
php: lists, the list and text natives, and the walk of the manifest under PHP. Extend the PHP emitter and the runtime; no native is added to the manifest.
ContainerNewof kindListStoragebecomes a PHP object that owns a growing PHP array (a small class inruntime/php/list.php, written in front of a program only if the program reaches one of its functions, likeint64.php). The list natives ofruntime/javascript/list.mjsget PHP forms with the same arguments:torb_list_length,get,slice,add,set,insert,remove_at,replace,reverse,clear,compact, with the bounds and reversed-range panics of the C runtime, the location argument where the C prototype takes one, the release function of the dropped elements forset,replaceandclear, and the element copy foradd,setandinsertas the shared analysis says (PHP.md 4). The text natives that sit on the same path:torb_text_sliceandtorb_text_byte_at(substrandord, the wrappedsubstrof 2.5; panics for a cut inside a character as in C). A map or setContainerNewstays a named finding (epic #55).MakeUniqueandWrite-drivenrc(PHP.md section 4, "Copy on write"): decide, with the shared analysis ofbackend/shared/, whether a list element needsrcandMakeUniquein PHP, implement what the lists need, and pin by test thatCopyof a list shares the array until the first write (the engine's copy on write, section 4) and that no PHP reference is emitted.compiler/tests/php-natives.test.trb, walksnativeEntries()likejs-natives.test.trband fails for every entry that has no PHP form (anemitsIntrinsicintrinsic, a function ofruntime/php/, a body the IR generates, a container of kindListStorage) and is not on the explicit deferred listtests/conformance/php.deferred(pattern | tag | reason, a pattern a name or a name with one*, asjs.deferred). A line that matches no remaining entry fails too, so the list shrinks as slices land. Tags:4Cthe rest of the kernel natives of this slice (below),5floats andlibm(K3, K6,Float32),6tasks,8capability table and host operations,55maps and sets,unassigned(Decimal,Expression, the Unicode tables),vm. Copy the JavaScript list as the starting point and correct each tag for PHP.Inton 5.6 compared with C"): a small scripttools/php-memory.shrun byconformance-phpprints, for 5.6.40, 7.4.33 and 8.4,memory_get_usagefor 10^6Intlist elements, 10^6 byte-buffer elements and 10^5 records, next to the C sizes; the first green run's figures are copied into section 7 by hand and the row is marked pinned. The script never fails on a figure (a shared runner is noisy); it fails only if it cannot run.main: hash, power, checked conversions, parsers,CharandStringnatives beyond the two above, the page size andShown values are part C (below); floats,pack/unpack, tasks, maps and sets are later slices.Decided by the loop
CharandStringnatives, about 45 symbols) into one issue; for PHP that is two reviews. Part B (this issue) is storage, the two text natives on the list path,MakeUnique, the manifest walk with the deferred list and the memory figures. Part C is the rest of the natives of the kernel list ofcompiler/src/backend/javascript/natives.trb(kernel), the page size (Posix.configuration "PAGESIZE", K8), the narrowing conversionsInt8.tryFromand the like (named in "What slice 4A left out") and theShown values; each is a line ofphp.deferredtagged4Cuntil then, so the walk stays green, and Part C is filed when this one is merged, just in time as the contract asks. The #64 step 5 line says so.refintorb_list_add(ref, value)), and a class keeps one place for the length and the engine's copy on write. The JavaScript record chose a plain array for the same job because the engine there has one; PHP's arrays are copied on assignment, which is exactly why the object is wanted. Decided on the shape of the natives, not on a measurement; the memory figures above are recorded and the form can change without changing anything else if they are bad.tools/php-int-vectors.share not touched.Files
compiler/src/backend/php/{natives,body,emit,type,writer,count}.trb(theContainerNewcase, the list symbols,takesLocation,dropsElements,storesElement,isListNativeas in the JavaScriptnatives.trb, the write oflist.phponly when reached); newruntime/php/list.php;runtime/php/core.phponly for shared helpers.compiler/tests/php-natives.test.trb(the walk added next to the existing tests), newtests/conformance/php.deferred.tools/php-memory.sh,.forgejo/workflows/gates.ymlfor the call inconformance-php,tools/php-output.sh(a program with no list has nolist.phptext;php_first.trband the integer programs unchanged).tests/conformance/php.allowand, where a program prints lists, its existing expected files unchanged; newtests/conformance/php-lists.trbwith.expected,.stderr,.exit(every list native, an index out of range that panics with the location, a reversed range, a slice inside a multi-byte character, a copy that is written after the copy, aCloseelement dropped bysetandclear);tests/php-findings/updated (the list case removed, the map and set case stays).docs/design/PHP.md: row 4B marked done with its text corrected to the split, a row 4C for part C, a "What slice 4B left out" paragraph, section 7 row for the memory figures; docs regenerated astorb docsrequires.Tests
php.deferred; adding an entry tonativeEntries()with neither a PHP form nor a line fails it, and a line that matches no entry fails it.php-lists.trbpasses on the C, VM, JavaScript and PHP legs (JavaScript only if it already passes there; otherwise the PR says why) with one set of expected files, on 5.6.40, 7.4.33 and 8.4..expected,.stderrand.exitof the C leg and joinphp.allow; each candidate left off (map, set,Show, float, task, a part C native) is named in the PR with the finding or deferred tag. Candidates to try first, from the JavaScript 4B list:buffer-list,collect-through-wrappers,cons-stack-persists,bankers-queue,shared-top-level-const,buffer-field-derived.tools/php-output.sh: no output contains&$,= &or__destruct; a program with no list carries nolist.phptext; float arithmetic and a map still fail the build with a named finding and no file;php_first.trboutput unchanged.tools/php-memory.shruns on the three interpreters inconformance-phpand prints the three figures with the C sizes; the figures are in PHP.md section 7.Acceptance criteria
php-natives.test.trb) fails for an entry with no PHP form that is not ontests/conformance/php.deferred, passes onmainwith the list naming only entries of tags4C,5,6,8,55,vmandunassigned, and a stale line fails ittorb_text_slice,torb_text_byte_atbuild and run on 5.6.40, 7.4.33 and 8.4;php-lists.trbpasses on the C, VM, JavaScript (or the stated reason) and PHP legs with one set of expected filesphp.allowgrows by the programs listed in the PR, at leastbuffer-list; none is removed; each program left off is listed with its reasonphp_first.trband the integer programs produce the same PHP as before; a program with no list has nolist.phpcode; the JavaScript leg is unchanged (--jswith the samejs.allow)Intlist element and a byte buffer element against C) are printed byconformance-phpand recorded in PHP.md section 7; the statement there is marked pinned or amendeddocs/design/PHP.mdmarked done and split from a new row 4C, "What slice 4B left out" written;torb format --checkandtorb docs checkgreentools/check-commits.shclean;sh tools/gates.sh aand theconformance-phpjob green in forge CI (CI only, no local bootstrap or gates)Seed
Compiler, runtime and tools only: no syntax change, no new native, no new std name looked up by string, no new
Architecturecase. Not touched:seed/, releases.Size
One PR, one or two Conventional Commits (
feat(php): ...,test(php): ...). A few hours of implementer work: the list class and its eleven natives, the two text natives, the walk with its list and the memory script. Model: sonnet, thinking high (compiler work). Out of scope: part C (the rest of the kernel natives, the page size, the narrowing conversions,Shown values), maps and sets (epic #55), floats andlibm(slice 5), tasks,.nophpmarkers andtorb test, a minifier.Dependencies
main).Part of #64 (epic; do not close it).
ArrayList, the hash tables and the tries onBuffer#55[loop:torbscript] claim implement by session:loop-torbscript-836-implement until 2026-11-16T19:40:00Z
Reason: #836 is ready, one worker slot free, openPrs 3 of 8; it shares no path with #565 (ir passes) or the open PRs (PHP backend and runtime).
ArrayList, the hash tables and the tries onBuffer#55std/livepage placement (WEB slice 6) and the client script (slice 7) #103?in a body whose result type is inferred #747[loop:torbscript] release by session:loop-torbscript-836-implement: the worker ended; PR #839 (loop/836-php-lists, head
658f4650) is the live path, CI and the Argus review are pending. A red job gets a fix worker on the same branch.Scope amendment from PR #839 (reviewer finding). Acceptance criterion 3 is met only partly:
buffer-listis not inphp.allowin this slice because it reaches the kernel nativetorb_text_show_nested, which belongs to slice 4C (PHP.md row 4C). The criterion "at leastbuffer-list" therefore reads "the programs listed in PR #839;buffer-listmoves to 4C". TheMakeUniqueitem (a copy shares the array until the first write) also moves to 4C. The memory figures are now pinned in PHP.md section 7, measured byconformance-phpon head658f465.[loop:torbscript] claim fix by session:loop-torbscript-836-fix until 2026-11-16T21:30:00Z Reason: PR #839 (head
cdf65761) has red CI:tier B (linux-x64)andconformance (PHP 5.6, 7.4 and 8.4)failed in run 3187, and main had both green, so the failure is not inherited. A fix worker pushes to loop/836-php-lists.[loop:torbscript] release by session:loop-torbscript-836-fix: root cause of the red
tier Bandconformance-phpjobs wastests/conformance/php-lists-close.trbfailing the checker ("rowis never read again", line 32); fixed infc284b41onloop/836-php-lists(the last append is now followed by a read of the length, output unchanged). PR #839 is the live path: CI onfc284b41and Argus's re-requested review are pending; tier A and gates stay red from main until PR #840 lands.[loop:torbscript] wait: PR #839 carries the fix
fc284b41.conformance (PHP 5.6, 7.4 and 8.4)is green on it;tier Bis still running, andtier Ais red on the inherited json-schema entries that main fixed in #840 (the PR base predates that merge). The next step is Argus: review and landing once tier B is green; if tier A stays red after the landing rebase, the fix worker rebases on main. next: waiting (PR #839 tier B and Argus review)Post-merge follow-up (orion), PR #839 merged 2026-11-16 22:45 UTC as
7e267913on main.7e267913was still pending at the check (ci / commit messages,gates,pdiscon push). The change ships with the next release; no deploy target for the compiler itself.