aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_z.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-08-31 16:06:37 +0200
committerBjörn Gustavsson <[email protected]>2012-10-09 15:24:41 +0200
commitb44f86b779f0b8579e4df2a98930ac3150c6c07c (patch)
treeba10bf906e4432f12a9a7aa6d6ee1af7735dfacf /lib/compiler/src/beam_z.erl
parent105e056cddaf765952d58813e2ec5c9bdfd4403c (diff)
downloadotp-b44f86b779f0b8579e4df2a98930ac3150c6c07c.tar.gz
otp-b44f86b779f0b8579e4df2a98930ac3150c6c07c.tar.bz2
otp-b44f86b779f0b8579e4df2a98930ac3150c6c07c.zip
Rewrite bs_put* instructions to a generic bs_put instruction
Seven bs_put_* instructions can be combined into one generic bs_put instruction to avoid some code bloat. That will also improve some optimizations (such as beam_trim) that did not handle all bs_put* variants.
Diffstat (limited to 'lib/compiler/src/beam_z.erl')
-rw-r--r--lib/compiler/src/beam_z.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_z.erl b/lib/compiler/src/beam_z.erl
index 706500e01c..7da6391f1f 100644
--- a/lib/compiler/src/beam_z.erl
+++ b/lib/compiler/src/beam_z.erl
@@ -27,8 +27,9 @@ module({Mod,Exp,Attr,Fs0,Lc}, _Opt) ->
Fs = [function(F) || F <- Fs0],
{ok,{Mod,Exp,Attr,Fs,Lc}}.
-function({function,Name,Arity,CLabel,Is}) ->
+function({function,Name,Arity,CLabel,Is0}) ->
try
+ Is = [undo_rename(I) || I <- Is0],
{function,Name,Arity,CLabel,Is}
catch
Class:Error ->
@@ -36,3 +37,11 @@ function({function,Name,Arity,CLabel,Is}) ->
io:fwrite("Function: ~w/~w\n", [Name,Arity]),
erlang:raise(Class, Error, Stack)
end.
+
+undo_rename({bs_put,F,{I,U,Fl},[Sz,Src]}) ->
+ {I,F,Sz,U,Fl,Src};
+undo_rename({bs_put,F,{I,Fl},[Src]}) ->
+ {I,F,Fl,Src};
+undo_rename({bs_put,{f,0},{bs_put_string,_,_}=I,[]}) ->
+ I;
+undo_rename(I) -> I.