From 10e65b35ced28c826645d3e24b25a8a7ef61dfde Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 25 Jul 2017 10:01:12 +0200 Subject: [PATCH] mescc: Tinycc support: more function stack space. * module/mes/as-i386.mes (function-locals): Increase local space from 64 (16 vars) to 2*1025 + 80 (20 vars). --- module/language/c99/compiler.mes | 11 ++++++++--- module/mes/as-i386.mes | 2 +- stage0/x86.M1 | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/module/language/c99/compiler.mes b/module/language/c99/compiler.mes index 3cb94c6e..91d60269 100644 --- a/module/language/c99/compiler.mes +++ b/module/language/c99/compiler.mes @@ -2315,9 +2315,14 @@ (format (current-error-port) " :~a\n" name) (let loop ((statements (.statements o)) (info (clone info #:locals locals #:function (.name o) #:text text))) - (if (null? statements) (clone info - #:function #f - #:functions (append (.functions info) (list (cons name (assert-return (.text info)))))) + (if (null? statements) (let* ((locals (.locals info)) + (local (and (pair? locals) (car locals))) + (count (and=> local (compose local:id cdr))) + (stack (and count (* count 4)))) + (if (and stack (getenv "MESC_DEBUG")) (stderr " stack: ~a\n" stack)) + (clone info + #:function #f + #:functions (append (.functions info) (list (cons name (assert-return (.text info))))))) (let* ((statement (car statements))) (loop (cdr statements) ((ast->info info) (car statements))))))))) diff --git a/module/mes/as-i386.mes b/module/mes/as-i386.mes index d5059c43..4ffb7923 100644 --- a/module/mes/as-i386.mes +++ b/module/mes/as-i386.mes @@ -38,7 +38,7 @@ ("mov____%esp,%ebp"))) (define (i386:function-locals) - '(("sub____%esp,$i8" (#:immediate1 #x40)))) ; sub %esp,$0x40 # 16 local vars + `(("sub____%esp,$i32" (#:immediate ,(+ (* 4 1025) (* 20 4)))))) ; sub %esp,xxx 4*1024 buf, 20 local vars (define (i386:push-label label) `(("push___$i32" (#:address ,label)))) ; push $0x