write-image.scm 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ; Copyright (c) 1993-2008 by Richard Kelsey and Jonathan Rees. See file COPYING.
  2. ; Two-space-GC-specific part of the dumper
  3. (define image-start-address 0)
  4. (define *image-begin*) ; Starting address.
  5. (define *image-hp*) ; Current ending address.
  6. (define (write-header resumer-records resume-proc image-descriptor port)
  7. (write-check (write-char #\newline port))
  8. (write-page)
  9. (write-check (write-char #\newline port))
  10. (write-check (write-string architecture-version port))
  11. (write-check (write-char #\newline port))
  12. (write-check (write-integer (enum image-format two-space) port))
  13. (write-check (write-char #\newline port))
  14. (write-header-integer bytes-per-cell)
  15. ;;Start Address
  16. (write-header-integer (a-units->cells image-start-address))
  17. ;;End Address
  18. (write-header-integer (a-units->cells (+ image-start-address (image-size))))
  19. (write-header-integer (image-descriptor (s48-symbol-table)))
  20. (write-header-integer (image-descriptor (s48-imported-bindings)))
  21. (write-header-integer (image-descriptor (s48-exported-bindings)))
  22. (write-header-integer resumer-records)
  23. (write-header-integer resume-proc)
  24. (write-page))
  25. (define (image-size)
  26. (address-difference *image-hp* *image-begin*))
  27. (define (begin-making-image/gc-specific)
  28. ; (let ((cand-addr (get-candidate-address)))
  29. ; (if (not (null-address? cand-addr))
  30. ; (set! image-start-address (address->integer cand-addr))))
  31. ;; There seems to be no problem with a possible null-address - David
  32. (set! image-start-address (address->integer (get-candidate-address)))
  33. (set! *image-begin* (integer->address image-start-address))
  34. (set! *image-hp* (integer->address image-start-address)))
  35. (define (allocate-new-image-object stob)
  36. (let* ((new-descriptor (image-alloc (enum area-type-size small)
  37. (header-length-in-a-units (stob-header stob)))))
  38. (values new-descriptor
  39. (make-image-location new-descriptor))))
  40. (define (finalize-new-image-object stob)
  41. (unspecific))
  42. (define (get-candidate-address)
  43. (get-new-heap-start-addr))
  44. (define (image-alloc area-type-size length-in-a-units)
  45. (let ((data-addr (address+ *image-hp* (cells->a-units stob-overhead))))
  46. (set! *image-hp* (address+ data-addr length-in-a-units))
  47. (address->stob-descriptor data-addr)))
  48. (define (write-image-areas first-stob stob-table write-stob)
  49. (let loop ((stob first-stob))
  50. (if (stob? stob)
  51. (let ((location (table-ref stob-table stob)))
  52. (if (null-pointer? location)
  53. (error "traced stob has no image-table entry"))
  54. (write-stob stob)
  55. (loop (image-location-next location))))))
  56. (define (deallocate-areas)
  57. (unspecific))
  58. (define (adjust-descriptors! stob-table)
  59. (unspecific))
  60. (define (note-traced-last-stob!)
  61. (unspecific))