Skip to content

Commit 56bdc67

Browse files
committed
Pass correct live value in BIFs
If BIF did GC and tried to preserve input registers and args with memory_ensure_free_with_roots(ctx, TERMS_N, live, ctx->x, MEMORY_CAN_SHRINK) it would invalidate registers anyways because live=0. Now, GC BIFs can keep them at cost of temporary memory increase until next GC is done. Signed-off-by: Jakub Gonet <jakub.gonet@swmansion.com>
1 parent ed6a158 commit 56bdc67

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libAtomVM/opcodesswitch.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,15 +1612,15 @@ static bool maybe_call_native(Context *ctx, AtomString module_name, AtomString f
16121612
const struct GCBif *gcbif = EXPORTED_FUNCTION_TO_GCBIF(exported_bif);
16131613
switch (arity) {
16141614
case 1: {
1615-
*return_value = gcbif->gcbif1_ptr(ctx, 0, 0, ctx->x[0]);
1615+
*return_value = gcbif->gcbif1_ptr(ctx, 0, 1, ctx->x[0]);
16161616
return true;
16171617
}
16181618
case 2: {
1619-
*return_value = gcbif->gcbif2_ptr(ctx, 0, 0, ctx->x[0], ctx->x[1]);
1619+
*return_value = gcbif->gcbif2_ptr(ctx, 0, 2, ctx->x[0], ctx->x[1]);
16201620
return true;
16211621
}
16221622
case 3: {
1623-
*return_value = gcbif->gcbif3_ptr(ctx, 0, 0, ctx->x[0], ctx->x[1], ctx->x[2]);
1623+
*return_value = gcbif->gcbif3_ptr(ctx, 0, 3, ctx->x[0], ctx->x[1], ctx->x[2]);
16241624
return true;
16251625
}
16261626
}

0 commit comments

Comments
 (0)