core: teach the compiler the Buffer natives (commit 1 of 2 for #54) #299
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
Commit 1 of 2 for #54 (
Buffer<Item>).CLAUDE.md"Seed and breaking changes": a new native the std declares must be known to the seed before the std declares it. This issue teaches the compiler theBuffernatives and nothing else; thestd/coretype is #54, which waits for a published seed that contains this merge.Bufferstands on the list runtime thatArrayListalready uses (runtime/list.c: contiguous storage, in place when the storage has one owner), so no runtime C changes and no newtorb_symbol are needed. Both back ends read the same table (nativeEntries(); the VM'snativeSymbols()is derived from it), so one table change covers both.Acceptance criteria
compiler/src/backend/c/natives.trb: aBuffer.*row for each ofwithCapacity(container row,RuntimeKind.ListStorage),length,get,append,set,insert,removeAt,replaceBetween,reverseandclear, bound to the sametorb_list_*symbols and ownership lists as theArrayList.*rows. Do it by callinglistEntrieswith a flag or a second small function; noBuffer.sliceBetweenrow and noBuffer.compactrow (Buffer.sliceis TorbScript and copies,compactis not part ofBuffer; see #54).compiler/src/ir/instantiate.trbnewInstantiation:addPrimitive checker, table, "Buffer", PrimitiveKind.Runtime(RuntimeKind.ListStorage).addPrimitiveskips a name the prelude does not export yet, so this is inert until #54 lands - state that in the commit message.runtime/include/torb_natives.handruntime/machine_natives.cregenerated if the table change alters them (expected: unchanged, because the symbols are shared and the generator counts a shared symbol once);runtime/tests/natives_header_test.cstill compiles.compiler/tests/natives.test.trb: a test that everyBuffer.<member>above has a ready row with the same symbol as itsArrayListtwin, and thatBuffer.sliceBetweenandBuffer.compactare not in the table. A test incompiler/tests/bytecode.test.trbthatnativeSymbols()is unchanged by the new rows (same symbol set as before).std/,seed/,tests/conformance/.seed-> Run workflow, or the nightly). Not part of this PR.Dependencies
None. #54 depends on this one.
Notes
This is commit 1 of the two-commit rule. Do not declare
Bufferinstd/here: with the published seed not yet knowing the rows, CI could not bootstrap.Buffer<Item>as the heap storage primitive #54Buffer<Item>as the heap storage primitive #54[loop:torbscript] claim implement by session:loop-torbscript-20261010 until 2026-10-10T07:54Z
[loop:torbscript] claim implement by session:loop-torbscript-20261010 until 2026-10-10T14:02Z (re-claim: the previous worker died in the gateway gap between 02:10Z and 08:00Z without a write-back)
[loop:torbscript] implement: PR #301 (head
de7689ba, mergeable, argus requested); the resumed worker was killed by a gateway restart after the push, so this write-back comes from the loop session. CI is running on the head. next: waiting (review by argus; after the merge #54 needs a published seed containing it)[loop:torbscript] merge follow-up for #301 (merge commit
1724b82c2d): dispatched the forge workflowseedon main (Actions run 824, queued behind the runner backlog at 10:38Z). It packs and publishes the seed only after tier A and tier B pass. next: #54 stays notreadyuntilseeds.txton theseedsrelease lists a seed at or after1724b82; the loop checks that on its next tick.Buffer<Item>as the heap storage primitive #54Buffer<Item>joins theListfamily andBytesbecomesBuffer<UInt8>#300ArrayList, the hash tables and the tries onBuffer(step 1 of #55) #413ArrayList, the hash tables and the tries onBuffer#55std/tensoron the CPU (step 1 of #82) #438std/tensoron the CPU #82std/tensoron the CPU #82std/tensoron the CPU (step 1 of #82) #438std/tensor,Tensor<Scalar>over aBuffer(step 2 of #82) #691