aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_a.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-09-05 12:38:45 +0200
committerBjörn Gustavsson <[email protected]>2012-10-10 15:37:49 +0200
commite199e2471a6468a1908638d1b9fb863ea39e4d0e (patch)
tree41a7c081e26843d0638783fcef753d1de9aaabab /lib/compiler/src/beam_a.erl
parent47d109fc4eda1288e8d21a31b603b3cfc300536a (diff)
downloadotp-e199e2471a6468a1908638d1b9fb863ea39e4d0e.tar.gz
otp-e199e2471a6468a1908638d1b9fb863ea39e4d0e.tar.bz2
otp-e199e2471a6468a1908638d1b9fb863ea39e4d0e.zip
Break apart tail-recursive call instructions
Somewhat reduce the code bloat by eliminating special cases.
Diffstat (limited to 'lib/compiler/src/beam_a.erl')
-rw-r--r--lib/compiler/src/beam_a.erl16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_a.erl b/lib/compiler/src/beam_a.erl
index ed594bb0d4..1c51226314 100644
--- a/lib/compiler/src/beam_a.erl
+++ b/lib/compiler/src/beam_a.erl
@@ -31,7 +31,7 @@ module({Mod,Exp,Attr,Fs0,Lc}, _Opt) ->
function({function,Name,Arity,CLabel,Is0}) ->
try
%% Rename certain operations to simplify the optimization passes.
- Is1 = [rename_instr(I) || I <- Is0],
+ Is1 = rename_instrs(Is0),
%% Remove unusued labels for cleanliness and to help
%% optimization passes and HiPE.
@@ -44,6 +44,20 @@ function({function,Name,Arity,CLabel,Is0}) ->
erlang:raise(Class, Error, Stack)
end.
+rename_instrs([{apply_last,A,N}|Is]) ->
+ [{apply,A},{deallocate,N},return|rename_instrs(Is)];
+rename_instrs([{call_last,A,F,N}|Is]) ->
+ [{call,A,F},{deallocate,N},return|rename_instrs(Is)];
+rename_instrs([{call_ext_last,A,F,N}|Is]) ->
+ [{call_ext,A,F},{deallocate,N},return|rename_instrs(Is)];
+rename_instrs([{call_only,A,F}|Is]) ->
+ [{call,A,F},return|rename_instrs(Is)];
+rename_instrs([{call_ext_only,A,F}|Is]) ->
+ [{call_ext,A,F},return|rename_instrs(Is)];
+rename_instrs([I|Is]) ->
+ [rename_instr(I)|rename_instrs(Is)];
+rename_instrs([]) -> [].
+
rename_instr({bs_put_binary=I,F,Sz,U,Fl,Src}) ->
{bs_put,F,{I,U,Fl},[Sz,Src]};
rename_instr({bs_put_float=I,F,Sz,U,Fl,Src}) ->