summaryrefslogtreecommitdiff
path: root/rts/StaticPtrTable.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2016-08-31 19:39:54 -0400
committerBen Gamari <ben@smart-cactus.org>2017-01-08 22:19:45 -0500
commit98ed207472febdc3b2a144267f8af9b29b44934c (patch)
treef6f2dea660fb6f391d3a7e89edddb8e0daf55227 /rts/StaticPtrTable.c
parent326931db9cdc26f2d47657c1f084b9903fd46246 (diff)
downloadhaskell-wip/ghci-staticptrs.tar.gz
Add support for StaticPointers in GHCiwip/ghci-staticptrs
Here we add support to GHCi for StaticPointers. This process begins by adding remote GHCi messages for adding entries to the static pointer table. We then collect binders needing SPT entries after linking and send the interpreter a message adding entries with the appropriate fingerprints.
Diffstat (limited to 'rts/StaticPtrTable.c')
-rw-r--r--rts/StaticPtrTable.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/rts/StaticPtrTable.c b/rts/StaticPtrTable.c
index 57ade5bafb..b793b9c56c 100644
--- a/rts/StaticPtrTable.c
+++ b/rts/StaticPtrTable.c
@@ -31,7 +31,7 @@ static int compareFingerprint(StgWord64 ptra[2], StgWord64 ptrb[2]) {
return ptra[0] == ptrb[0] && ptra[1] == ptrb[1];
}
-void hs_spt_insert(StgWord64 key[2],void *spe_closure) {
+void hs_spt_insert_stableptr(StgWord64 key[2], StgStablePtr *entry) {
// hs_spt_insert is called from constructor functions, so
// the SPT needs to be initialized here.
if (spt == NULL) {
@@ -43,6 +43,12 @@ void hs_spt_insert(StgWord64 key[2],void *spe_closure) {
#endif
}
+ ACQUIRE_LOCK(&spt_lock);
+ insertHashTable(spt, (StgWord)key, entry);
+ RELEASE_LOCK(&spt_lock);
+}
+
+void hs_spt_insert(StgWord64 key[2], void *spe_closure) {
// Cannot remove this indirection yet because getStablePtr()
// might return NULL, in which case hs_spt_lookup() returns NULL
// instead of the actual closure pointer.
@@ -50,9 +56,7 @@ void hs_spt_insert(StgWord64 key[2],void *spe_closure) {
, "hs_spt_insert: entry"
);
*entry = getStablePtr(spe_closure);
- ACQUIRE_LOCK(&spt_lock);
- insertHashTable(spt, (StgWord)key, entry);
- RELEASE_LOCK(&spt_lock);
+ hs_spt_insert_stableptr(key, entry);
}
static void freeSptEntry(void* entry) {