bytecode compiler: add missing stack check in SFS pass
C-implemented recursive pass needs stack-overflow check and handling. Closes #1607
This commit is contained in:
parent
2333251a26
commit
b3223ad8d2
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "schpriv.h"
|
#include "schpriv.h"
|
||||||
#include "schrunst.h"
|
#include "schrunst.h"
|
||||||
|
#include "schmach.h"
|
||||||
#include "schexpobs.h"
|
#include "schexpobs.h"
|
||||||
|
|
||||||
struct SFS_Info {
|
struct SFS_Info {
|
||||||
|
@ -1360,12 +1361,40 @@ top_level_require_sfs(Scheme_Object *data, SFS_Info *rslv)
|
||||||
/* expressions */
|
/* expressions */
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
|
|
||||||
|
static Scheme_Object *sfs_expr_k(void)
|
||||||
|
{
|
||||||
|
Scheme_Thread *p = scheme_current_thread;
|
||||||
|
Scheme_Object *e = (Scheme_Object *)p->ku.k.p1;
|
||||||
|
SFS_Info *info = (SFS_Info *)p->ku.k.p2;
|
||||||
|
|
||||||
|
p->ku.k.p1 = NULL;
|
||||||
|
p->ku.k.p2 = NULL;
|
||||||
|
|
||||||
|
return scheme_sfs_expr(e, info, p->ku.k.i1);
|
||||||
|
}
|
||||||
|
|
||||||
Scheme_Object *scheme_sfs_expr(Scheme_Object *expr, SFS_Info *info, int closure_self_pos)
|
Scheme_Object *scheme_sfs_expr(Scheme_Object *expr, SFS_Info *info, int closure_self_pos)
|
||||||
/* closure_self_pos == -2 => immediately in sequence */
|
/* closure_self_pos == -2 => immediately in sequence */
|
||||||
{
|
{
|
||||||
Scheme_Type type = SCHEME_TYPE(expr);
|
Scheme_Type type = SCHEME_TYPE(expr);
|
||||||
int seqn, stackpos, tp;
|
int seqn, stackpos, tp;
|
||||||
|
|
||||||
|
#ifdef DO_STACK_CHECK
|
||||||
|
{
|
||||||
|
# include "mzstkchk.h"
|
||||||
|
{
|
||||||
|
Scheme_Thread *p = scheme_current_thread;
|
||||||
|
|
||||||
|
p->ku.k.p1 = (void *)expr;
|
||||||
|
p->ku.k.p2 = (void *)info;
|
||||||
|
p->ku.k.i1 = closure_self_pos;
|
||||||
|
|
||||||
|
return scheme_handle_stack_overflow(sfs_expr_k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
seqn = info->seqn;
|
seqn = info->seqn;
|
||||||
stackpos = info->stackpos;
|
stackpos = info->stackpos;
|
||||||
tp = info->tail_pos;
|
tp = info->tail_pos;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user