~ chicken-core (chicken-5) f40f5daf969459b2601dfec39dfdcfcf82c2ccc9
commit f40f5daf969459b2601dfec39dfdcfcf82c2ccc9
Author: Peter Bex <peter@more-magic.net>
AuthorDate: Sat May 23 16:14:36 2015 +0200
Commit: Evan Hanson <evhan@foldling.org>
CommitDate: Mon May 25 07:16:16 2015 +1200
Fix size calculation for generated code for (list ...).
The calculation was off by one, which might cause errors.
Signed-off-by: Evan Hanson <evhan@foldling.org>
diff --git a/NEWS b/NEWS
index 8f3c94ce..1140763e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
5.0.0 (preliminary)
+- Compiler
+ - Fixed an off by one allocation problem in generated C code for (list ...).
+
- Core libraries
- Removed support for memory-mapped files (posix), queues (data-structures),
binary-search (data-structures) and object-eviction (lolevel). These
diff --git a/c-platform.scm b/c-platform.scm
index 78a01bcf..5b72e432 100644
--- a/c-platform.scm
+++ b/c-platform.scm
@@ -838,8 +838,8 @@
(rewrite 'cons 16 2 "C_a_i_cons" #t 3)
(rewrite '##sys#cons 16 2 "C_a_i_cons" #t 3)
-(rewrite 'list 16 #f "C_a_i_list" #t '(3) #t)
-(rewrite '##sys#list 16 #f "C_a_i_list" #t '(3))
+(rewrite 'list 16 #f "C_a_i_list" #t '(1 3) #t)
+(rewrite '##sys#list 16 #f "C_a_i_list" #t '(1 3))
(rewrite 'vector 16 #f "C_a_i_vector" #t #t #t)
(rewrite '##sys#vector 16 #f "C_a_i_vector" #t #t)
(rewrite '##sys#make-structure 16 #f "C_a_i_record" #t #t #t)
diff --git a/optimizer.scm b/optimizer.scm
index 5a7e23fc..27002c7a 100644
--- a/optimizer.scm
+++ b/optimizer.scm
@@ -1170,8 +1170,9 @@
;; (<alloc-op> ...) -> (##core#inline_allocate (<aiop> <words>) ...)
((16) ; classargs = (<argc> <aiop> <safe> <words> [<counted>])
;; - <argc> may be #f, saying that any number of arguments is allowed,
- ;; - <words> may be a list of one element (the number of words), meaning that
- ;; the words are to be multiplied with the number of arguments.
+ ;; - <words> may be a list of two elements (the base number of words and
+ ;; the number of words per element), meaning that the words are to be
+ ;; multiplied with the number of arguments.
;; - <words> may also be #t, meaning that the number of words is the same as the
;; number of arguments plus 1.
;; - if <counted> is given and true and <argc> is between 1-8, append "<count>"
@@ -1194,7 +1195,8 @@
(conc (second classargs) rargc)
(second classargs) )
(cond ((eq? #t w) (add1 rargc))
- ((pair? w) (* rargc (car w)))
+ ((pair? w) (+ (car w)
+ (* rargc (cadr w))))
(else w) ) )
callargs) ) ) ) ) )
@@ -1796,4 +1798,4 @@
groups)
(values node (pair? groups))))
-)
\ No newline at end of file
+)
Trap