Repository navigation
mem: one var node per binder, and a call's result takes its regions by call - #80
Merged
Merged
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.
Two precision fixes from the
--memaudit (M9.4).One var node per binder. Polonius has one local per binding; Mem had one node per name in a def, so a shadowed name and the same name in two sibling scopes merged (1,026 vars on s2c). A pre-pass,
Mem.unshadow, renames each binder whose name its def already bound tox#n(its nth binder), and gives every use the name of the binder in scope (lexical: a val for the rest of its block, a pattern var for its arm). The name is printed throughConsole.captureBegin/captureEnd, the wayStore.textbuilds a string. The walks then see one name per binder. On s2c, 3 vars remain with two binders: two handlers'alloc/freeshare a bare def name (filed).A call's result by call. The result of every call of a fn took the regions of all its calls (
retOf(G, X), rin(X, R), callOf(N, G)), sobuild{sess}(..)andbuild{a}(..)both listed sess and a. Now each call node gets:callAt(F, line, R)for a handled region,callFreeAt(F, line)for a region its def runs in), and Mem joins it to the escape walk's call node before the solve (ecallIn,ecallFree);rin(C, R) :- argOf(M, G, I, C), rin(M, R), retP(G, I).This over-approximates a callee that returns no new box (its call still lists the region it runs in); a first version gated it on
snewRet(G)and cost 10.6 G on s2c, because of the atom order of the join.useAfterFreeno longer needs itsbinds == 1guard (shadowing is gone); theassignedguard stays (no kill at an assignment yet).New test
tests/s2/mem/binders.srs:BN.mk{s}called in r and in t (p holds r, q holds t), an innerpshadowing the outer one (p#2),BN.wrap{t}(p)(w holds t and r),BN.mk2with no choice (runs in t). Checked by hand; the program prints 11. Inprog/scope_shadow_innerthe outer x now holds only sess and the innerx#2only a.Checks:
failis empty on every prog test.--mem2.019 G -> 2.241 G (+11%: the rename pass and more var nodes).Mutants (each builds):
ecallInruleecallFreerule