aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-03-26 10:59:16 +0100
committerBjörn Gustavsson <[email protected]>2015-04-13 12:37:55 +0200
commit61712dda57647804aec8d4f45da8ae1ccfad732c (patch)
treec5360b2ca07ae69e11bdb6f82dcef6e7fa990dd5
parent9b940b12210500e615ea05b447b0e1be34e70d39 (diff)
downloadotp-61712dda57647804aec8d4f45da8ae1ccfad732c.tar.gz
otp-61712dda57647804aec8d4f45da8ae1ccfad732c.tar.bz2
otp-61712dda57647804aec8d4f45da8ae1ccfad732c.zip
Tigthen code for the i_get_map_elements/3 instruction
-rw-r--r--erts/emulator/beam/beam_emu.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c
index 6fde14bc8d..7e242640ed 100644
--- a/erts/emulator/beam/beam_emu.c
+++ b/erts/emulator/beam/beam_emu.c
@@ -2439,28 +2439,27 @@ do { \
sz = flatmap_get_size(mp);
if (sz == 0) {
- SET_I((BeamInstr *) Arg(0));
- goto get_map_elements_fail;
+ ClauseFail();
}
ks = flatmap_get_keys(mp);
vs = flatmap_get_values(mp);
while(sz) {
- if (EQ((Eterm)*fs,*ks)) {
+ if (EQ((Eterm) fs[0], *ks)) {
PUT_TERM_REG(*vs, fs[1]);
n--;
fs += 3;
/* no more values to fetch, we are done */
- if (n == 0) break;
+ if (n == 0) {
+ I = fs;
+ Next(-1);
+ }
}
ks++, sz--, vs++;
}
- if (n) {
- SET_I((BeamInstr *) Arg(0));
- goto get_map_elements_fail;
- }
+ ClauseFail();
} else {
const Eterm *v;
Uint32 hx;
@@ -2469,19 +2468,14 @@ do { \
hx = fs[2];
ASSERT(hx == hashmap_make_hash((Eterm)fs[0]));
if ((v = erts_hashmap_get(hx, (Eterm)fs[0], map)) == NULL) {
- SET_I((BeamInstr *) Arg(0));
- goto get_map_elements_fail;
+ ClauseFail();
}
PUT_TERM_REG(*v, fs[1]);
fs += 3;
}
+ I = fs;
+ Next(-1);
}
-
-
- I += 4 + Arg(2);
-get_map_elements_fail:
- ASSERT(VALID_INSTR(*I));
- Goto(*I);
}
#undef PUT_TERM_REG