From 9b940b12210500e615ea05b447b0e1be34e70d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 25 Mar 2015 13:10:30 +0100 Subject: Pre-compute hash values for the general get_map_elements instruction See the previous commit for justification and use cases. --- erts/emulator/beam/beam_emu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'erts/emulator/beam/beam_emu.c') diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 5f49032e23..6fde14bc8d 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -2427,7 +2427,7 @@ do { \ * i.e. that it follows a test is_map if needed. */ - n = (Uint)Arg(2) / 2; + n = (Uint)Arg(2) / 3; fs = &Arg(3); /* pattern fields and target registers */ if (is_flatmap(map)) { @@ -2450,12 +2450,11 @@ do { \ if (EQ((Eterm)*fs,*ks)) { PUT_TERM_REG(*vs, fs[1]); n--; - fs += 2; + fs += 3; /* no more values to fetch, we are done */ if (n == 0) break; } - ks++; sz--; - vs++; + ks++, sz--, vs++; } if (n) { @@ -2467,13 +2466,14 @@ do { \ Uint32 hx; ASSERT(is_hashmap(map)); while(n--) { - hx = hashmap_make_hash((Eterm)*fs); - if ((v = erts_hashmap_get(hx,(Eterm)*fs, map)) == NULL) { + 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; } PUT_TERM_REG(*v, fs[1]); - fs += 2; + fs += 3; } } -- cgit v1.2.3