@@ -1990,19 +1990,23 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
1990
1990
// Support compilers < OTP26 that generate CALL_EXT
1991
1991
// for min/2 and max/2
1992
1992
const struct Bif * bif = EXPORTED_FUNCTION_TO_BIF (func );
1993
+ term return_value ;
1993
1994
switch (arity ) {
1994
1995
case 0 :
1995
- x_regs [ 0 ] = bif -> bif0_ptr (ctx );
1996
+ return_value = bif -> bif0_ptr (ctx );
1996
1997
break ;
1997
1998
case 1 :
1998
- x_regs [ 0 ] = bif -> bif1_ptr (ctx , 0 , x_regs [0 ]);
1999
+ return_value = bif -> bif1_ptr (ctx , 0 , x_regs [0 ]);
1999
2000
break ;
2000
2001
case 2 :
2001
- x_regs [ 0 ] = bif -> bif2_ptr (ctx , 0 , x_regs [0 ], x_regs [1 ]);
2002
+ return_value = bif -> bif2_ptr (ctx , 0 , x_regs [0 ], x_regs [1 ]);
2002
2003
break ;
2003
2004
default :
2004
2005
fprintf (stderr , "Invalid arity %" PRIu32 " for bif\n" , arity );
2006
+ AVM_ABORT ();
2005
2007
}
2008
+ PROCESS_MAYBE_TRAP_RETURN_VALUE_RESTORE_PC (return_value , orig_pc );
2009
+ x_regs [0 ] = return_value ;
2006
2010
2007
2011
break ;
2008
2012
}
@@ -2090,19 +2094,23 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
2090
2094
ctx -> e += (n_words + 1 );
2091
2095
2092
2096
const struct Bif * bif = EXPORTED_FUNCTION_TO_BIF (func );
2097
+ term return_value ;
2093
2098
switch (arity ) {
2094
2099
case 0 :
2095
- x_regs [ 0 ] = bif -> bif0_ptr (ctx );
2100
+ return_value = bif -> bif0_ptr (ctx );
2096
2101
break ;
2097
2102
case 1 :
2098
- x_regs [ 0 ] = bif -> bif1_ptr (ctx , 0 , x_regs [0 ]);
2103
+ return_value = bif -> bif1_ptr (ctx , 0 , x_regs [0 ]);
2099
2104
break ;
2100
2105
case 2 :
2101
- x_regs [ 0 ] = bif -> bif2_ptr (ctx , 0 , x_regs [0 ], x_regs [1 ]);
2106
+ return_value = bif -> bif2_ptr (ctx , 0 , x_regs [0 ], x_regs [1 ]);
2102
2107
break ;
2103
2108
default :
2104
2109
fprintf (stderr , "Invalid arity %" PRIu32 " for bif\n" , arity );
2110
+ AVM_ABORT ();
2105
2111
}
2112
+ PROCESS_MAYBE_TRAP_RETURN_VALUE_LAST (return_value );
2113
+ x_regs [0 ] = return_value ;
2106
2114
2107
2115
DO_RETURN ();
2108
2116
@@ -3541,19 +3549,23 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
3541
3549
// Support compilers < OTP26 that generate CALL_EXT_ONLY
3542
3550
// for min/2 and max/2
3543
3551
const struct Bif * bif = EXPORTED_FUNCTION_TO_BIF (func );
3552
+ term return_value ;
3544
3553
switch (arity ) {
3545
3554
case 0 :
3546
- x_regs [ 0 ] = bif -> bif0_ptr (ctx );
3555
+ return_value = bif -> bif0_ptr (ctx );
3547
3556
break ;
3548
3557
case 1 :
3549
- x_regs [ 0 ] = bif -> bif1_ptr (ctx , 0 , x_regs [0 ]);
3558
+ return_value = bif -> bif1_ptr (ctx , 0 , x_regs [0 ]);
3550
3559
break ;
3551
3560
case 2 :
3552
- x_regs [ 0 ] = bif -> bif2_ptr (ctx , 0 , x_regs [0 ], x_regs [1 ]);
3561
+ return_value = bif -> bif2_ptr (ctx , 0 , x_regs [0 ], x_regs [1 ]);
3553
3562
break ;
3554
3563
default :
3555
3564
fprintf (stderr , "Invalid arity %" PRIu32 " for bif\n" , arity );
3565
+ AVM_ABORT ();
3556
3566
}
3567
+ PROCESS_MAYBE_TRAP_RETURN_VALUE_LAST (return_value );
3568
+ x_regs [0 ] = return_value ;
3557
3569
3558
3570
DO_RETURN ();
3559
3571
0 commit comments