From 1005628ab59e3761fb3216f147cf4eec65adc3a0 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sat, 14 Feb 2009 22:54:19 +0100 Subject: [PATCH] better alignment * module/language/assembly.scm (align-program): Whoops, align programs properly. * module/language/glil/compile-assembly.scm (compile-assembly): Start with addr=-1, for the unserialized load-program byte. (glil->assembly): Align programs in all cases. --- module/language/assembly.scm | 3 ++- module/language/glil/compile-assembly.scm | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/module/language/assembly.scm b/module/language/assembly.scm index fbe3a7153..42fd5f0e1 100644 --- a/module/language/assembly.scm +++ b/module/language/assembly.scm @@ -66,7 +66,8 @@ (define (align-program prog addr) `(,@(make-list (modulo (- *program-alignment* - (modulo addr *program-alignment*)) + (modulo (1+ addr) *program-alignment*)) + ;; plus the one for the load-program inst itself *program-alignment*) '(nop)) ,prog)) diff --git a/module/language/glil/compile-assembly.scm b/module/language/glil/compile-assembly.scm index 5679b6898..797c59653 100644 --- a/module/language/glil/compile-assembly.scm +++ b/module/language/glil/compile-assembly.scm @@ -129,7 +129,7 @@ (define (compile-assembly glil) (receive (code . _) - (glil->assembly glil 0 '() '(()) '() '() #f 0) + (glil->assembly glil 0 '() '(()) '() '() #f -1) (car code))) (define (make-object-table objects) (and (not (null? objects)) @@ -176,7 +176,7 @@ ;; toplevel bytecode isn't loaded by the vm, no way to do ;; object table or closure capture (not in the bytecode, ;; anyway) - (emit-code `(,prog))) + (emit-code (align-program prog addr))) (else (let ((table (dump-object (make-object-table objects) addr)) (closure (if (> closure-level 0) '((make-closure)) '()))) @@ -191,7 +191,8 @@ object-alist))) (else ;; otherwise emit a load directly - (emit-code `(,@table ,prog ,@closure))))))))))) + (emit-code `(,@table ,@(align-program prog (addr+ addr table)) + ,@closure))))))))))) (( vars) (values '()