Repository navigation
-mm=own: assigned parameters are kept, delete ends an owner; deterministic constant order - #868
Merged
Merged
Conversation
…compiler crashed about once in 500 runs)
OwnershipInferencePass runs on the functions of a module at once, on several
threads. For a field read through an interface whose value leaves its function
(`function dirOf(r: R) { return r.dir; }`) releaseCellReads asks accessorFiller
whether a class fills the field with a getter, and accessorFiller looked for the
accessor cell's global with module.walk - which goes into the body of every
function of the module, among them the ones the other threads were putting
releases in and erasing reads from at that moment. It read an operation list as
it was relinked, and the compiler ended with an access violation: about once in
300 to 700 compiles of test/tester/own/own_field_chain_let.ts, and once in a
run of the suite.
It now looks at the module's own operations only: that is where globals are,
and no function's pass changes that list.
Found from a crash dump: two worker threads in releaseCellReads, both in the
module walk. The compiler from before the fix failed 2 of 1,000 and 1 of 725
compiles of that test; with the fix, 0 of 4,000. Release suite on Windows x64;
LLVM IR of the 190 tests of test/tester/own that compile without the default
library is unchanged.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two refusals that said "yet", which stopped 14 of the 621 corpus files. A parameter the body assigns starts a local of its own for every type that owns a block, as rc does (it did under own only for a string and a Shared<T>). The local owns what it holds, so the function keeps the parameter and its callers give the argument up, by the rules of a parameter stored in a field; no pass changed. `p.length = n` starts a local only for a string. `delete place` is written as the assignment that clears the place when the place owns its value; a value no storage holds is released where its block ends; a parameter or a local that owns nothing is an error. Corpus under own: 466 -> 473 of 621. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ogram order RelocateConstantPass gathered the constants it moves to the top of a function in a SmallPtrSet and recreated them in the set's iteration order. With more than 16 of them the set is a hash table keyed by address, so the order - and with it the order of the string globals lowered from them - changed from run to run: 00param_assigned_owned.ts gave four different LLVM IR files in eight compiles (the same lines in another order). They are now kept in a vector in the order the function holds them; 12 compiles each of that file and the ray tracer, with and without --opt, under gc, rc and own, give one output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ests follow the new rule A parameter a nested function mentions gets no local of its own under own, so a closure that captures and assigns it is still "a captured parameter and cannot be assigned" rather than a kept parameter. own_err_delete compiles now (own_delete covers it), and own-mlirgen-matches-rc checks moves and field stores instead of delete, which own now writes as a clearing assignment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
-mm=own: assigned parameters anddelete-mm=ownrefused two constructs with "yet" errors, and those stopped 14 of the 621 corpus files.A parameter the body assigns now gets a local of its own for every type that owns a block. Before, only a string or a
Shared<T>got one, as under rc (#512). The local owns what it holds, so the function keeps the parameter, by the same rules as a parameter stored in a field, and no ownership pass changed:own_err_param_assigned).@keeps("x"), the same as a function that stores its parameter (own_err_param_assigned_exported).x = nof a local movesnin. This was the error Two fuzz rounds: own keeper literal elements, own parameters given a local's value, rc arguments read through a parameter's object #752 added, and it now works (fromLocalinown_param_assigned).x ??= v(a merge).deleteunder own emits nots.Delete:deleteis written as the assignment that clears it. The passes already follow that: a local whose value moved frees nothing, and a borrow of it ends (own_err_delete_borrowed).deleteof a parameter, or of a local that owns nothing, is an error (own_err_delete_param).Corpus under own: 466 → 473 of 621 compile. New tests:
own_param_assigned, under own, rc and gc.own_delete, under own and rc. Not gc: there, a delete after a move frees what the field holds.test-*-own-flipped-*).Docs:
docs/own-memory-model.mdgains a section, and the spec gains §81.Semantics worth a look: an assigned parameter now takes the argument away from the caller. That is consistent with kept parameters elsewhere, but it is a choice.
Compile output is the same from run to run
RelocateConstantPasscollected the constants it moves into aSmallPtrSetand recreated them in the set's iteration order. Above 16 entries that set is a hash table keyed by address, so constants, and the string globals lowered from them, came out in a different order on each run.00param_assigned_owned.tsgave 4 different IR files in 8 compiles. It is the variationdocs/compile-time-work.mdhad written off as "not a finding".The constants are now kept in a vector in program order. I compiled that file and the ray tracer 12 times each, with and without
--opt, under gc, rc and own, and every combination gave a single output.Testing
test-borrow-facts-*, a known environment issue on the development machine (staleCMAKE_ARtoolset).mainback in) is still in progress.src/lib.tscompiles under own and rc.mm_fuzzround.🤖 Generated with Claude Code