diff options
author | Björn Gustavsson <[email protected]> | 2018-10-30 06:25:40 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2018-10-30 09:40:37 +0100 |
commit | d9470c07acc8d9b5f18676d852a0ff1707788e9e (patch) | |
tree | 9f64e1c12a8ae77537600904ea587ce08ba9c0e2 /erts/emulator/Makefile | |
parent | b36b359d4cb9988c0c24130023cf89e92b6577a4 (diff) | |
download | otp-d9470c07acc8d9b5f18676d852a0ff1707788e9e.tar.gz otp-d9470c07acc8d9b5f18676d852a0ff1707788e9e.tar.bz2 otp-d9470c07acc8d9b5f18676d852a0ff1707788e9e.zip |
beam_except: Generalize translation to func_info instructions
The `beam_except` pass replaces some calls to `erlang:error/1` or
`erlang:error/2` with specialized instructions in order to reduce the
size of the BEAM code.
In functions that do binary matching, `beam_except` would fail to
translate the instructions that generate a `function_clause`
exception. Here is an example:
bsum(<<H:16,T/binary>>, Acc) ->
bsum(T, Acc+H);
bsum(<<>>, Acc) ->
Acc.
The BEAM code that generates the `function_clause` exception looks
like this:
{label,4}.
{test_heap,2,3}.
{put_list,{x,1},nil,{x,1}}.
%% The following two instructions prevents the translation.
{bs_set_position,{x,2},{x,0}}.
{bs_get_tail,{x,2},{x,0},3}.
{test_heap,2,2}.
{put_list,{x,0},{x,1},{x,1}}.
{move,{atom,function_clause},{x,0}}.
{line,...}.
{call_ext,2,{extfunc,erlang,error,2}}.
Make the translation of `function_clause` exceptions smarter, so
that the following code will be produced:
{label,4}.
{bs_set_position,{x,2},{x,0}}.
{bs_get_tail,{x,2},{x,0},3}.
{jump,{f,1}}. %Jump to `func_info` instruction.
(This issue was noticed when looking at the code generated by
https://github.com/tomas-abrahamsson/gpb.)
Diffstat (limited to 'erts/emulator/Makefile')
0 files changed, 0 insertions, 0 deletions