aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_dead.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-04-18 05:53:16 +0200
committerBjörn Gustavsson <[email protected]>2015-04-22 10:14:54 +0200
commit2e2d583a49939026ec9b959f9b7941d3c2d084f2 (patch)
treefea392fcb28695b0b129c2f2de36d40377e604ed /lib/compiler/src/beam_dead.erl
parent0971feb23d553bb51b04eb78fbf76c4bc19b4b93 (diff)
downloadotp-2e2d583a49939026ec9b959f9b7941d3c2d084f2.tar.gz
otp-2e2d583a49939026ec9b959f9b7941d3c2d084f2.tar.bz2
otp-2e2d583a49939026ec9b959f9b7941d3c2d084f2.zip
Move rewriting of bs_match from beam_clean to beam_z
The actual bs_match_string instruction has four operands: bs_match_string {f,Lbl} Ctxt NumBits {string,ListOfBytes} However, v3_codegen emits a more compact representation where the bits to match are packaged in a bitstring: bs_match_string {f,Lbl} Ctxt Bitstring Currently, beam_clean:clean_labels/1 will rewrite the compact representation to the final representation. That is unfortunate since clean_labels/1 is called by beam_dead, which means that the less compact representation will be introduced long before it is actually needed by beam_asm. It will also complicate any optimizations that we might want to do. Move the rewriting of bs_match_string from beam_clean:clean_labels/1 to the beam_z pass, which is the last pass executed before beam_validator and beam_asm.
Diffstat (limited to 'lib/compiler/src/beam_dead.erl')
-rw-r--r--lib/compiler/src/beam_dead.erl4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_dead.erl b/lib/compiler/src/beam_dead.erl
index f4515ba2a7..adc3cebc62 100644
--- a/lib/compiler/src/beam_dead.erl
+++ b/lib/compiler/src/beam_dead.erl
@@ -459,8 +459,8 @@ count_bits_matched([{test,_,_,_,[_,Sz,U,{field_flags,_}],_}|Is], SavePoint, Bits
{integer,N} -> count_bits_matched(Is, SavePoint, Bits+N*U);
_ -> count_bits_matched(Is, SavePoint, Bits)
end;
-count_bits_matched([{test,bs_match_string,_,[_,Bits,_]}|Is], SavePoint, Bits0) ->
- count_bits_matched(Is, SavePoint, Bits0+Bits);
+count_bits_matched([{test,bs_match_string,_,[_,Bs]}|Is], SavePoint, Bits) ->
+ count_bits_matched(Is, SavePoint, Bits+bit_size(Bs));
count_bits_matched([{test,_,_,_}|Is], SavePoint, Bits) ->
count_bits_matched(Is, SavePoint, Bits);
count_bits_matched([{bs_save2,Reg,SavePoint}|_], {Reg,SavePoint}, Bits) ->