aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_validator.erl
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-08-29 18:27:45 +0200
committerBjörn-Egil Dahlberg <[email protected]>2017-03-24 10:53:14 +0100
commit14d709b0e07e899161a40bb43fc43fd6916f59ab (patch)
tree841aac1ed1a67417d4274215aeadbec3b1b2ead3 /lib/compiler/src/beam_validator.erl
parentf7d248a6794655809e2fdc7d0d1932bbb3dc8cc0 (diff)
downloadotp-14d709b0e07e899161a40bb43fc43fd6916f59ab.tar.gz
otp-14d709b0e07e899161a40bb43fc43fd6916f59ab.tar.bz2
otp-14d709b0e07e899161a40bb43fc43fd6916f59ab.zip
compiler: Add is_tagged_tuple instruction
Rewrite the instruction stream on tagged tuple tests. Tagged tuples means a tuple of any arity with an atom as its first element. Typically records, ok-tuples and error-tuples. from: ... {test,is_tuple,Fail,[Src]}. {test,test_arity,Fail,[Src,Sz]}. ... {get_tuple_element,Src,0,Dst}. ... {test,is_eq_exact,Fail,[Dst,Atom]}. ... to: ... {test,is_tagged_tuple,Fail,[Src,Sz,Atom]}. ...
Diffstat (limited to 'lib/compiler/src/beam_validator.erl')
-rw-r--r--lib/compiler/src/beam_validator.erl3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl
index bf33ae0aeb..c26e5719aa 100644
--- a/lib/compiler/src/beam_validator.erl
+++ b/lib/compiler/src/beam_validator.erl
@@ -653,6 +653,9 @@ valfun_4({test,is_nonempty_list,{f,Lbl},[Cons]}, Vst) ->
valfun_4({test,test_arity,{f,Lbl},[Tuple,Sz]}, Vst) when is_integer(Sz) ->
assert_type(tuple, Tuple, Vst),
set_type_reg({tuple,Sz}, Tuple, branch_state(Lbl, Vst));
+valfun_4({test,is_tagged_tuple,{f,Lbl},[Src,Sz,_Atom]}, Vst) ->
+ validate_src([Src], Vst),
+ set_type_reg({tuple, Sz}, Src, branch_state(Lbl, Vst));
valfun_4({test,has_map_fields,{f,Lbl},Src,{list,List}}, Vst) ->
assert_type(map, Src, Vst),
assert_unique_map_keys(List),