From b166f8975387d7ef07409e841d45c2cd74c2282e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 7 Dec 2010 16:04:05 +0100 Subject: Introduce a special instruction for select_val with two values The new instruction will save one word (because no size operand is needed), and is slightly faster. Handle select_tuple_arity in the same way. --- erts/emulator/beam/beam_load.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'erts/emulator/beam/beam_load.c') diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index 02aef95a52..2d57c8a218 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -2978,6 +2978,21 @@ gen_select_tuple_arity(LoaderState* stp, GenOpArg S, GenOpArg Fail, ASSERT(op->a[i].val < op->a[i+2].val); } #endif + + /* + * Use a special-cased instruction if there are only two values. + */ + if (size == 2) { + op->op = genop_i_select_tuple_arity2_6; + op->arity--; + op->a[2].type = TAG_u; + op->a[2].val = arityval(op->a[3].val); + op->a[3] = op->a[4]; + op->a[4].type = TAG_u; + op->a[4].val = arityval(op->a[5].val); + op->a[5] = op->a[6]; + } + return op; } @@ -3228,6 +3243,18 @@ gen_select_val(LoaderState* stp, GenOpArg S, GenOpArg Fail, } #endif + /* + * Use a special-cased instruction if there are only two values. + */ + if (size == 2) { + op->op = genop_i_select_val2_6; + op->arity--; + op->a[2] = op->a[3]; + op->a[3] = op->a[4]; + op->a[4] = op->a[5]; + op->a[5] = op->a[6]; + } + return op; } -- cgit v1.2.3