diff options
author | Björn Gustavsson <[email protected]> | 2015-04-18 05:53:16 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-04-22 10:14:54 +0200 |
commit | 2e2d583a49939026ec9b959f9b7941d3c2d084f2 (patch) | |
tree | fea392fcb28695b0b129c2f2de36d40377e604ed /lib/compiler/src/beam_z.erl | |
parent | 0971feb23d553bb51b04eb78fbf76c4bc19b4b93 (diff) | |
download | otp-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_z.erl')
-rw-r--r-- | lib/compiler/src/beam_z.erl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_z.erl b/lib/compiler/src/beam_z.erl index 0c7bef9183..47e786034d 100644 --- a/lib/compiler/src/beam_z.erl +++ b/lib/compiler/src/beam_z.erl @@ -74,6 +74,13 @@ undo_rename({bs_init,F,{I,Extra,U,Flags},Live,[Sz,Src],Dst}) -> {I,F,Sz,Extra,Live,U,Src,Flags,Dst}; undo_rename({bs_init,_,bs_init_writable=I,_,_,_}) -> I; +undo_rename({test,bs_match_string=Op,F,[Ctx,Bin0]}) -> + Bits = bit_size(Bin0), + Bin = case Bits rem 8 of + 0 -> Bin0; + Rem -> <<Bin0/bitstring,0:(8-Rem)>> + end, + {test,Op,F,[Ctx,Bits,{string,binary_to_list(Bin)}]}; undo_rename({put_map,Fail,assoc,S,D,R,L}) -> {put_map_assoc,Fail,S,D,R,L}; undo_rename({put_map,Fail,exact,S,D,R,L}) -> |