diff options
author | Björn Gustavsson <[email protected]> | 2013-12-10 16:10:58 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-12-19 11:58:20 +0100 |
commit | 73b7692a1b9f3b8e810e5528f574b230f4299788 (patch) | |
tree | d2acad6df64d9f3b1a3b14a1ceb4f70e8db17541 /lib/compiler/src/beam_flatten.erl | |
parent | 7fcde0281c04170595d437dc0480f4cd690c6fde (diff) | |
download | otp-73b7692a1b9f3b8e810e5528f574b230f4299788.tar.gz otp-73b7692a1b9f3b8e810e5528f574b230f4299788.tar.bz2 otp-73b7692a1b9f3b8e810e5528f574b230f4299788.zip |
Eliminate bottlenecks in sys_core_fold
Compiling programs with very many uses of the "dot notation"
for extracting a record element could be very slow. The reason
is that each extraction of a record element (R#r.a) would first be
transformed to code like this:
case R of
{r,rec0,_,_} -> rec0;
_ -> error({badrecord,r})
end
In Core Erlang, each '_' would be become a new variable. The
resulting code would be optimized by sys_core_fold, but the
optimization process could be very slow.
Profiling shows that sub_del_var/2 was the worst bottleneck, and the
sub_is_val/2 the second worst bottleneck. In both cases, the culprit
is the linear traversal of a very long list (the list of variable
substitutions). Fortunately, there already is a gb_set (the scope)
which contains all variables that are currently live. If a variable is
not known to be live, it is no point in doing the linear operation on
the list.
Diffstat (limited to 'lib/compiler/src/beam_flatten.erl')
0 files changed, 0 insertions, 0 deletions