allocation.scm 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: David Frese, Marcus Crestani, Mike Sperber
  3. ; Interface to the VM for allocation
  4. ;; Everything else is defined via bibop-gc-external
  5. ;; For allocation done outside the VM.
  6. (define (allocate-stob weak? type size unmovable?)
  7. (let* ((traced? (< type least-b-vector-type))
  8. (length-in-bytes (if traced?
  9. (cells->bytes size)
  10. size))
  11. (needed (+ length-in-bytes (cells->bytes stob-overhead)))
  12. (thing (if weak?
  13. (s48-allocate-weak+gc needed)
  14. (if traced?
  15. (if unmovable?
  16. (s48-allocate-traced-unmovable+gc needed)
  17. (s48-allocate-traced+gc needed))
  18. (if unmovable?
  19. (s48-allocate-untraced-unmovable+gc needed)
  20. (s48-allocate-untraced+gc needed))))))
  21. (if (null-address? thing)
  22. (error "insufficient heap space for external allocation"))
  23. (store! thing (make-header type length-in-bytes))
  24. (address->stob-descriptor (address+ thing
  25. (cells->bytes stob-overhead)))))
  26. (define (s48-allocate-stob type size)
  27. (allocate-stob #f type size #f))
  28. (define (s48-allocate-weak-stob type size)
  29. (allocate-stob #t type size #f))
  30. (define (s48-allocate-unmovable-stob type size)
  31. (allocate-stob #f type size #t))