diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-02-01 23:39:52 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-02-02 00:18:58 -0500 |
commit | eedb3df0c1c28a7abc43705d614239c1c6199a1f (patch) | |
tree | 32045d426c9ecd4b07d74871d65d3e605842672d /rts | |
parent | b16239a95b730dd2d6fc0dbb18c8430669f2c187 (diff) | |
download | haskell-eedb3df0c1c28a7abc43705d614239c1c6199a1f.tar.gz |
Add support for StaticPointers in GHCi
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.
Test Plan: `make test TEST=StaticPtr`
Reviewers: facundominguez, mboes, simonpj, simonmar, goldfire, austin,
hvr, erikd
Reviewed By: simonpj, simonmar
Subscribers: RyanGlScott, simonpj, thomie
Differential Revision: https://phabricator.haskell.org/D2504
GHC Trac Issues: #12356
Diffstat (limited to 'rts')
-rw-r--r-- | rts/RtsSymbols.c | 1 | ||||
-rw-r--r-- | rts/StaticPtrTable.c | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c index be61388501..b5e4f8e8bf 100644 --- a/rts/RtsSymbols.c +++ b/rts/RtsSymbols.c @@ -904,6 +904,7 @@ SymI_HasProto(atomic_dec) \ SymI_HasProto(hs_spt_lookup) \ SymI_HasProto(hs_spt_insert) \ + SymI_HasProto(hs_spt_insert_stableptr) \ SymI_HasProto(hs_spt_remove) \ SymI_HasProto(hs_spt_keys) \ SymI_HasProto(hs_spt_key_count) \ 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) { |