From: Ivan Maidanski Date: Fri, 22 Mar 2019 17:23:47 +0000 (+0300) Subject: Update the ASCII diagrams describing the tree structure for pointer lookups X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=006ecb4d941e5e6184b15fef81d1073917e502fe;p=gc Update the ASCII diagrams describing the tree structure for pointer lookups * doc/tree.md (A picture): Update the Dave Barrett's ASCII diagrams (from v3.7, 1994) to match the current BDWGC version. --- diff --git a/doc/tree.md b/doc/tree.md index cdf1aa7b..801638f2 100644 --- a/doc/tree.md +++ b/doc/tree.md @@ -77,99 +77,99 @@ is contiguous and not excessively large. ## A picture -The following is an _ASCII_ diagram of the data structure used by GC_base (as -of GC v3.7, Apr 21, 1994). This was contributed by Dave Barrett. - - - 63 LOG_TOP_SZ[11] LOG_BOTTOM_SZ[10] LOG_HBLKSIZE[13] - +------------------+----------------+------------------+------------------+ - p:| | TL_HASH(hi) | | HBLKDISPL(p) | - +------------------+----------------+------------------+------------------+ - \-----------------------HBLKPTR(p)-------------------/ - \------------hi-------------------/ - \______ ________/ \________ _______/ \________ _______/ - V V V - | | | - GC_top_index[] | | | - --- +--------------+ | | | - ^ | | | | | - | | | | | | - TOP +--------------+<--+ | | - _SZ +-<| [] | * | | - (items)| +--------------+ if 0 < bi< HBLKSIZE | | - | | | | then large object | | - | | | | starts at the bi'th | | - v | | | HBLK before p. | i | - --- | +--------------+ | (word- | - v | aligned) | - bi= |GET_BI(p){->hash_link}->key==hi | | - v | | - | (bottom_index) \ scratch_alloc'd | | - | ( struct bi ) / by get_index() | | - --- +->+--------------+ | | - ^ | | | | - ^ | | | | - BOTTOM | | ha=GET_HDR_ADDR(p) | | - _SZ(items)+--------------+<----------------------+ +-------+ - | +--<| index[] | | - | | +--------------+ GC_obj_map: v - | | | | from / +-+-+-----+-+-+-+-+ --- - v | | | GC_add < 0| | | | | | | | ^ - --- | +--------------+ _map_entry \ +-+-+-----+-+-+-+-+ | - | | asc_link | +-+-+-----+-+-+-+-+ MAXOBJSZ - | +--------------+ +-->| | | j | | | | | +1 - | | key | | +-+-+-----+-+-+-+-+ | - | +--------------+ | +-+-+-----+-+-+-+-+ | - | | hash_link | | | | | | | | | | v - | +--------------+ | +-+-+-----+-+-+-+-+ --- - | | |<--MAX_OFFSET--->| - | | (bytes) - HDR(p)| GC_find_header(p) | |<--MAP_ENTRIES-->| - | \ from | =HBLKSIZE/WORDSZ - | (hdr) (struct hblkhdr) / alloc_hdr() | (1024 on Alpha) - +-->+----------------------+ | (8/16 bits each) - GET_HDR(p)| word hb_sz (words) | | - +----------------------+ | - | struct hblk *hb_next | | - +----------------------+ | - |mark_proc hb_mark_proc| | - +----------------------+ | - | char * hb_map |>-------------+ - +----------------------+ - | ushort hb_obj_kind | - +----------------------+ - | hb_last_reclaimed | - --- +----------------------+ - ^ | | - MARK_BITS| hb_marks[] | * if hdr is free, hb_sz is the size of - _SZ(words)| | a heap chunk (struct hblk) of at least - v | | MININCR*HBLKSIZE bytes (below), - --- +----------------------+ otherwise, size of each object in chunk. +The following is an _ASCII_ diagram of the data structure used by GC_base. This was +contributed originally by Dave Barrett. + + + 63 LOG_TOP_SZ[11] LOG_BOTTOM_SZ[10] LOG_HBLKSIZE[13] + +------------------+----------------+------------------+------------------+ + p:| | TL_HASH(hi) | | HBLKDISPL(p) | + +------------------+----------------+------------------+------------------+ + \-----------------------HBLKPTR(p)-------------------/ + \------------hi-------------------/ + \______ ________/ \________ _______/ \________ _______/ + V V V + | | | + GC_top_index[] | | | + --- +--------------+ | | | + ^ | | | | | + | | | | | | + TOP_SZ +--------------+<--+ | | + (items)+-<| [] | * | | + | | +--------------+ if 0 < bi< HBLKSIZE | | + | | | | then large object | | + | | | | starts at the bi'th | | + v | | | hblk before p. | i | + --- | +--------------+ | (word- | + v | aligned) | + bi= |GET_BI(p){->hash_link}->key==hi | | + v | | + | (bottom_index) \ scratch_alloc'd | | + | ( struct bi ) / by get_index() | | + --- +->+--------------+ | | + ^ | | | | + | | | | | + BOTTOM_SZ | | ha=GET_HDR_ADDR(p) | | + (items) +--------------+<----------------------+ +-------+ + | +--<| index[] | | + | | +--------------+ GC_obj_map: v + | | | | from / +-+-+-----+-+-+-+-+ --- + v | | | GC_add_map_entry <0| | | | | | | | ^ + --- | +--------------+ \ +-+-+-----+-+-+-+-+ | + | | asc_link | +-+-+-----+-+-+-+-+ MAXOBJGRANULES + | +--------------+ +-->| | | j | | | | | +1 + | | key | | +-+-+-----+-+-+-+-+ | + | +--------------+ | +-+-+-----+-+-+-+-+ | + | | hash_link | | | | | | | | | | v + | +--------------+ | +-+-+-----+-+-+-+-+ --- + | | |<----MAP_LEN---->| + | | =HBLKSIZE/GRANULE_BYTES + HDR(p)| GC_find_header(p) | (1024 on Alpha) + | \ from | (8/16 bits each) + | (hdr) (struct hblkhdr) / alloc_hdr() | + +--->+----------------------+ | + GET_HDR(p)| word hb_sz (words) | | + +----------------------+ | + | struct hblk *hb_next | | + +----------------------+ | + | word hb_descr | | + +----------------------+ | + | char * hb_map |>------------+ + +----------------------+ + | ushort hb_obj_kind | + +----------------------+ + | hb_last_reclaimed | + --- +----------------------+ + ^ | | + MARK_BITS_SZ| hb_marks[] | * if hdr is free, hb_sz is the size of + (words) | | a heap chunk (struct hblk) of at least + v | | MININCR*HBLKSIZE bytes (below), + --- +----------------------+ otherwise, size of each object in chunk. Dynamic data structures above are interleaved throughout the heap in blocks of size `MININCR * HBLKSIZE` bytes as done by `gc_scratch_alloc` which cannot -be freed; free lists are used (e.g. `alloc_hdr`). `HBLK`'s below are +be freed; free lists are used (e.g. `alloc_hdr`). `hblk`'s below are collected. - (struct hblk) HDR_BYTES - --- +----------------------+ < HBLKSIZE --- (bytes) - ^ +-----hb_body----------+ (and WORDSZ) ^ --- --- - | | | aligned | ^ ^ - | | | | hb_sz | - | | | | (words) | - | | Object 0 | | | | - | | | i |(word- v | - | + - - - - - - - - - - -+ --- (bytes)|aligned) --- | - | | | ^ | ^ | - | | | j (words) | | | - n * | Object 1 | v v hb_sz BODY_SZ - HBLKSIZE | |--------------- | (words) - (bytes) | | v MAX_OFFSET - | + - - - - - - - - - - -+ --- (bytes) - | | | !ALL_INTERIOR_POINTERS ^ | - | | | sets j only for hb_sz | - | | Object N | valid object offsets. | | - v | | All objects WORDSZ v v - --- +----------------------+ aligned. --- --- + (struct hblk) + --- +----------------------+ < HBLKSIZE --- + ^ +-----hb_body----------+ (and WORDSZ) ^ --- --- + | | | aligned | ^ ^ + | | | | hb_sz | + | | | | (words) | + | | Object 0 | | | | + | | | i |(word- v | + | + - - - - - - - - - - -+ --- (bytes)|aligned) --- | + | | | ^ | ^ | + | | | j (words) | | | + n * | Object 1 | v v hb_sz HBLKSIZE/BYTES_PER_WORD + HBLKSIZE | |--------------- | (words) + (bytes) | | v | + | + - - - - - - - - - - -+ --- | + | | | !ALL_INTERIOR_POINTERS ^ | + | | | sets j only for hb_sz | + | | Object N | valid object offsets. | | + v | | All objects WORDSZ- v v + --- +----------------------+ aligned. --- ---