diff options
author | Björn-Egil Dahlberg <[email protected]> | 2015-03-05 16:16:30 +0100 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2015-03-12 19:15:32 +0100 |
commit | 10fa0c3d1b1fbe473de385ee7ae2aa77807e0281 (patch) | |
tree | fd106d30912795528a846856a778f6c16d88c4a5 /erts/emulator | |
parent | d0e0608c0585240d18e9193af947bd666e9df892 (diff) | |
download | otp-10fa0c3d1b1fbe473de385ee7ae2aa77807e0281.tar.gz otp-10fa0c3d1b1fbe473de385ee7ae2aa77807e0281.tar.bz2 otp-10fa0c3d1b1fbe473de385ee7ae2aa77807e0281.zip |
erts: Fix instruction i_has_map_fields_fsI for hashmaps
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/beam/beam_emu.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 4f57037507..9b4cd38d69 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -2400,10 +2400,24 @@ void process_main(void) Uint sz,n; GetArg1(1, map); + n = (Uint)Arg(2); + fs = &Arg(3); /* pattern fields */ - /* this instruction assumes Arg1 is a map, - * i.e. that it follows a test is_map if needed. - */ + /* get term from field? */ + if (is_hashmap(map)) { + Uint32 hx; + while(n--) { + field = *fs++; + hx = hashmap_make_hash(field); + if (!erts_hashmap_get(hx,field,map)) { + SET_I((BeamInstr *) Arg(0)); + goto has_map_fields_fail; + } + } + goto has_map_fields_ok; + } + + ASSERT(is_map(map)); mp = (map_t *)map_val(map); sz = map_get_size(mp); @@ -2414,8 +2428,6 @@ void process_main(void) } ks = map_get_keys(mp); - n = (Uint)Arg(2); - fs = &Arg(3); /* pattern fields */ ASSERT(n>0); @@ -2433,7 +2445,7 @@ void process_main(void) SET_I((BeamInstr *) Arg(0)); goto has_map_fields_fail; } - +has_map_fields_ok: I += 4 + Arg(2); has_map_fields_fail: ASSERT(VALID_INSTR(*I)); |