-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: move
not resetting source location
#1293
Conversation
Instead of in the code generator(s), lower the magics with a combined MIR pass. This also fixes `move` calls not resetting the source location when using the VM backend (`vmgen` implemented the magic improperly). `jsgen` had a similar bug, where locations of primitive types were not reset properly -- this is fixed too.
Handling the `mMove` and `mWasMoved` magics is obsolete.
Scanning the body of every procedure for magics has overhead, and it'd be better to only run the pass if the relevant magics are actually used within the body. My plan is store a As for For example, for: var x = @[...]
var y = move(x) the compiler currently injects a destructor for both |
Checking whether `extract` reset the value was disabled for the VM, since `move` did previously not reset the source location.
This was a change that unintentionally made its way into the earlier commit.
/merge |
Merge requested by: @saem Contents after the first section break of the PR description has been removed and preserved below:
|
Summary
Use a MIR pass to lower the
move
andwasMoved
magic calls intoassignments, fixing
move
not always resetting the source location forboth the VM and JS backends. The C backend was not affected.
Details
A
x = move(y)
call is now lowered into the following MIR:and a
wasMoved(x)
call into:which is equivalent in behaviour to the code previously produced by
cgen
-- using a shared MIR pass for the lowering ensures that thebehaviour is consistent across all backends.
The implementation of the two magics is removed from each code
generator, and a test for making sure
move
works correctly is added.Previous behaviour
For the VM backend, the source location was never reset on
move
,while for the JS backend, the source location was reset with
genericReset
, which left record-like locations empty (reading thefields then yield
undefined
) and ignores primitive types like int orfloat.