Repository navigation
-mm=own: tuple literals given to calls are given back; a rest element of an iterable - #1040
Merged
Merged
Conversation
… of an iterable
Tuple literals under -mm=own (a gap since before pre-alpha134):
- `h(["a" + i, 1])`: the new string was moved into the literal's in-place local, which nothing
releases; each call leaked it (2M calls: 47 MB -> 5 MB). A field of such a literal, read whole
only into what borrows it (a call that keeps none of it, an array a call borrows), is now a
borrow (isBorrowedTupleLiteralField), as a ts.CreateTuple given to such calls already was.
- `g([["a" + i, 1]])` and `new Map([["a" + i, 1]])` (the array through ts.OptionalValue): the array
of tuples looked as if it borrowed them, and was given back by nothing (51 MB / 173 MB -> 5 MB;
`new Map([["a", 1]])` 105 MB -> 5 MB). A tuple literal whose fields hold new values or string
constants is now a new value moved into the array (isInPlaceTupleLiteral), as a nested array
literal is, so the array owns it and goes with it. Object literals (named fields) are records
of their own and are left out of both.
`const [first, ...rest] = it` of an iterable (`m.entries()`, a Set, a generator) was refused
("spread is not implemented"): the rest is an array of what the iterator gives from there on, made
as `[...iterator]` is.
Still refused: a tuple literal given to a callee that keeps it (`k.keep(["a" + i, 1])`).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes the two items left open by #1039.
-mm=own: tuple literals given to calls leaked (a gap since before pre-alpha134). A tuple literal is built in place: a temporary
ts.Variable, filled field by field, then read whole. The inference moved the new string into that local, which nothing releases.h(["a" + i, 1]): a field store of such a literal whose tuple is only read into what borrows it (a call that keeps none of it, an array a call borrows) is now a borrow (isBorrowedTupleLiteralField,OwnershipInferenceMoves.cpp), as ats.CreateTuplegiven to such calls already was.g([["a" + i, 1]]),new Map([["a" + i, 1]]),new Map([["a", 1]]): the array literal looked as if it borrowed its tuples and was given back by nothing. A tuple literal whose fields hold new values or string constants is now a new value moved into the array (isInPlaceTupleLiteral,OwnedReturnConsumptionPass.cpp; also thets.CreateTupleof constants), as a nested array literal is.classifyRecords) and are left out of both.2M rounds, peak working set (own):
h(["a" + i, 1])g([["a" + i, 1]])new Map([["a" + i, 1]])new Map([["a", 1]])const [first, ...rest] = itof an iterable (m.entries(), a Set, a generator) was refused in every model ("spread is not implemented for type"). The rest is now an array of what the iterator gives from there on, made as[...iterator]is (MLIRGenVariables.cpp).Still refused (pre-existing): a tuple literal given to a callee that keeps it (
k.keepOne(["a" + i, i])).Tests:
00own_tuple_literal_arguments.ts,00array_pattern_rest_of_iterator.ts(jit/compile, none/rc/own). ctest 9865/9865 locally; DefaultLibtests.ps1 -Model ownrelease compile+jit all pass with this compiler.🤖 Generated with Claude Code