fix alignment of subprograms of subprograms
authorAndy Wingo <wingo@pobox.com>
Sun, 26 Jul 2009 09:54:05 +0000 (11:54 +0200)
committerAndy Wingo <wingo@pobox.com>
Sun, 26 Jul 2009 09:54:05 +0000 (11:54 +0200)
* module/language/glil/compile-assembly.scm (glil->assembly)
  (dump-object): Fix an exciting bug! Subprograms of subprograms were
  not being aligned correctly, because the code was generated too early.
  So instead delay dumping the object table until the proper time.

module/language/glil/compile-assembly.scm

index 9a5cae0..c4725e2 100644 (file)
            ;; anyway)
            (emit-code (align-program prog addr)))
           (else
-           (let ((table (dump-object (make-object-table objects) addr)))
+           (let ((table (make-object-table objects)))
              (cond
               (object-alist
                ;; if we are being compiled from something with an object
                                    object-alist)))
               (else
                ;; otherwise emit a load directly
-               (emit-code `(,@table ,@(align-program prog (addr+ addr table))))))))))))
-    
+               (let ((table-code (dump-object table addr)))
+                 (emit-code
+                  `(,@table-code
+                    ,@(align-program prog (addr+ addr table-code)))))))))))))
     
     ((<glil-bind> vars)
      (values '()
    ((object->assembly x) => list)
    ((variable-cache-cell? x) (dump-object (variable-cache-cell-key x) addr))
    ((subprogram? x)
-    `(,@(subprogram-table x)
-      ,@(align-program (subprogram-prog x)
-                       (addr+ addr (subprogram-table x)))))
+    (let ((table-code (dump-object (subprogram-table x) addr)))
+      `(,@table-code
+        ,@(align-program (subprogram-prog x)
+                         (addr+ addr table-code)))))
    ((number? x)
     `((load-number ,(number->string x))))
    ((string? x)