1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

Avoid shuffle-down for tail calls

* module/language/tree-il/compile-bytecode.scm (compile-closure): We can
  emit the precise move sequence and just do a reset-frame once, so go
  ahead and do that.
This commit is contained in:
Andy Wingo 2020-05-04 21:58:10 +02:00
parent f0a9e537a0
commit 6b2d56ce15

View file

@ -1246,10 +1246,13 @@ in the frame with for the lambda-case clause @var{clause}."
(emit-return-values asm))
(($ <call> src proc args)
(let ((from (stack-height env)))
(fold for-push (for-push proc env) args)
(emit-reset-frame asm (+ from 1 (length args)))
(emit-shuffle-down asm from 0)
(let* ((base (stack-height env))
(env (fold for-push (for-push proc env) args)))
(let lp ((i (length args)) (env env))
(when (<= 0 i)
(lp (1- i) (env-prev env))
(emit-mov asm (+ (env-idx env) base) (env-idx env))))
(emit-reset-frame asm (+ 1 (length args)))
(emit-tail-call asm)))
(($ <prompt>) (visit-prompt exp env 'tail))