From 5ca336c43f5bf09cd0d5777f527194cf8091c33f Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sat, 23 May 2015 14:50:38 +0200 Subject: [PATCH] Fix size calculation for generated code for (list ...). The calculation was off by one, which might cause errors. --- NEWS | 3 +++ c-platform.scm | 6 +++--- optimizer.scm | 10 ++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 8f3c94c..1140763 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 40d18ad..baaca8f 100644 --- a/c-platform.scm +++ b/c-platform.scm @@ -711,8 +711,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) @@ -1062,4 +1062,4 @@ '##core#inline_allocate '("C_a_i_cons" 3) (list (second callargs) (varnode tmp))))))))))) -) \ No newline at end of file +) diff --git a/optimizer.scm b/optimizer.scm index bacd3dd..7a2a04c 100644 --- a/optimizer.scm +++ b/optimizer.scm @@ -1165,8 +1165,9 @@ ;; ( ...) -> (##core#inline_allocate ( ) ...) ((16) ; classargs = ( []) ;; - may be #f, saying that any number of arguments is allowed, - ;; - may be a list of one element (the number of words), meaning that - ;; the words are to be multiplied with the number of arguments. + ;; - 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. ;; - may also be #t, meaning that the number of words is the same as the ;; number of arguments plus 1. ;; - if is given and true and is between 1-8, append "" @@ -1189,7 +1190,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) ) ) ) ) ) @@ -1788,4 +1790,4 @@ groups) (values node (pair? groups)))) -) \ No newline at end of file +) -- 2.1.4