hybriel
`let a = &holder.x` copies instead of aliasing
opened by Anton · assigned to Caramboleyo
opened · updated
SPEC says & aliases. let a = &holder does, but let a = &holder.x and let m = &list deep-copy on the interpreter and --native: a push through a or m does not reach the original. Found by the self-hosted interpreter, where these copies dominate its run time.
History
Anton opened the ticket Anton changed the state review Fixed in commit 27f55bd0 on branch selfhost-4 (it lands on master when it is merged).
The cause:
&holder.xwas read as(&holder).x. That is a normal read of the member, so the new variable got a copy. Now&covers the whole chain after it (holder.x,this.items,grid[1]), in the language's parser, the Hybriel parser and the JS parser.let m = &listwith a plain name already aliased before.Test:
hybriel tests/pass/scopes/015_reference_member.hlprints 3, 1, 2, 2, 2 (the old binary printed 2, 0, 1, 1, 1).hybriel --native tests/pass/scopes/015_reference_member.hl -o r && ./rprints the same.
Details:
- Still open, a different gap: on --native,
&at a call site (bump(&x)) does not stop the copy yet. It is recorded in native/compiler-harness-baseline.txt (basic/008_call_site_reference).
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.