]> gitweb.factorcode.org Git - factor.git/blob - vm/write_barrier.hpp
webapps.wiki: adding search bar
[factor.git] / vm / write_barrier.hpp
1 // card marking write barrier. a card is a byte storing a mark flag,
2 // and the offset (in cells) of the first object in the card.
3
4 // the mark flag is set by the write barrier when an object in the
5 // card has a slot written to.
6
7 // the offset of the first object is set by the allocator.
8
9 namespace factor {
10
11 // if card_points_to_nursery is set, card_points_to_aging must also be set.
12 static const cell card_points_to_nursery = 0x80;
13 static const cell card_points_to_aging = 0x40;
14 static const cell card_mark_mask =
15     (card_points_to_nursery | card_points_to_aging);
16 typedef uint8_t card;
17
18 static const cell card_bits = 8;
19 static const cell card_size = 1 << card_bits;
20 static const cell addr_card_mask = card_size - 1;
21
22 typedef uint8_t card_deck;
23
24 static const cell deck_bits = card_bits + 10;
25 // Number of bytes on the heap a deck addresses. Each deck as 1024
26 // cards. So 256 kb.
27 static const cell deck_size = 1 << deck_bits;
28 static const cell cards_per_deck = 1 << 10;
29
30 inline cell addr_to_card(cell a) { return a >> card_bits; }
31
32 inline cell addr_to_deck(cell a) { return a >> deck_bits; }
33 }