summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2017-04-24 09:41:35 -0400
committerBen Gamari <ben@smart-cactus.org>2017-04-24 12:53:43 -0400
commitb68697e579d38ca29c2b84377dc2affa04659a28 (patch)
tree3d7a9f8c888baad175c81863d5519fb42e817770 /includes
parentd5cb4d2b7fab89ea1c3fc74da2317f86e75816ea (diff)
downloadhaskell-b68697e579d38ca29c2b84377dc2affa04659a28.tar.gz
compiler/cmm/PprC.hs: constify labels in .rodata
Consider one-line module module B (v) where v = "hello" in -fvia-C mode it generates code like static char gibberish_str[] = "hello"; It resides in data section (precious resource on ia64!). The patch switches genrator to emit: static const char gibberish_str[] = "hello"; Other types if symbols that gained 'const' qualifier are: - info tables (from haskell and CMM) - static reference tables (from haskell and CMM) Cleanups along the way: - fixed info tables defined in .cmm to reside in .rodata - split out closure declaration into 'IC_' / 'EC_' - added label declaration (based on label type) right before each label definition (based on section type) so that C compiler could check if declaration and definition matches at definition site. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: ran testsuite on unregisterised x86_64 compiler Reviewers: simonmar, ezyang, austin, bgamari, erikd Reviewed By: bgamari, erikd Subscribers: rwbarton, thomie GHC Trac Issues: #8996 Differential Revision: https://phabricator.haskell.org/D3481
Diffstat (limited to 'includes')
-rw-r--r--includes/Stg.h22
-rw-r--r--includes/rts/storage/InfoTables.h2
-rw-r--r--includes/stg/MiscClosures.h14
3 files changed, 24 insertions, 14 deletions
diff --git a/includes/Stg.h b/includes/Stg.h
index ff5e3174c0..063959d880 100644
--- a/includes/Stg.h
+++ b/includes/Stg.h
@@ -222,13 +222,23 @@ typedef StgInt I_;
typedef StgWord StgWordArray[];
typedef StgFunPtr F_;
-#define EB_(X) extern char X[]
-#define IB_(X) static char X[]
-#define EI_(X) extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
-#define II_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
+/* byte arrays (and strings): */
+#define EB_(X) extern const char X[]
+#define IB_(X) static const char X[]
+/* static (non-heap) closures (requires alignment for pointer tagging): */
+#define EC_(X) extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
+#define IC_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
+/* writable data (does not require alignment): */
+#define ERW_(X) extern StgWordArray (X)
+#define IRW_(X) static StgWordArray (X)
+/* read-only data (does not require alignment): */
+#define ERO_(X) extern const StgWordArray (X)
+#define IRO_(X) static const StgWordArray (X)
+/* stg-native functions: */
#define IF_(f) static StgFunPtr GNUC3_ATTRIBUTE(used) f(void)
-#define FN_(f) StgFunPtr f(void)
-#define EF_(f) StgFunPtr f(void) /* External Cmm functions */
+#define FN_(f) StgFunPtr f(void)
+#define EF_(f) StgFunPtr f(void) /* External Cmm functions */
+/* foreign functions: */
#define EFF_(f) void f() /* See Note [External function prototypes] */
/* Note [External function prototypes] See Trac #8965, #11395
diff --git a/includes/rts/storage/InfoTables.h b/includes/rts/storage/InfoTables.h
index e732a30daf..3201c105e1 100644
--- a/includes/rts/storage/InfoTables.h
+++ b/includes/rts/storage/InfoTables.h
@@ -265,7 +265,7 @@ typedef struct {
} StgFunInfoTable;
// canned bitmap for each arg type, indexed by constants in FunTypes.h
-extern StgWord stg_arg_bitmaps[];
+extern const StgWord stg_arg_bitmaps[];
/* -----------------------------------------------------------------------------
Return info tables
diff --git a/includes/stg/MiscClosures.h b/includes/stg/MiscClosures.h
index 1181abcca4..725323b395 100644
--- a/includes/stg/MiscClosures.h
+++ b/includes/stg/MiscClosures.h
@@ -20,10 +20,10 @@
#pragma once
#if IN_STG_CODE
-# define RTS_RET_INFO(i) extern W_(i)[]
-# 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_RET_INFO(i) extern const W_(i)[]
+# define RTS_FUN_INFO(i) extern const W_(i)[]
+# define RTS_THUNK_INFO(i) extern const W_(i)[]
+# define RTS_INFO(i) extern const W_(i)[]
# define RTS_CLOSURE(i) extern W_(i)[]
# define RTS_FUN_DECL(f) extern DLL_IMPORT_RTS StgFunPtr f(void)
#else
@@ -488,9 +488,9 @@ extern StgWord RTS_VAR(sched_mutex);
// Apply.cmm
// canned bitmap for each arg type
-extern StgWord stg_arg_bitmaps[];
-extern StgWord stg_ap_stack_entries[];
-extern StgWord stg_stack_save_entries[];
+extern const StgWord stg_arg_bitmaps[];
+extern const StgWord stg_ap_stack_entries[];
+extern const StgWord stg_stack_save_entries[];
// Storage.c
extern unsigned int RTS_VAR(g0);