summaryrefslogtreecommitdiff
path: root/rts/Hash.c
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2020-05-25 11:59:11 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-11 03:20:35 -0500
commitc34a4b98b1f09ea3096d39a839a86f2d7185c796 (patch)
treebf3700fd70504a5676220df8702b41810e880846 /rts/Hash.c
parent584058ddff71460023712a8d816b83b581e6e78f (diff)
downloadhaskell-c34a4b98b1f09ea3096d39a839a86f2d7185c796.tar.gz
Fix and enable object unloading in GHCi
Fixes #16525 by tracking dependencies between object file symbols and marking symbol liveness during garbage collection See Note [Object unloading] in CheckUnload.c for details.
Diffstat (limited to 'rts/Hash.c')
-rw-r--r--rts/Hash.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/rts/Hash.c b/rts/Hash.c
index 31a285aefa..6e1873ff29 100644
--- a/rts/Hash.c
+++ b/rts/Hash.c
@@ -492,6 +492,27 @@ mapHashTableKeys(HashTable *table, void *data, MapHashFnKeys fn)
}
}
+void
+iterHashTable(HashTable *table, void *data, IterHashFn fn)
+{
+ /* The last bucket with something in it is table->max + table->split - 1 */
+ long segment = (table->max + table->split - 1) / HSEGSIZE;
+ long index = (table->max + table->split - 1) % HSEGSIZE;
+
+ while (segment >= 0) {
+ while (index >= 0) {
+ for (HashList *hl = table->dir[segment][index]; hl != NULL; hl = hl->next) {
+ if (!fn(data, hl->key, hl->data)) {
+ return;
+ }
+ }
+ index--;
+ }
+ segment--;
+ index = HSEGSIZE - 1;
+ }
+}
+
/* -----------------------------------------------------------------------------
* When we initialize a hash table, we set up the first segment as well,
* initializing all of the first segment's hash buckets to NULL.
@@ -522,12 +543,6 @@ allocHashTable(void)
return table;
}
-void
-exitHashTable(void)
-{
- /* nothing to do */
-}
-
int keyCountHashTable (HashTable *table)
{
return table->kcount;