areas.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Part of Scheme 48 1.9. See file COPYING for notices and license.
  3. *
  4. * Authors: David Frese, Robert Ransom
  5. */
  6. #ifndef __S48_AREAS_H
  7. #define __S48_AREAS_H
  8. #include "memory.h"
  9. #include "gc_config.h"
  10. #include "remset.h"
  11. /* Areas
  12. Memory is divided into areas, each of which has:
  13. start address
  14. end pointer
  15. allocation pointer (points to next unused space)
  16. next area in this category
  17. Each generation is a set of areas, grouped into lists by metatype and
  18. fixed-ness
  19. */
  20. typedef struct {
  21. #if S48_DIRTY_VECTOR_METHOD==S48_ADDRESS_DIRTY_VECTORS
  22. int length;
  23. s48_address* items;
  24. #endif
  25. } Dirty_vector;
  26. /* must be synchronized with the Scheme-side definition in ALLOCATION */
  27. typedef enum { AREA_TYPE_SIZE_SMALL, AREA_TYPE_SIZE_LARGE, AREA_TYPE_SIZE_WEAKS,
  28. AREA_TYPE_SIZE_ILLEGAL }
  29. area_type_size_t;
  30. typedef enum {GC_ACTION_IGNORE = 0, GC_ACTION_ERROR, GC_ACTION_COPY_MIXED,
  31. GC_ACTION_COPY_SMALL, GC_ACTION_MARK_LARGE,
  32. GC_ACTION_COPY_WEAK}
  33. gc_action_t;
  34. typedef struct Area {
  35. s48_address start;
  36. s48_address end;
  37. s48_address frontier;
  38. struct Area* next;
  39. int generation_index;
  40. area_type_size_t area_type_size;
  41. /* only used during collection: */
  42. gc_action_t action;
  43. s48_address trace;
  44. Dirty_vector dirty_vector;
  45. struct Space* target_space;
  46. #if S48_USE_REMEMBERED_SETS==TRUE
  47. RemSet* remset;
  48. #endif
  49. } Area;
  50. typedef struct Space {
  51. int generation_index;
  52. Area* small_area;
  53. Area* large_area;
  54. Area* weaks_area;
  55. } Space;
  56. #define AREA_REMAINING(area) ((area) == NULL ? 0 :\
  57. (area)->end - (area)->frontier)
  58. /* Allocate an area of between MINIMUM and MAXIMUM pages, inclusive. */
  59. extern Area* s48_allocate_area_without_crashing(unsigned long minimum,
  60. unsigned long maximum,
  61. unsigned char generation_index,
  62. area_type_size_t area_type_size);
  63. extern Area* s48_allocate_area(unsigned long minimum, unsigned long maximum,
  64. unsigned char generation_index, area_type_size_t area_type_size);
  65. /* Remove AREA from the list starting with START */
  66. extern Area* s48_delete_area(Area* start, Area* area);
  67. /* Free all pages covered by AREA, update the memory_map and free Area
  68. struct itself too. */
  69. extern void s48_free_area(Area* area);
  70. /* Call s48_free_area on all areas in the list starting with START */
  71. extern void s48_free_areas(Area* start);
  72. /* Allocate a block for the whole image */
  73. void s48_allocate_image_area(long bytes, s48_address* start, s48_address* end);
  74. /* Wrap the static make_area */
  75. Area* s48_make_area(s48_address start, s48_address end,
  76. s48_address frontier,
  77. unsigned char generation_index,
  78. area_type_size_t area_type_size);
  79. #endif