1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 05:50:26 +02:00

Prefer "receive" over "receive-values"+"reset-frame"

* module/language/cps/compile-bytecode.scm (compile-fun): Attempt to
  emit "receive" instead of "receive-values"+"reset-frame" where
  possible.
This commit is contained in:
Andy Wingo 2013-12-22 11:14:13 -05:00
parent 4dfcb36006
commit e4fa7d403a

View file

@ -466,9 +466,20 @@
(lookup-parallel-moves label allocation)) (lookup-parallel-moves label allocation))
(for-each maybe-load-constant arg-slots (cons proc args)) (for-each maybe-load-constant arg-slots (cons proc args))
(emit-call asm proc-slot nargs) (emit-call asm proc-slot nargs)
(cond
((and (= 1 nreq) (and rest-var) (not (maybe-slot rest-var))
(match (lookup-parallel-moves k allocation)
((((? (lambda (src) (= src (1+ proc-slot))) src)
. dst)) dst)
(_ #f)))
;; The usual case: one required live return value, ignoring
;; any additional values.
=> (lambda (dst)
(emit-receive asm dst proc-slot nlocals)))
(else
;; FIXME: Only allow more values if there is a rest arg. ;; FIXME: Only allow more values if there is a rest arg.
;; Express values truncation by the presence of an ;; Express values truncation by the presence of an unused
;; unused rest arg instead of implicitly. ;; rest arg instead of implicitly.
(unless (zero? nreq) (unless (zero? nreq)
(emit-receive-values asm proc-slot #t nreq)) (emit-receive-values asm proc-slot #t nreq))
(when (and rest-var (maybe-slot rest-var)) (when (and rest-var (maybe-slot rest-var))
@ -476,7 +487,7 @@
(for-each (match-lambda (for-each (match-lambda
((src . dst) (emit-mov asm dst src))) ((src . dst) (emit-mov asm dst src)))
(lookup-parallel-moves k allocation)) (lookup-parallel-moves k allocation))
(emit-reset-frame asm nlocals))))) (emit-reset-frame asm nlocals)))))))
(match f (match f
(($ $fun src meta free ($ $cont k ($ $kentry self tail clauses))) (($ $fun src meta free ($ $cont k ($ $kentry self tail clauses)))