fix mishandling of the continuation-mark depth
When a chaperone-wrapped function leads to a slow-path tail call, the continuation-mark depth can be made too deep when resolving the slow tail call. Closes #1265
This commit is contained in:
parent
7151d6d034
commit
81b5d74ed6
|
@ -2474,6 +2474,27 @@
|
||||||
(test-wrapped wrapped-f)
|
(test-wrapped wrapped-f)
|
||||||
(test-wrapped wrapped2-f))
|
(test-wrapped wrapped2-f))
|
||||||
|
|
||||||
|
;; ----------------------------------------
|
||||||
|
;; Check that continuation-mark depth is handled
|
||||||
|
;; properly when the JIT has to take a slow
|
||||||
|
;; path for a tail call
|
||||||
|
|
||||||
|
(let ()
|
||||||
|
(define (counter)
|
||||||
|
(let ([c 0])
|
||||||
|
(case-lambda
|
||||||
|
[() c]
|
||||||
|
[(x) (when (= c 1) (error 'fail)) (set! c (+ c 1)) #t])))
|
||||||
|
|
||||||
|
(for ([i 1000])
|
||||||
|
(let ([c (counter)])
|
||||||
|
(letrec ([f
|
||||||
|
(contract (-> any/c c)
|
||||||
|
(λ ([x #f]) (if (zero? x) x (f (- x 1))))
|
||||||
|
'pos
|
||||||
|
'neg)])
|
||||||
|
(f 6)))))
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
|
|
||||||
(report-errs)
|
(report-errs)
|
||||||
|
|
|
@ -3732,7 +3732,7 @@ static Scheme_Object *_apply_native(Scheme_Object *obj, int num_rands, Scheme_Ob
|
||||||
obj = data->start_code(obj, num_rands, rands EXTRA_NATIVE_ARGUMENT);
|
obj = data->start_code(obj, num_rands, rands EXTRA_NATIVE_ARGUMENT);
|
||||||
|
|
||||||
if (obj == SCHEME_TAIL_CALL_WAITING)
|
if (obj == SCHEME_TAIL_CALL_WAITING)
|
||||||
obj = force_values(obj, 1);
|
obj = scheme_force_value_same_mark(obj);
|
||||||
|
|
||||||
MZ_CONT_MARK_STACK = old_cont_mark_stack;
|
MZ_CONT_MARK_STACK = old_cont_mark_stack;
|
||||||
MZ_CONT_MARK_POS -= 2;
|
MZ_CONT_MARK_POS -= 2;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user