Repository navigation
buffer: one byte-access API; perry-ffi stops writing at cell+8 (B1) - #12103
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (59)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ze (layout ratchet)
|
Rebased onto main c85c2db (#12104 streams, #12105 statepoints), head 96cc204. The payload ABI is reconciled to v2: the family descriptor names a PayloadVTable, so there is one descriptor, with separate byte-span and stream digests. #12096's new size_of::() in fromspace_scan now goes through buffer_payload_size (caught by the layout ratchet). Checks on head:
tsc RSS (+2.1 MB median, THP off, n=5): file-backed code pages. Anonymous memory is flat to −1 MB, and arena_live and GC counts are identical. Section sizes are identical apart from 512 B less .text; .perry_src is at the same offset. The extra resident pages are in the binary's r-xp mapping (65.0 → 68.6 MB). Explained under PERF_POLICY rule 2. |
Refs #11919. Buffer slice B1 of
BUFFER-DESIGN.md; owner decision 85.Removes: every native extension's raw write at
cell+8.perry-ffi::alloc_buffernow copies throughjs_perry_bytes_copyandBufferHeaderis opaque, so an extension can't derive a payload address from it. 14 runtime/stdlib raw writers move onto one access API:buffer/access.rs, bun_compat, child_process, dgram, embedded, fs, node_v8, tls, typedarray (duplicate resolvers unified), and stdlib ethers, tls and zlib.Adds:
buffer::bytes, a single API for byte access:no_gctoken and ends before any allocation or JS;The C ABI
js_perry_bytes_{borrow,pin,unpin,new,copy,adopt}lives innative_payload_abi.rs, under the payload digest shared with draft #12064. There is no new header size, table, cache, latch, placement threshold or codegen rule. A source ratchet (scripts/check_buffer_layout.py) blocks new raw-layout sites.Tests (current main merged):
Witnesses cover a moving collection during a pin, detach lifetime, spans across every current placement, NativeArena disposal, a native-backed allocation through the
alloc_bufferABI, and two agents pinning a shared buffer. Each has a child sabotage that turns it red: restoring the cell+8 copy, dropping the owner root, freeing on detach, and corrupting each converted producer.Known limit:
pinrefuses engine-owned foreign memory, the wasmmemory.growcase. Borrowing still covers it.Program A/B: in the comment below.