From 1ba194a85da774f3fb563d2b04979bd7dcf4be15 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sat, 24 Sep 2016 11:41:41 +0200 Subject: [PATCH] Copy temp arg values back into argvector on loop This would prevent the procedure from starting from scratch after GC. With this change, we continue the calculation, as it should be. Fixes #1317 --- NEWS | 3 +++ c-backend.scm | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index c7210dd..d27b997 100644 --- a/NEWS +++ b/NEWS @@ -55,6 +55,9 @@ 4.11.2 +- Compiler: + - Fixed incorrect argvector restoration after GC in directly + recursive functions (#1317). 4.11.1 diff --git a/c-backend.scm b/c-backend.scm index e3958c2..c4cd6b3 100644 --- a/c-backend.scm +++ b/c-backend.scm @@ -866,6 +866,11 @@ (else (gen #\{))))) (cond ((and (not (eq? 'toplevel id)) (not direct)) + (when (and looping (not customizable)) + ;; Loop will update t_n copy of av[n]; refresh av. + (do ((i 0 (add1 i))) + ((>= i n)) + (gen #t "av[" i "]=t" i ";"))) (cond (rest (gen #t "C_save_and_reclaim((void*)" id ",c,av);}" #t "a=C_alloc((c-" n ")*C_SIZEOF_PAIR+" demand ");") @@ -880,7 +885,7 @@ (apply gen arglist) (gen ");}")) (else - (gen "C_save_and_reclaim((void *)" id #\, n ",av);}"))) + (gen #t "C_save_and_reclaim((void *)" id #\, n ",av);}"))) (when (> demand 0) (gen #t "a=C_alloc(" demand ");"))))) (else (gen #\}))) -- 2.1.4