aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_validator.erl
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-02-10 18:55:17 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-02-13 14:39:28 +0100
commit210dbf68a62794b51b74337381cd87424a46b2a5 (patch)
tree6f7a25b60514b1b96bea15c4cf568c1a00c02504 /lib/compiler/src/beam_validator.erl
parent993642bd638f194c2cbb0e62ee706e8d6eb81fce (diff)
downloadotp-210dbf68a62794b51b74337381cd87424a46b2a5.tar.gz
otp-210dbf68a62794b51b74337381cd87424a46b2a5.tar.bz2
otp-210dbf68a62794b51b74337381cd87424a46b2a5.zip
compiler: Change map instructions for fetching values
* Combine multiple get values with one instruction * Combine multiple check keys with one instruction
Diffstat (limited to 'lib/compiler/src/beam_validator.erl')
-rw-r--r--lib/compiler/src/beam_validator.erl20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl
index 682f7adbc2..9f8f1cd3f5 100644
--- a/lib/compiler/src/beam_validator.erl
+++ b/lib/compiler/src/beam_validator.erl
@@ -770,6 +770,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,_Op,{f,Lbl},Src,{list,_}}, Vst) ->
+ validate_src([Src], Vst),
+ branch_state(Lbl, Vst);
valfun_4({test,_Op,{f,Lbl},Src}, Vst) ->
validate_src(Src, Vst),
branch_state(Lbl, Vst);
@@ -871,14 +874,21 @@ valfun_4({put_map_assoc,{f,Fail},Src,Dst,Live,{list,List}}, Vst) ->
verify_put_map(Fail, Src, Dst, Live, List, Vst);
valfun_4({put_map_exact,{f,Fail},Src,Dst,Live,{list,List}}, Vst) ->
verify_put_map(Fail, Src, Dst, Live, List, Vst);
-valfun_4({get_map_element,{f,Fail},Src,Key,Dst}, Vst0) ->
- assert_term(Src, Vst0),
- assert_term(Key, Vst0),
- Vst = branch_state(Fail, Vst0),
- set_type_reg(term, Dst, Vst);
+valfun_4({get_map_elements,{f,Fail},Src,{list,List}}, Vst) ->
+ verify_get_map(Fail, Src, List, Vst);
valfun_4(_, _) ->
error(unknown_instruction).
+verify_get_map(Fail, Src, List, Vst0) ->
+ assert_term(Src, Vst0),
+ Vst1 = branch_state(Fail, Vst0),
+ verify_get_map_pair(List,Vst0,Vst1).
+
+verify_get_map_pair([],_,Vst) -> Vst;
+verify_get_map_pair([Src,Dst|Vs],Vst0,Vsti) ->
+ assert_term(Src, Vst0),
+ verify_get_map_pair(Vs,Vst0,set_type_reg(term,Dst,Vsti)).
+
verify_put_map(Fail, Src, Dst, Live, List, Vst0) ->
verify_live(Live, Vst0),
verify_y_init(Vst0),