-
Notifications
You must be signed in to change notification settings - Fork 3k
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
compiler: Optimize record updates #6033
compiler: Optimize record updates #6033
Conversation
CT Test Results 5 files 441 suites 1h 18m 20s ⏱️ For more details on these failures, see this check. Results for commit 85aa2e0. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
209f508
to
43592a7
Compare
43592a7
to
5b5be11
Compare
5ffc74f
to
a450a24
Compare
Thanks, I've refactored the changes to |
We don't need to stash the preserved term if it's currently live, making the code slightly shorter.
This is needed to keep the type information consistent in an upcoming commit that optimizes record updates. It will introduce a psuedo-instruction that does several updates at once, which gets converted either to a specialized instruction or a series of `setelement/3` calls during code generation. As the `setelement/3` is taken through `beam_call_types`, and that only dealt with normalized types prior to this commit, its type information would be less precise and could cause validation to fail.
This instruction updates several tuple fields at once, improving on the old `setelement/3 + set_tuple_element` method in the following ways: * Eliminates BIF call overhead, the tuple is copied and updated inline. * Doesn't require special treatment in the validator. * Uses heap allocations in the same manner as `put_tuple2` and friends. * When all fields are updated with the same value (runtime check), we can set `Dst=Src` and move on with our day. This is impossible with `set_tuple_element` as it requires a new copy every time to avoid creating illegal references from the old heap to the new heap.
a450a24
to
85aa2e0
Compare
#2080 isn't such a bad idea now that we have the JIT and far better type analysis. This PR is a modernized version that improves record update performance by a small but noticeable amount.