aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_load.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-03-26 13:16:45 +0100
committerBjörn Gustavsson <[email protected]>2015-04-13 12:37:54 +0200
commitc92cf260bb888c004fb02651670d19989dbc2b74 (patch)
tree1aea823e83a9696bcf9285742e73cd806cd98de1 /erts/emulator/beam/beam_load.c
parentfea64943212cd96764b595c91b22da68bc72e999 (diff)
downloadotp-c92cf260bb888c004fb02651670d19989dbc2b74.tar.gz
otp-c92cf260bb888c004fb02651670d19989dbc2b74.tar.bz2
otp-c92cf260bb888c004fb02651670d19989dbc2b74.zip
De-optimize the has_map_fields instructions
The has_map_fields instruction is infrequently used. Thus there is no need to have the fastest possible implementation; it is better to have an implementation that reduces the code size in the already big process_main() function. We can transform has_map_fields to a get_map_elements instruction, targeting the same unused x[0] register for all keys. That instruction will only be marginally slower than existing implementation.
Diffstat (limited to 'erts/emulator/beam/beam_load.c')
-rw-r--r--erts/emulator/beam/beam_load.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index 60f4ab5280..18e1e312ad 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -4107,21 +4107,31 @@ gen_get_map_element(LoaderState* stp, GenOpArg Fail, GenOpArg Src,
}
static GenOp*
-gen_has_map_field(LoaderState* stp, GenOpArg Fail, GenOpArg Src,
- GenOpArg Size, GenOpArg* Rest)
+gen_has_map_fields(LoaderState* stp, GenOpArg Fail, GenOpArg Src,
+ GenOpArg Size, GenOpArg* Rest)
{
GenOp* op;
+ Uint i;
+ Uint n;
ASSERT(Size.type == TAG_u);
+ n = Size.val;
NEW_GENOP(stp, op);
+ GENOP_ARITY(op, 3 + 2*n);
op->next = NULL;
- op->op = genop_has_map_field_3;
- op->arity = 4;
+ op->op = genop_get_map_elements_3;
op->a[0] = Fail;
op->a[1] = Src;
- op->a[2] = Rest[0];
+ op->a[2].type = TAG_u;
+ op->a[2].val = 2*n;
+
+ for (i = 0; i < n; i++) {
+ op->a[3+2*i] = Rest[i];
+ op->a[3+2*i+1].type = TAG_x;
+ op->a[3+2*i+1].val = 0; /* x(0); normally not used */
+ }
return op;
}