summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@mit.edu>2013-08-26 15:23:15 -0700
committerEdward Z. Yang <ezyang@cs.stanford.edu>2014-10-01 22:26:39 -0700
commit35672072b4091d6f0031417bc160c568f22d0469 (patch)
tree243925bae6f8869cca1df8595c17c0467b9d5998 /includes
parent178eb9060f369b216f3f401196e28eab4af5624d (diff)
downloadhaskell-35672072b4091d6f0031417bc160c568f22d0469.tar.gz
Rename _closure to _static_closure, apply naming consistently.
Summary: In preparation for indirecting all references to closures, we rename _closure to _static_closure to ensure any old code will get an undefined symbol error. In order to reference a closure foobar_closure (which is now undefined), you should instead use STATIC_CLOSURE(foobar). For convenience, a number of these old identifiers are macro'd. Across C-- and C (Windows and otherwise), there were differing conventions on whether or not foobar_closure or &foobar_closure was the address of the closure. Now, all foobar_closure references are addresses, and no & is necessary. CHARLIKE/INTLIKE were not changed, simply alpha-renamed. Part of remove HEAP_ALLOCED patch set (#8199) Depends on D265 Signed-off-by: Edward Z. Yang <ezyang@mit.edu> Test Plan: validate Reviewers: simonmar, austin Subscribers: simonmar, ezyang, carter, thomie Differential Revision: https://phabricator.haskell.org/D267 GHC Trac Issues: #8199
Diffstat (limited to 'includes')
-rw-r--r--includes/Cmm.h1
-rw-r--r--includes/Rts.h1
-rw-r--r--includes/RtsAPI.h12
-rw-r--r--includes/rts/StaticClosures.h34
-rw-r--r--includes/rts/storage/ClosureMacros.h5
-rw-r--r--includes/rts/storage/TSO.h2
-rw-r--r--includes/stg/MiscClosures.h30
7 files changed, 61 insertions, 24 deletions
diff --git a/includes/Cmm.h b/includes/Cmm.h
index 802ab51a5a..1a6ea78ebc 100644
--- a/includes/Cmm.h
+++ b/includes/Cmm.h
@@ -323,6 +323,7 @@
-------------------------------------------------------------------------- */
#include "rts/Constants.h"
+#include "rts/StaticClosures.h"
#include "DerivedConstants.h"
#include "rts/storage/ClosureTypes.h"
#include "rts/storage/FunTypes.h"
diff --git a/includes/Rts.h b/includes/Rts.h
index 6bf7650f69..5348e73382 100644
--- a/includes/Rts.h
+++ b/includes/Rts.h
@@ -193,6 +193,7 @@ INLINE_HEADER Time fsecondsToTime (double t)
/* Global constaints */
#include "rts/Constants.h"
+#include "rts/StaticClosures.h"
/* Profiling information */
#include "rts/prof/CCS.h"
diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h
index 0ba16714e9..fc7eb26d37 100644
--- a/includes/RtsAPI.h
+++ b/includes/RtsAPI.h
@@ -249,15 +249,15 @@ void rts_done (void);
// the base package itself.
//
#if defined(COMPILING_WINDOWS_DLL) && !defined(COMPILING_BASE_PACKAGE)
-__declspec(dllimport) extern StgWord base_GHCziTopHandler_runIO_closure[];
-__declspec(dllimport) extern StgWord base_GHCziTopHandler_runNonIO_closure[];
+__declspec(dllimport) extern StgWord base_GHCziTopHandler_runIO_static_closure[];
+__declspec(dllimport) extern StgWord base_GHCziTopHandler_runNonIO_static_closure[];
#else
-extern StgWord base_GHCziTopHandler_runIO_closure[];
-extern StgWord base_GHCziTopHandler_runNonIO_closure[];
+extern StgWord base_GHCziTopHandler_runIO_static_closure[];
+extern StgWord base_GHCziTopHandler_runNonIO_static_closure[];
#endif
-#define runIO_closure base_GHCziTopHandler_runIO_closure
-#define runNonIO_closure base_GHCziTopHandler_runNonIO_closure
+#define runIO_closure STATIC_CLOSURE(base_GHCziTopHandler_runIO)
+#define runNonIO_closure STATIC_CLOSURE(base_GHCziTopHandler_runNonIO)
/* ------------------------------------------------------------------------ */
diff --git a/includes/rts/StaticClosures.h b/includes/rts/StaticClosures.h
new file mode 100644
index 0000000000..e6a00acaa9
--- /dev/null
+++ b/includes/rts/StaticClosures.h
@@ -0,0 +1,34 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team, 1998-2009
+ *
+ * _closure macros for static closures, which will properly handle
+ * indirection.
+ *
+ * NB: THIS FILE IS INCLUDED IN NON-C CODE AND DATA! #defines only please.
+ *
+ * To understand the structure of the RTS headers, see the wiki:
+ * http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
+ *
+ * ---------------------------------------------------------------------------*/
+
+#ifndef RTS_STATIC_CLOSURES_H
+#define RTS_STATIC_CLOSURES_H
+
+#if CMINUSMINUS
+#define STATIC_CLOSURE(clos) clos ## _static_closure
+#else
+#define STATIC_CLOSURE(clos) (StgClosure*)(&(clos ## _static_closure))
+#endif
+
+#define stg_END_TSO_QUEUE_closure STATIC_CLOSURE(stg_END_TSO_QUEUE)
+#define stg_STM_AWOKEN_closure STATIC_CLOSURE(stg_STM_AWOKEN)
+#define stg_NO_FINALIZER_closure STATIC_CLOSURE(stg_NO_FINALIZER)
+#define stg_dummy_ret_closure STATIC_CLOSURE(stg_dummy_ret)
+#define stg_forceIO_closure STATIC_CLOSURE(stg_forceIO)
+#define stg_END_STM_WATCH_QUEUE_closure STATIC_CLOSURE(stg_END_STM_WATCH_QUEUE)
+#define stg_END_INVARIANT_CHECK_QUEUE_closure STATIC_CLOSURE(stg_END_INVARIANT_CHECK_QUEUE)
+#define stg_END_STM_CHUNK_LIST_closure STATIC_CLOSURE(stg_END_STM_CHUNK_LIST)
+#define stg_NO_TREC_closure STATIC_CLOSURE(stg_NO_TREC)
+
+#endif /* RTS_STATIC_CLOSURES_H */
diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h
index 64e549a641..ea7905c46f 100644
--- a/includes/rts/storage/ClosureMacros.h
+++ b/includes/rts/storage/ClosureMacros.h
@@ -187,11 +187,12 @@ INLINE_HEADER StgClosure *STATIC_LINK2(const StgInfoTable *info,
INTLIKE and CHARLIKE closures.
-------------------------------------------------------------------------- */
+// XXX update me for indirection
INLINE_HEADER P_ CHARLIKE_CLOSURE(int n) {
- return (P_)&stg_CHARLIKE_closure[(n)-MIN_CHARLIKE];
+ return (P_)&stg_CHARLIKE_static_closure[(n)-MIN_CHARLIKE];
}
INLINE_HEADER P_ INTLIKE_CLOSURE(int n) {
- return (P_)&stg_INTLIKE_closure[(n)-MIN_INTLIKE];
+ return (P_)&stg_INTLIKE_static_closure[(n)-MIN_INTLIKE];
}
/* ----------------------------------------------------------------------------
diff --git a/includes/rts/storage/TSO.h b/includes/rts/storage/TSO.h
index 6dbcec2595..ad8dae61c0 100644
--- a/includes/rts/storage/TSO.h
+++ b/includes/rts/storage/TSO.h
@@ -252,6 +252,6 @@ void dirty_STACK (Capability *cap, StgStack *stack);
---------------------------------------------------------------------------- */
/* this is the NIL ptr for a TSO queue (e.g. runnable queue) */
-#define END_TSO_QUEUE ((StgTSO *)(void*)&stg_END_TSO_QUEUE_closure)
+#define END_TSO_QUEUE ((StgTSO *)stg_END_TSO_QUEUE_closure)
#endif /* RTS_STORAGE_TSO_H */
diff --git a/includes/stg/MiscClosures.h b/includes/stg/MiscClosures.h
index 6fd7181426..9b4949fbd6 100644
--- a/includes/stg/MiscClosures.h
+++ b/includes/stg/MiscClosures.h
@@ -25,14 +25,14 @@
# define RTS_FUN_INFO(i) extern W_(i)[]
# define RTS_THUNK_INFO(i) extern W_(i)[]
# define RTS_INFO(i) extern W_(i)[]
-# define RTS_CLOSURE(i) extern W_(i)[]
+# define RTS_CLOSURE(i) extern W_(i ## _static_closure)[]
# define RTS_FUN_DECL(f) extern DLL_IMPORT_RTS StgFunPtr f(void)
#else
# define RTS_RET_INFO(i) extern DLL_IMPORT_RTS const StgRetInfoTable i
# define RTS_FUN_INFO(i) extern DLL_IMPORT_RTS const StgFunInfoTable i
# define RTS_THUNK_INFO(i) extern DLL_IMPORT_RTS const StgThunkInfoTable i
# define RTS_INFO(i) extern DLL_IMPORT_RTS const StgInfoTable i
-# define RTS_CLOSURE(i) extern DLL_IMPORT_RTS StgClosure i
+# define RTS_CLOSURE(i) extern DLL_IMPORT_RTS StgClosure i ## _static_closure
# define RTS_FUN_DECL(f) extern DLL_IMPORT_RTS StgFunPtr f(void)
#endif
@@ -148,25 +148,25 @@ RTS_ENTRY(stg_NO_TREC);
/* closures */
-RTS_CLOSURE(stg_END_TSO_QUEUE_closure);
-RTS_CLOSURE(stg_STM_AWOKEN_closure);
-RTS_CLOSURE(stg_NO_FINALIZER_closure);
-RTS_CLOSURE(stg_dummy_ret_closure);
-RTS_CLOSURE(stg_forceIO_closure);
+RTS_CLOSURE(stg_END_TSO_QUEUE);
+RTS_CLOSURE(stg_STM_AWOKEN);
+RTS_CLOSURE(stg_NO_FINALIZER);
+RTS_CLOSURE(stg_dummy_ret);
+RTS_CLOSURE(stg_forceIO);
-RTS_CLOSURE(stg_END_STM_WATCH_QUEUE_closure);
-RTS_CLOSURE(stg_END_INVARIANT_CHECK_QUEUE_closure);
-RTS_CLOSURE(stg_END_STM_CHUNK_LIST_closure);
-RTS_CLOSURE(stg_NO_TREC_closure);
+RTS_CLOSURE(stg_END_STM_WATCH_QUEUE);
+RTS_CLOSURE(stg_END_INVARIANT_CHECK_QUEUE);
+RTS_CLOSURE(stg_END_STM_CHUNK_LIST);
+RTS_CLOSURE(stg_NO_TREC);
RTS_ENTRY(stg_NO_FINALIZER_entry);
#if IN_STG_CODE
-extern DLL_IMPORT_RTS StgWordArray stg_CHARLIKE_closure;
-extern DLL_IMPORT_RTS StgWordArray stg_INTLIKE_closure;
+extern DLL_IMPORT_RTS StgWordArray stg_CHARLIKE_static_closure;
+extern DLL_IMPORT_RTS StgWordArray stg_INTLIKE_static_closure;
#else
-extern DLL_IMPORT_RTS StgIntCharlikeClosure stg_CHARLIKE_closure[];
-extern DLL_IMPORT_RTS StgIntCharlikeClosure stg_INTLIKE_closure[];
+extern DLL_IMPORT_RTS StgIntCharlikeClosure stg_CHARLIKE_static_closure[];
+extern DLL_IMPORT_RTS StgIntCharlikeClosure stg_INTLIKE_static_closure[];
#endif
/* StgStartup */