summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-02-06 21:52:54 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-02-13 03:26:14 -0500
commitd6d48b167a35eebe3cecd047814c10f4685906d3 (patch)
tree91fe40d348c92fd83b6a779e7d0feec084a82e5a
parentbe591e27c76f1eaee79df671d8cf7e39d3d41720 (diff)
downloadhaskell-d6d48b167a35eebe3cecd047814c10f4685906d3.tar.gz
Introduce initAdjustors
-rw-r--r--rts/Adjustor.h2
-rw-r--r--rts/RtsStartup.c4
-rw-r--r--rts/adjustor/LibffiAdjustor.c11
-rw-r--r--rts/adjustor/NativeAmd64.c2
-rw-r--r--rts/adjustor/NativeAmd64Mingw.c2
-rw-r--r--rts/adjustor/NativeIA64.c2
-rw-r--r--rts/adjustor/NativePowerPC.c2
-rw-r--r--rts/adjustor/Nativei386.c2
8 files changed, 22 insertions, 5 deletions
diff --git a/rts/Adjustor.h b/rts/Adjustor.h
index a6dcac6d56..d6e387a887 100644
--- a/rts/Adjustor.h
+++ b/rts/Adjustor.h
@@ -5,3 +5,5 @@
#pragma once
int totalArgumentSize(const char *typeString);
+
+void initAdjustors(void);
diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c
index 07db7b7998..bfdfb1e976 100644
--- a/rts/RtsStartup.c
+++ b/rts/RtsStartup.c
@@ -24,6 +24,7 @@
#include "Ticky.h"
#include "StgRun.h"
#include "Prelude.h" /* fixupRTStoPreludeRefs */
+#include "Adjustor.h" /* initAdjustors */
#include "ThreadLabels.h"
#include "sm/BlockAlloc.h"
#include "Trace.h"
@@ -276,6 +277,9 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config)
initConsoleCP();
#endif
+ /* Initialise the adjustors subsystem */
+ initAdjustors();
+
/* Initialise the stats department, phase 1 */
initStats1();
diff --git a/rts/adjustor/LibffiAdjustor.c b/rts/adjustor/LibffiAdjustor.c
index b74059b8ce..e24a4a12f7 100644
--- a/rts/adjustor/LibffiAdjustor.c
+++ b/rts/adjustor/LibffiAdjustor.c
@@ -9,6 +9,7 @@
#include "StablePtr.h"
#include "sm/Storage.h"
#include "Hash.h"
+#include "Adjustor.h"
#include "ffi.h"
#include <string.h>
@@ -16,6 +17,10 @@
/* Maps AdjustorExecutable* to AdjustorWritable*. */
static HashTable* allocatedExecs;
+void initAdjustors() {
+ allocatedExecs = allocHashTable();
+}
+
static AdjustorWritable allocate_adjustor(AdjustorExecutable *exec_ret)
{
AdjustorWritable writ;
@@ -24,9 +29,6 @@ static AdjustorWritable allocate_adjustor(AdjustorExecutable *exec_ret)
ACQUIRE_SM_LOCK;
cl = writ = ffi_closure_alloc(sizeof(ffi_closure), exec_ret);
if (cl != NULL) {
- if (allocatedExecs == NULL) {
- allocatedExecs = allocHashTable();
- }
insertHashTable(allocatedExecs, (StgWord)*exec_ret, writ);
}
RELEASE_SM_LOCK;
@@ -37,8 +39,7 @@ static AdjustorWritable exec_to_writable(AdjustorExecutable exec)
{
AdjustorWritable writ;
ACQUIRE_SM_LOCK;
- if (allocatedExecs == NULL ||
- (writ = lookupHashTable(allocatedExecs, (StgWord)exec)) == NULL) {
+ if ((writ = lookupHashTable(allocatedExecs, (StgWord)exec)) == NULL) {
RELEASE_SM_LOCK;
barf("exec_to_writable: not found");
}
diff --git a/rts/adjustor/NativeAmd64.c b/rts/adjustor/NativeAmd64.c
index 045d984b2d..e58a7b79b0 100644
--- a/rts/adjustor/NativeAmd64.c
+++ b/rts/adjustor/NativeAmd64.c
@@ -43,6 +43,8 @@ static void GNUC3_ATTRIBUTE(used) obscure_ccall_wrapper(void)
extern void obscure_ccall_ret_code(void);
+void initAdjustors() { }
+
void*
createAdjustor(int cconv, StgStablePtr hptr,
StgFunPtr wptr,
diff --git a/rts/adjustor/NativeAmd64Mingw.c b/rts/adjustor/NativeAmd64Mingw.c
index 555d539c63..d9c831c36d 100644
--- a/rts/adjustor/NativeAmd64Mingw.c
+++ b/rts/adjustor/NativeAmd64Mingw.c
@@ -47,6 +47,8 @@ static void GNUC3_ATTRIBUTE(used) obscure_ccall_wrapper(void)
extern void obscure_ccall_ret_code(void);
+void initAdjustors() { }
+
void*
createAdjustor(int cconv, StgStablePtr hptr,
StgFunPtr wptr,
diff --git a/rts/adjustor/NativeIA64.c b/rts/adjustor/NativeIA64.c
index 229b1322d6..f955624945 100644
--- a/rts/adjustor/NativeIA64.c
+++ b/rts/adjustor/NativeIA64.c
@@ -35,6 +35,8 @@ stgAllocStable(size_t size_in_bytes, StgStablePtr *stable)
return(&(arr->payload));
}
+void initAdjustors() { }
+
void*
createAdjustor(int cconv, StgStablePtr hptr,
StgFunPtr wptr,
diff --git a/rts/adjustor/NativePowerPC.c b/rts/adjustor/NativePowerPC.c
index c5c4f6374b..5abb27533a 100644
--- a/rts/adjustor/NativePowerPC.c
+++ b/rts/adjustor/NativePowerPC.c
@@ -53,6 +53,8 @@ typedef struct AdjustorStub {
#endif /* !(defined(powerpc_HOST_ARCH) && defined(linux_HOST_OS)) */
#endif /* defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) */
+void initAdjustors() { }
+
void*
createAdjustor(int cconv, StgStablePtr hptr,
StgFunPtr wptr,
diff --git a/rts/adjustor/Nativei386.c b/rts/adjustor/Nativei386.c
index c613d361b3..55ad1bf310 100644
--- a/rts/adjustor/Nativei386.c
+++ b/rts/adjustor/Nativei386.c
@@ -28,6 +28,8 @@ typedef struct AdjustorStub {
StgInt argument_size;
} AdjustorStub;
+void initAdjustors() { }
+
void*
createAdjustor(int cconv, StgStablePtr hptr,
StgFunPtr wptr,