-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
sys_core_fold: Remove problematic optimization #6642
sys_core_fold: Remove problematic optimization #6642
Conversation
The optimization of nested lets was unsafe if the number of iterations for `sys_core_fold` ran out. There have been several attempts to fix that problem: 5076069 (erlang#6624) 30d4c45 (erlang#6631) ff05bee (erlang#6575) It's time to cut the Gordian knot by removing the optimization. While at it, remove all optimizations of nested lets, not only the offending part of the optimization. Running `scripts/diffable` before and after and diffing, shows changes in 40 modules. Most of them are neutral (the same instructions in a different order). There are few changes where an extra `test_heap` instruction has been introduced, for example in the `compile` module: - {test_heap,19,1}. + {test_heap,15,1}. {update_record,{atom,reuse},14,{y,0},{x,0},{list,[7,{x,0}]}}. - {put_tuple2,{x,0},{list,[{atom,ok},{y,1},{x,0}]}}. {try_end,{y,2}}. + {test_heap,4,1}. + {put_tuple2,{x,0},{list,[{atom,ok},{y,1},{x,0}]}}. {deallocate,3}. return. which was compiled from this source code: try Mod = cerl:concrete(cerl:module_name(Core)), {ok,Core,St#compile{module=Mod}} catch _:_ -> {ok,Core,St} end. In the `ct_run` module, the following code: case proplists:get_value(step, Misc) of undefined -> #opts{}; StepOpts -> #opts{step = StepOpts} end is no longer optimized to: StepOpts = proplists:get_value(step, Misc) #opts{step = StepOpts} There are also improvements in a few modules. Closes erlang#6633 Closes erlang#6635
CT Test ResultsNo tests were run for this PR. This is either because the build failed, or the PR is based on a branch without GH actions tests configured. Results for commit 19aa6b1 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 |
8cde394
to
19aa6b1
Compare
I have included a commit authored by @jhogberg that enhances an existing optimization so that the extra |
19aa6b1
to
22f0521
Compare
The optimization of nested lets was unsafe if the number of iterations for
sys_core_fold
ran out. There have been several attempts to fix that problem:5076069 (#6624)
30d4c45 (#6631)
ff05bee (#6575)
It's time to cut the Gordian knot by removing the optimization. While at it, remove all optimizations of nested lets, not only the offending part of the optimization.
Running
scripts/diffable
before and after and diffing, shows changes in 40 modules. Most of them are neutral (the same instructions in a different order). There are few changes where an extratest_heap
instruction has been introduced, for example in thecompile
module:which was compiled from this source code:
In the
ct_run
module, the following code:is no longer optimized to:
There are also improvements in a few modules.
Closes #6633
Closes #6635