aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_bsm.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-09-28 05:57:47 +0200
committerBjörn Gustavsson <[email protected]>2018-09-28 10:47:56 +0200
commit0bb261b730eff06cca524ea9999ff035585ef5b4 (patch)
treee057e70bc7fe53a7ec74577dfdb836707e7ae60b /lib/compiler/src/beam_bsm.erl
parent377f19f25aeec6939a6728bd0c4910086c22ccdc (diff)
downloadotp-0bb261b730eff06cca524ea9999ff035585ef5b4.tar.gz
otp-0bb261b730eff06cca524ea9999ff035585ef5b4.tar.bz2
otp-0bb261b730eff06cca524ea9999ff035585ef5b4.zip
Fix rare bug in binary matching (again)
2e40d8d1c51a attempted fix a bug in binary matching, but it only fixed the bug for the minimized test case. This commit removes the previous fix and fixes the bug in a more effective way. See the comments in the new code in `sys_core_bsm` for an explanation. This commit restores the optimizations in string.erl and dets_v9.erl that the previous fix disabled. I have not found any code where this commit will disable optimizations when they are actually safe. There are some changes to the code in ssl_cipher.erl in that some bs_start_match2 instruction did not reuse the binary register for the match context, but the delayed sub binary optimizations was never applied to the code in the first place. https://bugs.erlang.org/browse/ERL-689
Diffstat (limited to 'lib/compiler/src/beam_bsm.erl')
-rw-r--r--lib/compiler/src/beam_bsm.erl13
1 files changed, 1 insertions, 12 deletions
diff --git a/lib/compiler/src/beam_bsm.erl b/lib/compiler/src/beam_bsm.erl
index abc6e96c85..1c8e0e9854 100644
--- a/lib/compiler/src/beam_bsm.erl
+++ b/lib/compiler/src/beam_bsm.erl
@@ -310,18 +310,7 @@ btb_reaches_match_2([{test,bs_start_match2,{f,F},Live,[Bin,_],Ctx}|Is],
end;
btb_reaches_match_2([{test,_,{f,F},Ss}=I|Is], Regs, D0) ->
btb_ensure_not_used(Ss, I, Regs),
- D1 = btb_follow_branch(F, Regs, D0),
- D = case Is of
- [{bs_context_to_binary,_}|_] ->
- %% bs_context_to_binary following a test instruction
- %% probably needs the current position to be saved as
- %% the new start position, but we can't be sure.
- %% Therefore, conservatively disable the optimization
- %% (instead of forcing a saving of the position).
- D1#btb{must_save=true,must_not_save=true};
- _ ->
- D1
- end,
+ D = btb_follow_branch(F, Regs, D0),
btb_reaches_match_1(Is, Regs, D);
btb_reaches_match_2([{test,_,{f,F},_,Ss,_}=I|Is], Regs, D0) ->
btb_ensure_not_used(Ss, I, Regs),