bibop-gc-package-defs.scm 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. ; Copyright (c) 1993-2008 by Richard Kelsey and Jonathan Rees. See file COPYING.
  2. ;; Packages for BIBOP GC
  3. ;----------------------------------------------------------------
  4. ; Memory management
  5. (define-interface heap-bibop-interface
  6. (export s48-set-max-heap-size!
  7. s48-max-heap-size
  8. s48-min-heap-size
  9. s48-set-new-small-start-addr!
  10. s48-get-new-small-start-addr
  11. s48-set-new-large-start-addr!
  12. s48-get-new-large-start-addr
  13. s48-set-new-weaks-start-addr!
  14. s48-get-new-weaks-start-addr))
  15. (define-structures ((heap heap-interface)
  16. (heap-gc-util heap-gc-util-interface)
  17. (heap-init heap-init-interface)
  18. (heap-bibop heap-bibop-interface))
  19. (open prescheme ps-receive vm-utilities vm-architecture memory data
  20. ps-memory
  21. debugging
  22. bibop-gc-external)
  23. (files (gc-bibop heap)))
  24. (define-structures ((gc gc-interface)
  25. (gc-bibop-util (export s48-trace-continuation)))
  26. (open prescheme ps-receive vm-utilities vm-architecture
  27. memory data
  28. heap heap-gc-util
  29. interpreter-gc
  30. bibop-gc-external)
  31. (files (gc-bibop gc)
  32. (heap trace-continuation)))
  33. (define-structure allocation allocation-interface
  34. (open prescheme memory heap-gc-util gc data vm-architecture
  35. gc-static-hack
  36. bibop-gc-external)
  37. (files (gc-bibop allocation)))
  38. ; This should be in heap.scm except that it needs GC and GC needs HEAP,
  39. ; so we have to put this in its own package to avoid a dependency loop.
  40. (define-structure gc-static-hack (export)
  41. (open prescheme gc heap-gc-util gc-roots)
  42. (begin
  43. (add-gc-root! (lambda ()
  44. (walk-impure-areas
  45. (lambda (start end)
  46. (s48-trace-locations! start end)
  47. #t))))))
  48. ;; These are the things defined in c/bibop/*
  49. (define-structure bibop-gc-external
  50. (export s48-make-available+gc
  51. s48-allocate-small
  52. s48-allocate-traced+gc
  53. s48-allocate-untraced+gc
  54. s48-allocate-untraced-unmovable+gc
  55. s48-allocate-weak+gc
  56. s48-forbid-gc!
  57. s48-allow-gc!
  58. s48-collect
  59. s48-trace-value
  60. s48-trace-locations!
  61. s48-trace-stob-contents!
  62. s48-extant?
  63. s48-gc-count
  64. s48-write-barrier
  65. s48-check-heap
  66. s48-stob-in-heap?
  67. s48-available
  68. s48-find-all
  69. s48-find-all-records
  70. s48-gather-objects
  71. s48-heap-size
  72. s48-initialize-bibop-heap
  73. s48-allocate-heap-size
  74. s48-initialize-image-areas
  75. s48-check-heap-size!)
  76. (open prescheme)
  77. (begin
  78. ;; (pre)allocates space for a small, fixed-sized objects
  79. (define s48-make-available+gc
  80. (external "s48_make_availableAgc" (=> (integer) null)))
  81. ;; actually allocate a small, fixed-sized object, with no heap
  82. ;; check and no GC
  83. (define s48-allocate-small
  84. (external "s48_allocate_small" (=> (integer) address)))
  85. ;; allocate a potentially large object containing pointers, GCing
  86. ;; to get room if necessary
  87. (define s48-allocate-traced+gc
  88. (external "s48_allocate_tracedAgc" (=> (integer) address)))
  89. ;; allocate a potentially large object not containing pointers,
  90. ;; GCing to get room if necessary
  91. (define s48-allocate-untraced+gc
  92. (external "s48_allocate_untracedAgc" (=> (integer) address)))
  93. ;; allocate an unmovable object (allocation uses the large area
  94. ;; discarding the size of the object. The large area is collected
  95. ;; with the non-copy algorithmus). GCing to get room if necessary
  96. (define s48-allocate-untraced-unmovable+gc
  97. (external "s48_allocate_untraced_unmovableAgc" (=> (integer) address)))
  98. ;; allocate a weak-pointer object, GCing to get room if necessary
  99. (define s48-allocate-weak+gc
  100. (external "s48_allocate_weakAgc" (=> (integer) address)))
  101. ;; tell the GC not to collect in any case mainly used on startup
  102. ;; during reading the image
  103. (define s48-forbid-gc!
  104. (external "s48_forbid_gcB" (=> () null)))
  105. ;; the GC may collect again
  106. (define s48-allow-gc!
  107. (external "s48_allow_gcB" (=> () null)))
  108. ;; these are defined in c/bibop/area_gc.c
  109. (define s48-collect
  110. (external "s48_collect" (=> (boolean) null)))
  111. (define s48-trace-value ;; s48_value -> s48_value
  112. (external "s48_trace_value" (=> (integer) integer)))
  113. (define s48-trace-locations! ;; address, address -> void
  114. (external "s48_trace_locationsB" (=> (address address) null)))
  115. (define s48-trace-stob-contents! ;; s48_value -> void
  116. (external "s48_trace_stob_contentsB" (=> (integer) null)))
  117. (define s48-extant? ;; s48_value -> bool
  118. (external "s48_extantP" (=> (integer) boolean)))
  119. (define s48-gc-count ;; void -> integer
  120. (external "s48_gc_count" (=> () integer)))
  121. (define s48-write-barrier
  122. (external "S48_WRITE_BARRIER" (=> (integer address integer) null)))
  123. (define s48-check-heap
  124. (external "s48_check_heap" (=> (integer) boolean)))
  125. (define s48-stob-in-heap?
  126. (external "s48_stob_in_heapP" (=> (integer) boolean)))
  127. (define s48-available ;; void -> integer (cells)
  128. (external "s48_available" (=> () integer)))
  129. (define s48-find-all ;; integer -> s48_value
  130. (external "s48_find_all" (=> (integer) integer)))
  131. (define s48-find-all-records ;; s48_value -> s48_value
  132. (external "s48_find_all_records" (=> (integer) integer)))
  133. (define s48-gather-objects
  134. (external "s48_gather_objects" (=> ((=> (integer) boolean)
  135. (=> ((=> (integer) boolean)) boolean))
  136. integer)))
  137. (define s48-heap-size
  138. (external "s48_heap_size" (=> () integer)))
  139. (define s48-initialize-bibop-heap
  140. (external "s48_initialize_bibop_heap" (=> () null)))
  141. ;; defined in generation_gc.c and used by the dumper
  142. (define s48-initialize-image-areas
  143. (external "s48_initialize_image_areas"
  144. (=> (integer integer integer integer integer integer) null)))
  145. (define s48-check-heap-size!
  146. (external "s48_check_heap_sizeB" (=> () null)))
  147. ))
  148. ; Image handling
  149. (define-structure read-image-gc-specific read-image-gc-specific-interface
  150. (open prescheme ps-receive enum-case
  151. vm-utilities vm-architecture
  152. memory
  153. data struct
  154. (subset string-tables (relocate-table-two-space)) ; ####
  155. ps-memory ;allocate/deallocate-memory
  156. heap ;s48-heap-size
  157. heap-bibop
  158. image-util
  159. image-table ;make-table
  160. heap-init
  161. read-image-util
  162. read-image-portable
  163. )
  164. (files (gc-bibop read-image)))
  165. (define-structure read-image-util-gc-specific read-image-util-gc-specific-interface
  166. (open prescheme
  167. heap-bibop)
  168. (begin
  169. (define (get-small-start-addr heap-image-pointer)
  170. (s48-get-new-small-start-addr))
  171. (define (get-large-start-addr heap-image-pointer)
  172. (s48-get-new-large-start-addr))
  173. (define (get-weaks-start-addr heap-image-pointer)
  174. (s48-get-new-weaks-start-addr))))
  175. (define-structure write-image-gc-specific write-image-gc-specific-interface
  176. (open prescheme ps-receive enum-case
  177. vm-utilities vm-architecture
  178. memory data struct
  179. heap
  180. heap-bibop
  181. image-table
  182. image-util
  183. write-image-util
  184. string-tables
  185. symbols ;s48-symbol-table
  186. shared-bindings-access
  187. ps-record-types
  188. (subset allocation (area-type-size))
  189. )
  190. (files (gc-bibop write-image)))