Skip to content

Remove the last element of a packed array inline on pop - #1282

Merged
ctate merged 1 commit into
mainfrom
ctate/remove-last-element-8cef99
Oct 18, 2026
Merged

ctate merged 1 commit into
mainfrom
ctate/remove-last-element-8cef99

Conversation

@ctate

@ctate ctate commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator
  • pop() and discarded pop() on a hole-free dense array clear the last slot and lower the length in emitted code. Holes, present undefined and sparse arrays keep the runtime call.
  • Stack push/pop benchmark: 0.39 s -> 0.22 s (Node 0.26 s). bench:runtime executables are unchanged, and the tsc-ts checker is neutral across 4 code layouts.
  • Adds corpus program 5681 covering pop results and length stores for every element kind.

pop and a discarded pop (the length - 1 store) branch on the array's
length and hole-free prefix bound. When the bound equals the length, the
last element is a present dense value: the emitted code clears its slot
and state, lowers the bound and the length, and moves the slot out (or
releases it for a discarded pop). An empty array answers undefined
without a call. Holes, present undefined and sparse storage keep the
runtime call.
@vercel

vercel Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Oct 18, 2026 12:59pm UTC

@ctate
ctate merged commit 31b52e2 into main Oct 18, 2026
66 checks passed
@ctate
ctate deleted the ctate/remove-last-element-8cef99 branch October 18, 2026 13:21

This branch was successfully deployed

1 active deployment
Preview — fc68a582 Deployed Oct 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant