bytecode: fix "preserves marks" annotation w.r.t call/immediate-mark

A function that uses `call-with-immediate-continuation-mark` in tail
position should not be flagged as "preserves marks", because the JIT
needs to bump the mark stack if the function is called in non-tail
position.

Closes #2333
This commit is contained in:
Matthew Flatt 2018-10-28 18:50:56 -06:00
parent d1fe6a6e3e
commit 933e3c14b5
2 changed files with 38 additions and 0 deletions

View File

@ -6371,4 +6371,40 @@
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module optimizes-to-with-immediate-continuation-mark-in-noninlined racket/base
(define (call/icm proc)
(call-with-immediate-continuation-mark
'x
(lambda (v)
;; The constant '(1 2 3) currently prevents inlining
(if (proc '(1 2 3))
(proc v)
#f))))
(define (call/cm proc)
(if (zero? (random 1))
(with-continuation-mark
'x 'y
(proc))
;; disable inline:
'(3 4 5)))
(define result
(let ([in? #f]
[result #f])
(call/cm
(lambda ()
(set! in? #t)
(call/icm
(lambda (v)
(set! result v)))
(set! in? #f)))
result))
(provide result))
(test #f dynamic-require ''optimizes-to-with-immediate-continuation-mark-in-noninlined 'result)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs) (report-errs)

View File

@ -6539,6 +6539,8 @@ with_immed_mark_optimize(Scheme_Object *data, Optimize_Info *info, int context)
wcm->val = val; wcm->val = val;
SCHEME_CDR(wcm->body) = body; SCHEME_CDR(wcm->body) = body;
info->preserves_marks = 0;
return data; return data;
} }