From e8ee9f4cba07c7aa05685207c54ae1d773bf1814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Sat, 9 Sep 2017 12:30:35 +0200 Subject: Pack failure labels in i_select_val2 and i_select_tuple_arity2 --- erts/emulator/beam/beam_debug.c | 16 ++++++++++++++++ erts/emulator/beam/beam_load.c | 4 ++-- erts/emulator/beam/ops.tab | 4 ++-- erts/emulator/beam/select_instrs.tab | 8 +++++--- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/erts/emulator/beam/beam_debug.c b/erts/emulator/beam/beam_debug.c index df152f1605..afde45ba71 100644 --- a/erts/emulator/beam/beam_debug.c +++ b/erts/emulator/beam/beam_debug.c @@ -679,6 +679,22 @@ print_op(fmtfn_t to, void *to_arg, int op, int size, BeamInstr* addr) size += (n+1) / 2; } break; + case op_i_select_val2_xfcc: + case op_i_select_val2_yfcc: + case op_i_select_tuple_arity2_xfAA: + case op_i_select_tuple_arity2_yfAA: + { + Sint32* jump_tab = (Sint32 *) ap; + BeamInstr* target; + int i; + + for (i = 0; i < 2; i++) { + target = f_to_addr_packed(addr, op, jump_tab++); + erts_print(to, to_arg, "f(" HEXF ") ", target); + } + size += 1; + } + break; case op_i_jump_on_val_xfIW: case op_i_jump_on_val_yfIW: { diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index 944ff7bc4c..3f9dc2c1aa 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -3749,7 +3749,7 @@ gen_select_tuple_arity(LoaderState* stp, GenOpArg S, GenOpArg Fail, if (size == 2) { NEW_GENOP(stp, op); op->next = NULL; - op->op = genop_i_select_tuple_arity2_6; + op->op = genop_i_select_tuple_arity2_4; GENOP_ARITY(op, arity - 1); op->a[0] = S; op->a[1] = Fail; @@ -4045,7 +4045,7 @@ gen_select_val(LoaderState* stp, GenOpArg S, GenOpArg Fail, NEW_GENOP(stp, op); op->next = NULL; - op->op = genop_i_select_val2_6; + op->op = genop_i_select_val2_4; GENOP_ARITY(op, arity - 1); op->a[0] = S; op->a[1] = Fail; diff --git a/erts/emulator/beam/ops.tab b/erts/emulator/beam/ops.tab index 4152e0ced5..52a13d4e18 100644 --- a/erts/emulator/beam/ops.tab +++ b/erts/emulator/beam/ops.tab @@ -162,11 +162,11 @@ i_select_val_bins xy f I i_select_val_lins xy f I -i_select_val2 xy f c c f f +i_select_val2 xy f c c i_select_tuple_arity xy f I -i_select_tuple_arity2 xy f A A f f +i_select_tuple_arity2 xy f A A i_jump_on_val_zero xy f I diff --git a/erts/emulator/beam/select_instrs.tab b/erts/emulator/beam/select_instrs.tab index f5ce5d5a32..2951949d38 100644 --- a/erts/emulator/beam/select_instrs.tab +++ b/erts/emulator/beam/select_instrs.tab @@ -94,11 +94,13 @@ select_val2.get_arity() { } } -select_val2.execute(Fail, T1, T2, D1, D2) { +select_val2.execute(Fail, T1, T2) { + Sint32* jump_tab = (Sint32 *) ($NEXT_INSTRUCTION); + if (select_val2 == $T1) { - $JUMP($D1); + $JUMP(jump_tab[0]); } else if (select_val2 == $T2) { - $JUMP($D2); + $JUMP(jump_tab[1]); } else { $FAIL($Fail); } -- cgit v1.2.3