diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-12-02 12:31:44 +0100 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-12-05 16:06:11 +0100 |
commit | b9a8cebcc30ee1bce8e6b57041bf07cf84630386 (patch) | |
tree | 8883bb0afad52a294f86bce089ad2f381e04ba30 /erts/emulator/beam/beam_debug.c | |
parent | a9cb99ef1b497b9b9279d1499c1cbaabedb416bf (diff) | |
download | otp-b9a8cebcc30ee1bce8e6b57041bf07cf84630386.tar.gz otp-b9a8cebcc30ee1bce8e6b57041bf07cf84630386.tar.bz2 otp-b9a8cebcc30ee1bce8e6b57041bf07cf84630386.zip |
erts: Use linear search for small select_val arrays
For searching a key in an array we use linear search in arrays
up to 10 elements.
Selecting on tuple arity will always use linear search.
Instead of using two different instructions we assume selecting on
different tuple arities are always few in numbers.
Diffstat (limited to 'erts/emulator/beam/beam_debug.c')
-rw-r--r-- | erts/emulator/beam/beam_debug.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/erts/emulator/beam/beam_debug.c b/erts/emulator/beam/beam_debug.c index a3cd08834f..6bb987985d 100644 --- a/erts/emulator/beam/beam_debug.c +++ b/erts/emulator/beam/beam_debug.c @@ -579,9 +579,29 @@ print_op(int to, void *to_arg, int op, int size, BeamInstr* addr) unpacked = ap; ap = addr + size; switch (op) { - case op_i_select_val_rfI: - case op_i_select_val_xfI: - case op_i_select_val_yfI: + case op_i_select_val_lins_rfI: + case op_i_select_val_lins_xfI: + case op_i_select_val_lins_yfI: + { + int n = ap[-1]; + int ix = n; + + while (ix--) { + erts_print(to, to_arg, "%T ", (Eterm) ap[0]); + ap++; + size++; + } + ix = n; + while (ix--) { + erts_print(to, to_arg, "f(" HEXF ") ", (Eterm) ap[0]); + ap++; + size++; + } + } + break; + case op_i_select_val_bins_rfI: + case op_i_select_val_bins_xfI: + case op_i_select_val_bins_yfI: { int n = ap[-1]; @@ -598,13 +618,19 @@ print_op(int to, void *to_arg, int op, int size, BeamInstr* addr) case op_i_select_tuple_arity_yfI: { int n = ap[-1]; + int ix = n; - while (n > 0) { + while (ix--) { Uint arity = arityval(ap[0]); - erts_print(to, to_arg, " {%d} f(" HEXF ")", arity, ap[1]); - ap += 2; - size += 2; - n--; + erts_print(to, to_arg, "{%d} ", arity, ap[1]); + ap++; + size++; + } + ix = n; + while (ix--) { + erts_print(to, to_arg, "f(" HEXF ") ", ap[0]); + ap++; + size++; } } break; |