forked from erlang/otp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compiler: Optimize most pure bifs to be guard bifs in try/catch
When put in a try, calling a guard bif with no side-effects and 6 other bifs ([PR-9042](erlang#9042)) are optimized to remove the try/catch. However, most pure bifs can be safely optimized in the same way in order to gain performance. This PR introduces a new internal instruction `call_pseudo_guard_bif` that enables the compiler to remove the try/catch around the bif. The instruction is designed to call the bif in the same way, but having more optimized error-handling in the runtime system. Example code: try float_to_list(A, utf8) catch _:_ -> error end. Before, assembly for the bif call after optimizations: {label,2}. {allocate,1,1}. {'try',{y,0},{f,3}}. {line,[{location,"zlc.erl",23}]}. {call_ext,1,{extfunc,erlang,float_to_list,1}}. {try_end,{y,0}}. {deallocate,1}. return. Now, assembly for the bif call after optimizations: {label,2}. {allocate,0,1}. {line,[{location,"zlc.erl",23}]}. {call_pseudo_guard_bif,1,{extfunc,erlang,float_to_list,1},{f,3}}. {deallocate,0}. return. Bifs that are optimized for try/catch in this change are listed in `pbif.tab`.
- Loading branch information
Showing
25 changed files
with
694 additions
and
102 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.