memory_map.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Part of Scheme 48 1.9. See file COPYING for notices and license.
  3. *
  4. * Authors: David Frese
  5. */
  6. /* The Boehm collector also has a link to the next entry in ascending
  7. order. This is used for sweeping etc.. I don't think we need
  8. such. It would be hard to reconstruct dynamically. It is easy
  9. enough to find adjacent blocks, which is all I would think matters
  10. to us */
  11. #include <stdlib.h>
  12. #include "utils.h"
  13. #include "memory_map.h"
  14. #include "page_constants.h"
  15. Metapage* s48_memory_table[TABLE_SIZE];
  16. void s48_memory_map_setB(s48_address address, Area* value) {
  17. Metapage** metapagep = find_metapagep(address);
  18. Metapage* metapage = *metapagep;
  19. if (metapage == NULL) {
  20. metapage = (Metapage*)calloc(1, sizeof(Metapage));
  21. if (metapage == NULL) s48_gc_error("add_metapage: out of memory");
  22. #ifdef NEED_METAPAGE_HASHING
  23. metapage->start_address = ADDR_REST_MASKED(address);
  24. assert(IS_CORRECT_METAPAGE(metapage, address));
  25. metapage->next = NULL;
  26. #endif
  27. *metapagep = metapage;
  28. }
  29. metapage->contents[ADDR_PAGE_INDEX(address)] = value;
  30. assert(metapage == *(find_metapagep(address)));
  31. }