diff options
author | Ömer Sinan Ağacan <omer@well-typed.com> | 2019-02-05 00:40:27 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-10-20 21:15:37 -0400 |
commit | 32500f64935201828843b29899aaf28d3a1aa777 (patch) | |
tree | fad4fca5874c7eedfb2a3c78157aa12bedb56f6c /rts/StableName.h | |
parent | 8057ac965f72285a62cd57432c0a4f941a96a086 (diff) | |
download | haskell-32500f64935201828843b29899aaf28d3a1aa777.tar.gz |
rts/StableName: Expose FOR_EACH_STABLE_NAME, freeSnEntry, SNT_size
These will be needed when we implement sweeping in the nonmoving
collector.
Diffstat (limited to 'rts/StableName.h')
-rw-r--r-- | rts/StableName.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/rts/StableName.h b/rts/StableName.h index 6b5e551add..e5903bb3b5 100644 --- a/rts/StableName.h +++ b/rts/StableName.h @@ -11,7 +11,8 @@ #include "BeginPrivate.h" void initStableNameTable ( void ); -void exitStableNameTable ( void ); +void freeSnEntry ( snEntry *sn ); +void exitStableNameTable ( void ); StgWord lookupStableName ( StgPtr p ); void rememberOldStableNameAddresses ( void ); @@ -23,6 +24,29 @@ void updateStableNameTable ( bool full ); void stableNameLock ( void ); void stableNameUnlock ( void ); +extern unsigned int SNT_size; + +#define FOR_EACH_STABLE_NAME(p, CODE) \ + do { \ + snEntry *p; \ + snEntry *__end_ptr = &stable_name_table[SNT_size]; \ + for (p = stable_name_table + 1; p < __end_ptr; p++) { \ + /* Internal pointers are free slots. */ \ + /* If p->addr == NULL, it's a */ \ + /* stable name where the object has been GC'd, but the */ \ + /* StableName object (sn_obj) is still alive. */ \ + if ((p->addr < (P_)stable_name_table || \ + p->addr >= (P_)__end_ptr)) \ + { \ + /* NOTE: There is an ambiguity here if p->addr == NULL */ \ + /* it is either the last item in the free list or it */ \ + /* is a stable name whose pointee died. sn_obj == NULL */ \ + /* disambiguates as last free list item. */ \ + do { CODE } while(0); \ + } \ + } \ + } while(0) + #if defined(THREADED_RTS) // needed by Schedule.c:forkProcess() extern Mutex stable_name_mutex; |