Add support for GL_BGRA_ext
[factor/jcg.git] / vm / write_barrier.h
blobbe75d189de4f7bd2a8b52bdb7a5cd52cc76e70de
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.
4 the mark flag is set by the write barrier when an object in the
5 card has a slot written to.
7 the offset of the first object is set by the allocator. */
9 /* if CARD_POINTS_TO_NURSERY is set, CARD_POINTS_TO_AGING must also be set. */
10 #define CARD_POINTS_TO_NURSERY 0x80
11 #define CARD_POINTS_TO_AGING 0x40
12 #define CARD_MARK_MASK (CARD_POINTS_TO_NURSERY | CARD_POINTS_TO_AGING)
13 typedef u8 F_CARD;
15 #define CARD_BITS 8
16 #define CARD_SIZE (1<<CARD_BITS)
17 #define ADDR_CARD_MASK (CARD_SIZE-1)
19 DLLEXPORT CELL cards_offset;
21 #define ADDR_TO_CARD(a) (F_CARD*)(((CELL)(a) >> CARD_BITS) + cards_offset)
22 #define CARD_TO_ADDR(c) (CELL*)(((CELL)(c) - cards_offset)<<CARD_BITS)
24 typedef u8 F_DECK;
26 #define DECK_BITS (CARD_BITS + 10)
27 #define DECK_SIZE (1<<DECK_BITS)
28 #define ADDR_DECK_MASK (DECK_SIZE-1)
30 DLLEXPORT CELL decks_offset;
32 #define ADDR_TO_DECK(a) (F_DECK*)(((CELL)(a) >> DECK_BITS) + decks_offset)
33 #define DECK_TO_ADDR(c) (CELL*)(((CELL)(c) - decks_offset) << DECK_BITS)
35 #define DECK_TO_CARD(d) (F_CARD*)((((CELL)(d) - decks_offset) << (DECK_BITS - CARD_BITS)) + cards_offset)
37 #define ADDR_TO_ALLOT_MARKER(a) (F_CARD*)(((CELL)(a) >> CARD_BITS) + allot_markers_offset)
38 #define CARD_OFFSET(c) (*((c) - (CELL)data_heap->cards + (CELL)data_heap->allot_markers))
40 #define INVALID_ALLOT_MARKER 0xff
42 DLLEXPORT CELL allot_markers_offset;
44 /* the write barrier must be called any time we are potentially storing a
45 pointer from an older generation to a younger one */
46 INLINE void write_barrier(CELL address)
48 *ADDR_TO_CARD(address) = CARD_MARK_MASK;
49 *ADDR_TO_DECK(address) = CARD_MARK_MASK;
52 #define SLOT(obj,slot) (UNTAG(obj) + (slot) * CELLS)
54 INLINE void set_slot(CELL obj, CELL slot, CELL value)
56 put(SLOT(obj,slot),value);
57 write_barrier(obj);
60 /* we need to remember the first object allocated in the card */
61 INLINE void allot_barrier(CELL address)
63 F_CARD *ptr = ADDR_TO_ALLOT_MARKER(address);
64 if(*ptr == INVALID_ALLOT_MARKER)
65 *ptr = (address & ADDR_CARD_MASK);