fix continuation-attachment optimization and non-single-value primitives

original commit: 6180395ad38887c6278e96a6cea9e0a4aad2453a
This commit is contained in:
Matthew Flatt 2019-11-05 17:49:15 -07:00
parent f0dc15c335
commit 8c82d4e5b7
2 changed files with 21 additions and 3 deletions

View File

@ -3630,6 +3630,24 @@
(lambda ()
(k (lambda () #t)))))])
(proc))
(equal?
'(2 2)
(let ([f (parameterize ([run-cp0
;; Disable cp0 inlining of `for-each`:
(lambda (cp0 e) e)])
(eval '(lambda (g l)
(let-values ([(x y)
(call-setting-continuation-attachment
'hi
(lambda ()
;; Could be by `cpnanopoass`, but make
;; sure it's constrained by the fact that
;; `for-each` can tail-call `g`:
(#3%for-each g l)))])
(list x y)))))])
(f (lambda (x) (values x x)) (list 1 2))))
)
;;; section 4-7:

View File

@ -2880,9 +2880,9 @@
(cond
[(and
(or (not (info-call-shift-attachment? info))
;; FIXME: need a less fragile way to avoid multiple results
;; Exclude inlined primitives that return more than one value:
(not (memq (primref-name pr) '(values call/cc call-with-current-continuation call/1cc))))
;; Note: single-valued also implies that the primitive doesn't
;; tail-call an arbitary function (which might inspect attachments):
(all-set? (prim-mask single-valued) (primref-flags pr)))
(handle-prim (info-call-src info) (info-call-sexpr info) (primref-level pr) (primref-name pr) e*))
=> (lambda (e)
(let ([e (Expr e)])