diff options
author | Björn Gustavsson <[email protected]> | 2016-09-26 15:01:19 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-10-05 13:00:45 +0200 |
commit | 0c599bcad1e7f5f66dd2342ab27791048145e892 (patch) | |
tree | 2f9702b3f3c829d6862df0cc193d5abc394251b4 /lib/compiler/src/beam_block.erl | |
parent | 3f3f25b23379b1afb15cc97462cf5d385690f5a0 (diff) | |
download | otp-0c599bcad1e7f5f66dd2342ab27791048145e892.tar.gz otp-0c599bcad1e7f5f66dd2342ab27791048145e892.tar.bz2 otp-0c599bcad1e7f5f66dd2342ab27791048145e892.zip |
beam_block: Avoid unsafe inclusion of get_map_elements in blocks
c2035ebb8b restricted the get_map_elements instruction so that it
could only occur at the beginning of a block. It turns out that
including it anywhere in a block is unsafe.
Therefore, never put get_map_elements instruction in blocks.
(Also remove the beam_utils:join_even/2 function since it is no
longer used.)
ERL-266
Diffstat (limited to 'lib/compiler/src/beam_block.erl')
-rw-r--r-- | lib/compiler/src/beam_block.erl | 10 |
1 files changed, 0 insertions, 10 deletions
diff --git a/lib/compiler/src/beam_block.erl b/lib/compiler/src/beam_block.erl index ec41925beb..6a35191f6e 100644 --- a/lib/compiler/src/beam_block.erl +++ b/lib/compiler/src/beam_block.erl @@ -58,13 +58,6 @@ blockify(Is) -> blockify([{loop_rec,{f,Fail},{x,0}},{loop_rec_end,_Lbl},{label,Fail}|Is], Acc) -> %% Useless instruction sequence. blockify(Is, Acc); -blockify([{get_map_elements,F,S,{list,Gets}}|Is0], Acc) -> - %% A get_map_elements instruction is only safe at the beginning of - %% a block because of the failure label. - {Ss,Ds} = beam_utils:split_even(Gets), - I = {set,Ds,[S|Ss],{get_map_elements,F}}, - {Block,Is} = collect_block(Is0, [I]), - blockify(Is, [{block,Block}|Acc]); blockify([I|Is0]=IsAll, Acc) -> case collect(I) of error -> blockify(Is0, [I|Acc]); @@ -220,7 +213,6 @@ move_allocates_1([], Acc) -> Acc. alloc_may_pass({set,_,_,{alloc,_,_}}) -> false; alloc_may_pass({set,_,_,{set_tuple_element,_}}) -> false; -alloc_may_pass({set,_,_,{get_map_elements,_}}) -> false; alloc_may_pass({set,_,_,put_list}) -> false; alloc_may_pass({set,_,_,put}) -> false; alloc_may_pass({set,_,_,_}) -> true. @@ -235,8 +227,6 @@ opt([{set,_,_,{line,_}}=Line1, {set,[D2],[{integer,Idx2},Reg],{bif,element,{f,0}}}=I2|Is]) when Idx1 < Idx2, D1 =/= D2, D1 =/= Reg, D2 =/= Reg -> opt([Line2,I2,Line1,I1|Is]); -opt([{set,[_|_],_Ss,{get_map_elements,_F}}=I|Is]) -> - [I|opt(Is)]; opt([{set,Ds0,Ss,Op}|Is0]) -> {Ds,Is} = opt_moves(Ds0, Is0), [{set,Ds,Ss,Op}|opt(Is)]; |