barrett_diagram 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. This is an ASCII diagram of the data structure used to check pointer
  2. validity. It was provided by Dave Barrett <barrett@asgard.cs.colorado.edu>,
  3. and should be of use to others attempting to understand the code.
  4. The data structure in GC4.X is essentially the same. -HB
  5. Data Structure used by GC_base in gc3.7:
  6. 21-Apr-94
  7. 63 LOG_TOP_SZ[11] LOG_BOTTOM_SZ[10] LOG_HBLKSIZE[13]
  8. +------------------+----------------+------------------+------------------+
  9. p:| | TL_HASH(hi) | | HBLKDISPL(p) |
  10. +------------------+----------------+------------------+------------------+
  11. \-----------------------HBLKPTR(p)-------------------/
  12. \------------hi-------------------/
  13. \______ ________/ \________ _______/ \________ _______/
  14. V V V
  15. | | |
  16. GC_top_index[] | | |
  17. --- +--------------+ | | |
  18. ^ | | | | |
  19. | | | | | |
  20. TOP +--------------+<--+ | |
  21. _SZ +-<| [] | * | |
  22. (items)| +--------------+ if 0 < bi< HBLKSIZE | |
  23. | | | | then large object | |
  24. | | | | starts at the bi'th | |
  25. v | | | HBLK before p. | i |
  26. --- | +--------------+ | (word- |
  27. v | aligned) |
  28. bi= |GET_BI(p){->hash_link}->key==hi | |
  29. v | |
  30. | (bottom_index) \ scratch_alloc'd | |
  31. | ( struct bi ) / by get_index() | |
  32. --- +->+--------------+ | |
  33. ^ | | | |
  34. ^ | | | |
  35. BOTTOM | | ha=GET_HDR_ADDR(p) | |
  36. _SZ(items)+--------------+<----------------------+ +-------+
  37. | +--<| index[] | |
  38. | | +--------------+ GC_obj_map: v
  39. | | | | from / +-+-+-----+-+-+-+-+ ---
  40. v | | | GC_add < 0| | | | | | | | ^
  41. --- | +--------------+ _map_entry \ +-+-+-----+-+-+-+-+ |
  42. | | asc_link | +-+-+-----+-+-+-+-+ MAXOBJSZ
  43. | +--------------+ +-->| | | j | | | | | +1
  44. | | key | | +-+-+-----+-+-+-+-+ |
  45. | +--------------+ | +-+-+-----+-+-+-+-+ |
  46. | | hash_link | | | | | | | | | | v
  47. | +--------------+ | +-+-+-----+-+-+-+-+ ---
  48. | | |<--MAX_OFFSET--->|
  49. | | (bytes)
  50. HDR(p)| GC_find_header(p) | |<--MAP_ENTRIES-->|
  51. | \ from | =HBLKSIZE/WORDSZ
  52. | (hdr) (struct hblkhdr) / alloc_hdr() | (1024 on Alpha)
  53. +-->+----------------------+ | (8/16 bits each)
  54. GET_HDR(p)| word hb_sz (words) | |
  55. +----------------------+ |
  56. | struct hblk *hb_next | |
  57. +----------------------+ |
  58. |mark_proc hb_mark_proc| |
  59. +----------------------+ |
  60. | char * hb_map |>-------------+
  61. +----------------------+
  62. | ushort hb_obj_kind |
  63. +----------------------+
  64. | hb_last_reclaimed |
  65. --- +----------------------+
  66. ^ | |
  67. MARK_BITS| hb_marks[] | *if hdr is free, hb_sz + DISCARD_WORDS
  68. _SZ(words)| | is the size of a heap chunk (struct hblk)
  69. v | | of at least MININCR*HBLKSIZE bytes (below),
  70. --- +----------------------+ otherwise, size of each object in chunk.
  71. Dynamic data structures above are interleaved throughout the heap in blocks of
  72. size MININCR * HBLKSIZE bytes as done by gc_scratch_alloc which cannot be
  73. freed; free lists are used (e.g. alloc_hdr). HBLKs's below are collected.
  74. (struct hblk)
  75. --- +----------------------+ < HBLKSIZE --- --- DISCARD_
  76. ^ |garbage[DISCARD_WORDS]| aligned ^ ^ HDR_BYTES WORDS
  77. | | | | v (bytes) (words)
  78. | +-----hb_body----------+ < WORDSZ | --- ---
  79. | | | aligned | ^ ^
  80. | | Object 0 | | hb_sz |
  81. | | | i |(word- (words)|
  82. | | | (bytes)|aligned) v |
  83. | + - - - - - - - - - - -+ --- | --- |
  84. | | | ^ | ^ |
  85. n * | | j (words) | hb_sz BODY_SZ
  86. HBLKSIZE | Object 1 | v v | (words)
  87. (bytes) | |--------------- v MAX_OFFSET
  88. | + - - - - - - - - - - -+ --- (bytes)
  89. | | | !All_INTERIOR_PTRS ^ |
  90. | | | sets j only for hb_sz |
  91. | | Object N | valid object offsets. | |
  92. v | | All objects WORDSZ v v
  93. --- +----------------------+ aligned. --- ---
  94. DISCARD_WORDS is normally zero. Indeed the collector has not been tested
  95. with another value in ages.