feat(js): witnesses, trait values, shared objects and the counts (slice 3 of #63) #703
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/701-js-witnesses-close"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Slice 3 of the JavaScript back end (#63):
CallWitness,TraitValue,Object,SharedObject, witness tables,Retain,Release,Clear,EndOfScopeand the drop/close()order.What changed
backend/javascript/count.trb: release functions (r<typeId>),rcon shared objects,close()then field releases in reverse declaration order.backend/javascript/witness.trb: witness table classesW<trait>, instancesw<id>built on demand,O<count>trait value objects, thunks that retain owned operands.body.trb,type.trb,emit.trb,writer.trb: witness parameters appended to functions and calls,Copy/Retain/Release/Clear, closing analysis wired into the writer.js-witnesses-closeand eight programs onjs.allow:js-witnesses-close,traits,trait-values,generics,implementation-trait-arguments,destructor-scope-end,destructor-conditional-temporaries,destructor-using.docs/design/JAVASCRIPT-BACKEND.md: row 3 done, "What slice 3 left out".Decided by the loop
Closing.holdsaccepts;Retain/Releaseof any other type is a no-op, as in the C back end.MakeUniqueand aWrite-drivenrccheck are deferred to slice 4:Copyis an eagerclone()here (slice 2), so records never share storage and there is nothing to make unique.Left off
js.allow(12 programs of the issue's list): each needs a later-slice construct (list/map/Shownatives,BoxNew/LazyForce, ...), not a witness or count gap.Checked locally: new and existing allow-list programs under Node, with the nightly
torbrunning the compiler in the VM (no bootstrap, no gates);javascript_firstoutput identical to main;torb format --checkclean.torb docs checkreports 7 problems on unrelated pages with the nightly's native back end; no doc page changed.Closes #701
Review of
950140c(checked against #701 and the diff):js-witnesses-closeis new (generic bound with two types, trait values, supertrait narrowing, close order at scope end / early return / record / array, record copy with a shared object) with.expected,.exitand an.allocationsbudget; 8 programs added tojs.allow. CI is green on this head, includingconformance (JavaScript under Node.js), tier A/B, gates, pdisc, commit messages.parametersOfandemitCall; local slots now start aftersignature.parameters, so the table params do not collide. Counts exist only forClosing.holdstypes; the shared-object release runsclose()on a lent count of 1 and then releases fields in reverse order; null/undefined passed over.emitWritereleases the old value only for field/element/var-parameter places.MakeUnique/Write-drivenrcdeferral to slice 4 is stated with a rationale (eagerclone()since slice 2, so no shared storage) and recorded in the design doc.Non-blocking:
js.allowis listed in the PR with its reason; the body only says "12 programs ... each needs a later-slice construct". Name them with their finding in a follow-up comment or in the slice 4 issue so slice 4 knows what to pick up.MakeUniqueamong the instructions to handle; it is deferred, documented and consistent with the eagerclone(). Make sure the slice 4 issue carries it explicitly.