ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 8364209 was
bf71cfd,
checked in by Thierry Delisle <tdelisle@…>, 6 years ago
|
Moved up many directories in source
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[16cfd8c] | 1 | #pragma once |
---|
| 2 | |
---|
| 3 | #include "globals.h" |
---|
| 4 | #include "tools.h" |
---|
| 5 | |
---|
| 6 | static inline size_t card_of(void* address) |
---|
| 7 | { |
---|
| 8 | size_t card = ( ((intptr_t)address) & CARDS_OFFSET_MASK ) >> CARDS_SIZE_EXP; |
---|
[76af36f] | 9 | checkf(card < CARDS_COUNT, (const char*)"%lu %lu = (%lx & %lx) >> %lu\n", (size_t)CARDS_COUNT, (size_t)card, (size_t)address, (size_t)CARDS_OFFSET_MASK, (size_t)CARDS_SIZE_EXP); |
---|
[16cfd8c] | 10 | check(card < CARDS_COUNT); |
---|
| 11 | return card; |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | struct card_table_t |
---|
| 15 | { |
---|
| 16 | size_t count; |
---|
| 17 | void* cards_start[CARDS_COUNT]; |
---|
| 18 | }; |
---|
| 19 | |
---|
[24bc651] | 20 | static inline void ?{}(card_table_t* this) |
---|
[16cfd8c] | 21 | { |
---|
| 22 | this->count = 0; |
---|
| 23 | } |
---|
| 24 | |
---|
[24bc651] | 25 | static inline void ^?{}(card_table_t* this) |
---|
[16cfd8c] | 26 | { |
---|
| 27 | |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | static inline void* object_at(card_table_t* const this, size_t card_number) |
---|
| 31 | { |
---|
| 32 | return card_number < this->count ? this->cards_start[card_number] : NULL; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | static inline void register_object(card_table_t* const this, void* object) |
---|
| 36 | { |
---|
| 37 | size_t card = card_of(object); |
---|
| 38 | if(card < this->count) |
---|
| 39 | { |
---|
| 40 | intptr_t card_obj_add = (intptr_t)object_at(this, card); |
---|
| 41 | intptr_t obj_add = (intptr_t)object; |
---|
| 42 | if(card_obj_add > obj_add) |
---|
| 43 | { |
---|
| 44 | this->cards_start[card] = object; |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | else |
---|
| 48 | { |
---|
[46f1d20] | 49 | check(card == this->count); |
---|
[16cfd8c] | 50 | this->count++; |
---|
| 51 | this->cards_start[card] = object; |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | static inline void reset(card_table_t* const this) |
---|
| 56 | { |
---|
| 57 | for(size_t i = 0; i < this->count; i++) |
---|
| 58 | { |
---|
| 59 | this->cards_start[i] = NULL; |
---|
| 60 | } |
---|
| 61 | this->count = 0; |
---|
| 62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.