aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_trim.erl
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-01-24 13:21:41 +0100
committerJohn Högberg <[email protected]>2019-01-24 13:22:15 +0100
commit6adc50b534d0db2be2e0bf5c4029cf22e45a84a1 (patch)
treeea35ffd8e25dff4ed97153d438cf3b97265399af /lib/compiler/src/beam_trim.erl
parenta0104bc16c8c6f57c2725d07b811bf3bcb0a2455 (diff)
downloadotp-6adc50b534d0db2be2e0bf5c4029cf22e45a84a1.tar.gz
otp-6adc50b534d0db2be2e0bf5c4029cf22e45a84a1.tar.bz2
otp-6adc50b534d0db2be2e0bf5c4029cf22e45a84a1.zip
beam_trim: Ignore type annotations
The type annotations inserted by beam_ssa_type and beam_ssa_bsm would inadvertently disable stack trimming, as unknown instructions are considered unsafe.
Diffstat (limited to 'lib/compiler/src/beam_trim.erl')
-rw-r--r--lib/compiler/src/beam_trim.erl8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_trim.erl b/lib/compiler/src/beam_trim.erl
index 51ff580a7a..acf3838da4 100644
--- a/lib/compiler/src/beam_trim.erl
+++ b/lib/compiler/src/beam_trim.erl
@@ -200,6 +200,8 @@ create_map(Trim, Moves) ->
(Any) -> Any
end.
+remap([{'%',_}=I|Is], Map, Acc) ->
+ remap(Is, Map, [I|Acc]);
remap([{block,Bl0}|Is], Map, Acc) ->
Bl = remap_block(Bl0, Map, []),
remap(Is, Map, [{block,Bl}|Acc]);
@@ -279,6 +281,8 @@ safe_labels([_|Is], Acc) ->
safe_labels(Is, Acc);
safe_labels([], Acc) -> cerl_sets:from_list(Acc).
+is_safe_label([{'%',_}|Is]) ->
+ is_safe_label(Is);
is_safe_label([{line,_}|Is]) ->
is_safe_label(Is);
is_safe_label([{badmatch,{Tag,_}}|_]) ->
@@ -337,6 +341,8 @@ frame_layout_2(Is) -> reverse(Is).
%% to safe labels (i.e., the code at those labels don't depend
%% on the contents of any Y register).
+frame_size([{'%',_}|Is], Safe) ->
+ frame_size(Is, Safe);
frame_size([{block,_}|Is], Safe) ->
frame_size(Is, Safe);
frame_size([{call_fun,_}|Is], Safe) ->
@@ -393,6 +399,8 @@ frame_size_branch(L, Is, Safe) ->
%% This function handles the same instructions as frame_size/2. It
%% assumes that any labels in the instructions are safe labels.
+is_not_used(Y, [{'%',_}|Is]) ->
+ is_not_used(Y, Is);
is_not_used(Y, [{apply,_}|Is]) ->
is_not_used(Y, Is);
is_not_used(Y, [{bif,_,{f,_},Ss,Dst}|Is]) ->