aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test/os_SUITE_data/my_echo.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-08-09 14:19:18 +0200
committerBjörn Gustavsson <[email protected]>2017-08-10 12:14:56 +0200
commit3e1d141e4d22708788af1a14401f257f4153fbae (patch)
tree669e57ef3cd513a78091c18cbfc9a2c2ac48c1f4 /lib/kernel/test/os_SUITE_data/my_echo.c
parente25f673d520342bfe7cd479ef6b850a57f8ab1ea (diff)
downloadotp-3e1d141e4d22708788af1a14401f257f4153fbae.tar.gz
otp-3e1d141e4d22708788af1a14401f257f4153fbae.tar.bz2
otp-3e1d141e4d22708788af1a14401f257f4153fbae.zip
Generalize optimization of "one-armed" cases
A 'case' expression will force a stack frame (essentially in the same way as a function call), unless it is at the end of a function. In sys_core_fold there is an optimization that can optimize one-armed cases such as: case Expr of Pat1 -> DoSomething; Pat2 -> erlang:error(bad) end, MoreCode. Because only one arm of the 'case' can succeed, the code after the case can be move into the successful arm: case Expr of Pat1 -> DoSomething, MoreCode; Pat2 -> erlang:error(bad) end. Thus, the 'case' is at the end of the function and it will no longer need a stack frame. However, the optimization in sys_core_fold would not be applied if there were more than one failing clause such as in this code: case Expr of Pat1 -> DoSomething, MoreCode; Pat2 -> erlang:error(bad); _ -> erlang:error(case_clause) end. Generalize the optimization to handle any number of failing clauses at the end of the case. Reported-by: bugs.erlang.org/browse/ERL-452
Diffstat (limited to 'lib/kernel/test/os_SUITE_data/my_echo.c')
0 files changed, 0 insertions, 0 deletions