aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2010-11-10 14:03:50 +0100
committerBjörn Gustavsson <[email protected]>2011-01-17 15:23:36 +0100
commit177cca2e0ad8752022c3322f537ee836598b342a (patch)
treeb82fdb7cb0a11afe743eb81c45bc4d1e144ec3db /erts/emulator
parent89337287749d57024df06eaceca1236899efdcd1 (diff)
downloadotp-177cca2e0ad8752022c3322f537ee836598b342a.tar.gz
otp-177cca2e0ad8752022c3322f537ee836598b342a.tar.bz2
otp-177cca2e0ad8752022c3322f537ee836598b342a.zip
BEAM loader: Fix bug in handling of "rest" arguments
It would only really work in simple case like: select_val S=q Fail=f Size=u Rest=* => ... where all operands for a single instruction where bound to variables, and not for more complicated cases such as: i_put_tuple Dst Arity Puts=* | put PutSrc => ...
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/beam/beam_load.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index 2f335faad0..feac89784b 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -3992,14 +3992,17 @@ transform_engine(LoaderState* st)
case TOP_rest_args:
{
int n = *pc++;
+ int formal_arity = gen_opc[instr->op].arity;
+ int num_vars = n + (instr->arity - formal_arity);
+ int j = formal_arity;
+
var = erts_alloc(ERTS_ALC_T_LOADER_TMP,
- instr->arity * sizeof(GenOpArg));
+ num_vars * sizeof(GenOpArg));
for (i = 0; i < n; i++) {
var[i] = def_vars[i];
}
- while (i < instr->arity) {
- var[i] = instr->a[i];
- i++;
+ while (i < num_vars) {
+ var[i++] = instr->a[j++];
}
}
break;