aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-03-04 15:52:00 +0100
committerJohn Högberg <[email protected]>2019-03-05 15:41:20 +0100
commit359b065cf89d8513b1bfa6c4fd2699c72e2a7cb9 (patch)
tree9995d009d366cefe9f6b8559b32b7ef4fcae232a /lib/compiler/src
parent6a0de46369e72d06477681a50bc325e556069029 (diff)
downloadotp-359b065cf89d8513b1bfa6c4fd2699c72e2a7cb9.tar.gz
otp-359b065cf89d8513b1bfa6c4fd2699c72e2a7cb9.tar.bz2
otp-359b065cf89d8513b1bfa6c4fd2699c72e2a7cb9.zip
beam_validator: Infer types from bs_put instructions
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/beam_validator.erl30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl
index e50cc3696f..18e650f774 100644
--- a/lib/compiler/src/beam_validator.erl
+++ b/lib/compiler/src/beam_validator.erl
@@ -1018,24 +1018,42 @@ valfun_4({bs_put_string,Sz,_}, Vst) when is_integer(Sz) ->
valfun_4({bs_put_binary,{f,Fail},Sz,_,_,Src}, Vst) ->
assert_term(Sz, Vst),
assert_term(Src, Vst),
- branch(Fail, Vst, fun(V) -> V end);
+ branch(Fail, Vst,
+ fun(SuccVst) ->
+ update_type(fun meet/2, binary, Src, SuccVst)
+ end);
valfun_4({bs_put_float,{f,Fail},Sz,_,_,Src}, Vst) ->
assert_term(Sz, Vst),
assert_term(Src, Vst),
- branch(Fail, Vst, fun(V) -> V end);
+ branch(Fail, Vst,
+ fun(SuccVst) ->
+ update_type(fun meet/2, {float,[]}, Src, SuccVst)
+ end);
valfun_4({bs_put_integer,{f,Fail},Sz,_,_,Src}, Vst) ->
assert_term(Sz, Vst),
assert_term(Src, Vst),
- branch(Fail, Vst, fun(V) -> V end);
+ branch(Fail, Vst,
+ fun(SuccVst) ->
+ update_type(fun meet/2, {integer,[]}, Src, SuccVst)
+ end);
valfun_4({bs_put_utf8,{f,Fail},_,Src}, Vst) ->
assert_term(Src, Vst),
- branch(Fail, Vst, fun(V) -> V end);
+ branch(Fail, Vst,
+ fun(SuccVst) ->
+ update_type(fun meet/2, {integer,[]}, Src, SuccVst)
+ end);
valfun_4({bs_put_utf16,{f,Fail},_,Src}, Vst) ->
assert_term(Src, Vst),
- branch(Fail, Vst, fun(V) -> V end);
+ branch(Fail, Vst,
+ fun(SuccVst) ->
+ update_type(fun meet/2, {integer,[]}, Src, SuccVst)
+ end);
valfun_4({bs_put_utf32,{f,Fail},_,Src}, Vst) ->
assert_term(Src, Vst),
- branch(Fail, Vst, fun(V) -> V end);
+ branch(Fail, Vst,
+ fun(SuccVst) ->
+ update_type(fun meet/2, {integer,[]}, Src, SuccVst)
+ end);
%% Map instructions.
valfun_4({put_map_assoc=Op,{f,Fail},Src,Dst,Live,{list,List}}, Vst) ->
verify_put_map(Op, Fail, Src, Dst, Live, List, Vst);