Repository navigation
Conversation
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.
The last piece Perceus reuse was waiting on. A call whose argument the caller is done with hands over the reference its register holds, rather than adding one and giving it up after the call returns.
Why it matters. The reuse #124 added fires only when the cell's count is 1. Passing a value to a function made it 2, and the caller's own release came after the call, so the callee always saw 2 and never reused:
With the move, the callee is the only holder and the cell it drops is one it may overwrite.
How it works.
moves_on_last_useruns over each function's instructions once the loader has built them: a call followed by theDropof one of its own argument registers marks that argument moved, and a moved argument is taken out of its register instead of shared.Dropstays where it is. The register is empty by then, so it does nothing — and a jump that lands on it without the call having run still finds the value and releases it. Nothing is deleted, so no jump target moves.f(x, x)shares once and moves once, which is exactly the two references the callee needs.DropReuseis left alone, so a cell this frame has already paired with a constructor of its own stays here.Numbers.
add_oneover a 1000-cell list, beforeEvery
Consof the new list is the matching one of the old, written over. Three hundred passes over a 3,000-element list: 0.09 s → 0.05 s, best of three, release build. The loop from #124 also improves, 2 allocations to 1.Tests. A new one in
crates/scarlet_vm/tests/run.rspins the zero: the walk allocates nothing and reuses 1000, and still prints the right sum. #124's loop test moves to its new counts. Every.scrlinexamples/andtests/programs/prints exactly what it printed before.All seven CI gates pass locally. hawk ran for the host target, and nothing here is gated on a cfg.