aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/sys_core_fold.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-03-23 11:51:28 +0100
committerBjörn Gustavsson <[email protected]>2018-03-23 15:13:58 +0100
commit9d2f5cde19cffca9a00b8fad8075bf160cc872d3 (patch)
tree0333cab6eb4452f1a0f533a7fa390cf6a8e7ef98 /lib/compiler/src/sys_core_fold.erl
parent43a91c5e461e3fbec924e332f42fd69b81be34b2 (diff)
downloadotp-9d2f5cde19cffca9a00b8fad8075bf160cc872d3.tar.gz
otp-9d2f5cde19cffca9a00b8fad8075bf160cc872d3.tar.bz2
otp-9d2f5cde19cffca9a00b8fad8075bf160cc872d3.zip
Add cerl_trees:next_free_variable_name/1
Diffstat (limited to 'lib/compiler/src/sys_core_fold.erl')
-rw-r--r--lib/compiler/src/sys_core_fold.erl8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl
index a9bd363ee1..0354981562 100644
--- a/lib/compiler/src/sys_core_fold.erl
+++ b/lib/compiler/src/sys_core_fold.erl
@@ -119,6 +119,14 @@ module(#c_module{defs=Ds0}=Mod, Opts) ->
function_1({#c_var{name={F,Arity}}=Name,B0}) ->
try
+ %% Find a suitable starting value for the variable
+ %% counter. Note that this pass assumes that new_var_name/1
+ %% returns a variable name distinct from any variable used in
+ %% the entire body of the function. We use integers as
+ %% variable names to avoid filling up the atom table when
+ %% compiling huge functions.
+ Count = cerl_trees:next_free_variable_name(B0),
+ put(new_var_num, Count),
B = find_fixpoint(fun(Core) ->
%% This must be a fun!
expr(Core, value, sub_new())