aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorRichard Brooksby2012-09-01 00:01:03 +0100
committerRichard Brooksby2012-09-01 00:01:03 +0100
commit82bc1374643e8e357a984fefa550650c99f222fd (patch)
treea19d4c2a40603aa02ebac78cf6a8abc4c38da296 /mps/code
parentd554406726c4bff45658e9e02cb34c5acfea7cea (diff)
downloademacs-82bc1374643e8e357a984fefa550650c99f222fd.tar.gz
emacs-82bc1374643e8e357a984fefa550650c99f222fd.zip
Abolishing a bunch of varieties and reforming the hot variety to run about as fast as white-hot.
See <http://info.ravenbrook.com/mail/2012/08/15/17-43-37/0/>. Copied from Perforce Change: 179153 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/check.h72
-rw-r--r--mps/code/comm.gmk33
-rw-r--r--mps/code/config.h77
-rw-r--r--mps/code/gc.gmk5
-rw-r--r--mps/code/gp.gmk1
5 files changed, 103 insertions, 85 deletions
diff --git a/mps/code/check.h b/mps/code/check.h
index e58a9d04ced..26ce0ea965e 100644
--- a/mps/code/check.h
+++ b/mps/code/check.h
@@ -56,19 +56,32 @@ enum {
56#elif defined(AVER_AND_CHECK) 56#elif defined(AVER_AND_CHECK)
57 57
58#define AVER(cond) ASSERT(cond, #cond) 58#define AVER(cond) ASSERT(cond, #cond)
59#define AVERT(type, val) ASSERT(type ## Check(val), \ 59
60 "TypeCheck " #type ": " #val) 60#define AVERT(type, val) \
61 ASSERT(type ## Check(val), "TypeCheck " #type ": " #val)
62
63#if !defined(AVER_AND_CHECK_ALL)
64
65#define AVER_CRITICAL DISCARD
66#define AVERT_CRITICAL(type, val) DISCARD(type ## Check(val))
67
68#else /* AVER_AND_CHECK_ALL */
69
61#define AVER_CRITICAL(cond) \ 70#define AVER_CRITICAL(cond) \
62 BEGIN \ 71 BEGIN \
63 if (CheckLevel != CheckLevelMINIMAL) ASSERT(cond, #cond); \ 72 if (CheckLevel != CheckLevelMINIMAL) \
73 ASSERT(cond, #cond); \
64 END 74 END
75
65#define AVERT_CRITICAL(type, val) \ 76#define AVERT_CRITICAL(type, val) \
66 BEGIN \ 77 BEGIN \
67 if (CheckLevel != CheckLevelMINIMAL) \ 78 if (CheckLevel != CheckLevelMINIMAL) \
68 ASSERT(type ## Check(val), "TypeCheck " #type ": " #val); \ 79 ASSERT(type ## Check(val), "TypeCheck " #type ": " #val); \
69 END 80 END
70 81
71#else 82#endif /* AVER_AND_CHECK_ALL */
83
84#else /* AVER_AND_CHECK, not */
72 85
73#error "No checking defined." 86#error "No checking defined."
74 87
@@ -115,24 +128,34 @@ enum {
115 128
116#if defined(AVER_AND_CHECK_NONE) 129#if defined(AVER_AND_CHECK_NONE)
117 130
118 131#define CHECKS(type, val) DISCARD(CHECKT(type, val))
119#define CHECKS(type, val) DISCARD(CHECKT(type, val)) 132#define CHECKL(cond) DISCARD(cond)
120#define CHECKL(cond) DISCARD(cond) 133#define CHECKD(type, val) DISCARD(CHECKT(type, val))
121#define CHECKD(type, val) DISCARD(CHECKT(type, val))
122#define CHECKD_NOSIG(type, val) DISCARD((val) != NULL) 134#define CHECKD_NOSIG(type, val) DISCARD((val) != NULL)
123#define CHECKU(type, val) DISCARD(CHECKT(type, val)) 135#define CHECKU(type, val) DISCARD(CHECKT(type, val))
124#define CHECKU_NOSIG(type, val) DISCARD((val) != NULL) 136#define CHECKU_NOSIG(type, val) DISCARD((val) != NULL)
125 137
126 138#else /* AVER_AND_CHECK_NONE, not */
127#else
128
129 139
130/* CHECKS -- Check Signature */ 140/* CHECKS -- Check Signature */
131/* (if CheckLevel == CheckLevelMINIMAL, this is all we check) */ 141/* (if CheckLevel == CheckLevelMINIMAL, this is all we check) */
132 142
133#define CHECKS(type, val) ASSERT(CHECKT(type, val), \ 143#define CHECKS(type, val) \
134 "SigCheck " #type ": " #val) 144 ASSERT(CHECKT(type, val), "SigCheck " #type ": " #val)
135 145
146#if !defined(AVER_AND_CHECK_ALL)
147
148/* FIXME: This gives comparable performance to white-hot when compiling
149 using mps.c and -O (to get check methods inlined), but is it a bit
150 too minimal? How much do we rely on check methods? */
151
152#define CHECKL(cond) DISCARD(cond)
153#define CHECKD(type, val) DISCARD(CHECKT(type, val))
154#define CHECKD_NOSIG(type, val) DISCARD((val) != NULL)
155#define CHECKU(type, val) DISCARD(CHECKT(type, val))
156#define CHECKU_NOSIG(type, val) DISCARD((val) != NULL)
157
158#else /* AVER_AND_CHECK_ALL */
136 159
137/* CHECKL -- Check Local Invariant 160/* CHECKL -- Check Local Invariant
138 * 161 *
@@ -162,12 +185,10 @@ enum {
162 NOOP; \ 185 NOOP; \
163 break; \ 186 break; \
164 case CheckLevelSHALLOW: \ 187 case CheckLevelSHALLOW: \
165 ASSERT(CHECKT(type, val), \ 188 CHECKS(type, val); \
166 "SigCheck " #type ": " #val); \
167 break; \ 189 break; \
168 case CheckLevelDEEP: \ 190 case CheckLevelDEEP: \
169 ASSERT(type ## Check(val), \ 191 ASSERT(type ## Check(val), "TypeCheck " #type ": " #val); \
170 "TypeCheck " #type ": " #val); \
171 break; \ 192 break; \
172 } \ 193 } \
173 END 194 END
@@ -182,12 +203,10 @@ enum {
182 NOOP; \ 203 NOOP; \
183 break; \ 204 break; \
184 case CheckLevelSHALLOW: \ 205 case CheckLevelSHALLOW: \
185 ASSERT((val) != NULL, \ 206 ASSERT((val) != NULL, "NullCheck " #type ": " #val); \
186 "NullCheck " #type ": " #val); \
187 break; \ 207 break; \
188 case CheckLevelDEEP: \ 208 case CheckLevelDEEP: \
189 ASSERT(type ## Check(val), \ 209 ASSERT(type ## Check(val), "TypeCheck " #type ": " #val); \
190 "TypeCheck " #type ": " #val); \
191 break; \ 210 break; \
192 } \ 211 } \
193 END 212 END
@@ -203,8 +222,7 @@ enum {
203 break; \ 222 break; \
204 case CheckLevelSHALLOW: \ 223 case CheckLevelSHALLOW: \
205 case CheckLevelDEEP: \ 224 case CheckLevelDEEP: \
206 ASSERT(CHECKT(type, val), \ 225 CHECKS(type, val); \
207 "SigCheck " #type ": " #val); \
208 break; \ 226 break; \
209 } \ 227 } \
210 END 228 END
@@ -220,14 +238,14 @@ enum {
220 break; \ 238 break; \
221 case CheckLevelSHALLOW: \ 239 case CheckLevelSHALLOW: \
222 case CheckLevelDEEP: \ 240 case CheckLevelDEEP: \
223 ASSERT((val) != NULL, \ 241 ASSERT((val) != NULL, "NullCheck " #type ": " #val); \
224 "NullCheck " #type ": " #val); \
225 break; \ 242 break; \
226 } \ 243 } \
227 END 244 END
228 245
246#endif /* AVER_AND_CHECK_ALL */
229 247
230#endif 248#endif /* AVER_AND_CHECK_NONE */
231 249
232 250
233/* CHECKLVALUE &c -- type compatibility checking 251/* CHECKLVALUE &c -- type compatibility checking
diff --git a/mps/code/comm.gmk b/mps/code/comm.gmk
index 9141c34c9cd..1726e451543 100644
--- a/mps/code/comm.gmk
+++ b/mps/code/comm.gmk
@@ -16,8 +16,6 @@
16# information, and any optimization possible 16# information, and any optimization possible
17# CFLAGSOPT a list of flags for compilations with maximum 17# CFLAGSOPT a list of flags for compilations with maximum
18# optimization, and any debug info possible 18# optimization, and any debug info possible
19# CFLAGSOPTNODEBUG a list of flags for compilations with maximum
20# optimization, and absolutely no debug info
21# CC the command for the C compiler 19# CC the command for the C compiler
22# LINKFLAGS a list of flags passed to the linker 20# LINKFLAGS a list of flags passed to the linker
23# ARFLAGSPFM platform-specific flags for ar 21# ARFLAGSPFM platform-specific flags for ar
@@ -64,9 +62,6 @@ endif
64ifndef CFLAGSOPT 62ifndef CFLAGSOPT
65error "comm.gmk: CFLAGSOPT not defined" 63error "comm.gmk: CFLAGSOPT not defined"
66endif 64endif
67ifndef CFLAGSOPTNODEBUG
68error "comm.gmk: CFLAGSOPTNODEBUG not defined"
69endif
70 65
71# 66#
72# %%PART: Add checks for the parameter with the sources for the new 67# %%PART: Add checks for the parameter with the sources for the new
@@ -122,13 +117,9 @@ CFLAGSCOMMON = $(PFMDEFS) $(CFLAGSTARGET) $(CFLAGSCOMPILER)
122# variety. 117# variety.
123 118
124# These flags are added to compilations for the indicated variety. 119# These flags are added to compilations for the indicated variety.
125CFWE = -DCONFIG_VAR_WE -DNDEBUG $(CFLAGSOPTNODEBUG) 120CFWE = -DCONFIG_VAR_WE -DNDEBUG $(CFLAGSOPT)
126CFWI = -DCONFIG_VAR_WI -DNDEBUG $(CFLAGSOPT) 121CFHE = -DCONFIG_VAR_HE -DNDEBUG $(CFLAGSOPT)
127CFHE = -DCONFIG_VAR_HE -DNDEBUG $(CFLAGSOPTNODEBUG)
128CFHI = -DCONFIG_VAR_HI -DNDEBUG $(CFLAGSOPT)
129CFDI = -DCONFIG_VAR_DI -DNDEBUG $(CFLAGSOPT) 122CFDI = -DCONFIG_VAR_DI -DNDEBUG $(CFLAGSOPT)
130CFII = -DCONFIG_VAR_II -DNDEBUG $(CFLAGSOPT)
131CFCE = -DCONFIG_VAR_CE $(CFLAGSOPTNODEBUG)
132CFCI = -DCONFIG_VAR_CI $(CFLAGSDEBUG) 123CFCI = -DCONFIG_VAR_CI $(CFLAGSDEBUG)
133CFTI = -DCONFIG_VAR_TI $(CFLAGSDEBUG) 124CFTI = -DCONFIG_VAR_TI $(CFLAGSDEBUG)
134 125
@@ -137,24 +128,12 @@ CFTI = -DCONFIG_VAR_TI $(CFLAGSDEBUG)
137ifeq ($(VARIETY),we) 128ifeq ($(VARIETY),we)
138CFLAGS=$(CFLAGSCOMMON) $(CFWE) 129CFLAGS=$(CFLAGSCOMMON) $(CFWE)
139else 130else
140ifeq ($(VARIETY),wi)
141CFLAGS=$(CFLAGSCOMMON) $(CFWI)
142else
143ifeq ($(VARIETY),he) 131ifeq ($(VARIETY),he)
144CFLAGS=$(CFLAGSCOMMON) $(CFHE) 132CFLAGS=$(CFLAGSCOMMON) $(CFHE)
145else 133else
146ifeq ($(VARIETY),hi)
147CFLAGS=$(CFLAGSCOMMON) $(CFHI)
148else
149ifeq ($(VARIETY),di) 134ifeq ($(VARIETY),di)
150CFLAGS=$(CFLAGSCOMMON) $(CFDI) 135CFLAGS=$(CFLAGSCOMMON) $(CFDI)
151else 136else
152ifeq ($(VARIETY),ii)
153CFLAGS=$(CFLAGSCOMMON) $(CFII)
154else
155ifeq ($(VARIETY),ce)
156CFLAGS=$(CFLAGSCOMMON) $(CFCE)
157else
158ifeq ($(VARIETY),ci) 137ifeq ($(VARIETY),ci)
159CFLAGS=$(CFLAGSCOMMON) $(CFCI) 138CFLAGS=$(CFLAGSCOMMON) $(CFCI)
160else 139else
@@ -166,10 +145,6 @@ endif
166endif 145endif
167endif 146endif
168endif 147endif
169endif
170endif
171endif
172endif
173 148
174 149
175ARFLAGS=rc$(ARFLAGSPFM) 150ARFLAGS=rc$(ARFLAGSPFM)
@@ -328,10 +303,8 @@ clean: phony
328ifdef TARGET 303ifdef TARGET
329ifndef VARIETY 304ifndef VARIETY
330target: phony 305target: phony
331 $(MAKE) -f $(PFM).gmk VARIETY=hi variety 306 $(MAKE) -f $(PFM).gmk VARIETY=he variety
332 $(MAKE) -f $(PFM).gmk VARIETY=ci variety 307 $(MAKE) -f $(PFM).gmk VARIETY=ci variety
333 $(MAKE) -f $(PFM).gmk VARIETY=di variety
334 $(MAKE) -f $(PFM).gmk VARIETY=we variety
335endif 308endif
336endif 309endif
337 310
diff --git a/mps/code/config.h b/mps/code/config.h
index 29abad920f7..86b3a22b610 100644
--- a/mps/code/config.h
+++ b/mps/code/config.h
@@ -21,36 +21,46 @@
21 21
22/* Variety Configuration */ 22/* Variety Configuration */
23 23
24/* First translate GG build directives into better ones. 24/* Then deal with CONFIG_VAR_* build directives. These are translated into
25 */ 25 the directives CONFIG_ASSERT, CONFIG_STATS, CONFIG_LOG, etc. which control
26 26 actual compilation features. */
27#ifdef CONFIG_DEBUG
28/* Translate CONFIG_DEBUG to CONFIG_STATS, because that's what it */
29/* means. It's got nothing to do with debugging! RHSK 2007-06-29 */
30#define CONFIG_STATS
31#endif
32 27
33 28/* CONFIG_VAR_WE -- the white-hot variety
34/* Then deal with old-style CONFIG_VAR_* build directives. These
35 * must be translated into the new directives CONFIG_ASSERT,
36 * CONFIG_STATS, and CONFIG_LOG.
37 * 29 *
38 * One day the old build system may be converted to use the new 30 * This variety switches off as many features as possible for maximum
39 * directives. 31 * performance, but is therefore unsafe and undebuggable. It is not intended
32 * for use, but for comparison with the hot variety, to check that assertion,
33 * logging, etc. have negligible overhead.
40 */ 34 */
41 35
42#if defined(CONFIG_VAR_WI) || defined(CONFIG_VAR_WE) /* White-hot varieties */ 36#if defined(CONFIG_VAR_WE) /* White-hot variety */
43/* no asserts */ 37/* no asserts */
44/* ... so CHECKLEVEL_INITIAL is irrelevant */ 38/* ... so CHECKLEVEL_INITIAL is irrelevant */
45/* no statistic meters */ 39/* no statistic meters */
46/* no telemetry log events */ 40/* no telemetry log events */
47 41
48#elif defined(CONFIG_VAR_HI) || defined(CONFIG_VAR_HE) /* Hot varieties */ 42
43/* CONFIG_VAR_HE -- the hot variety
44 *
45 * This variety is the default variety for distribution in products that use
46 * the MPS. It has maximum performance while retaining a good level of
47 * consistency checking and allowing some debugging and telemetry features.
48 */
49
50#elif defined(CONFIG_VAR_HE) /* Hot variety */
49#define CONFIG_ASSERT 51#define CONFIG_ASSERT
50#define CHECKLEVEL_INITIAL CheckLevelMINIMAL 52#define CHECKLEVEL_INITIAL CheckLevelMINIMAL
51/* no statistic meters */ 53/* no statistic meters */
52/* no telemetry log events */ 54/* no telemetry log events */
53 55
56
57/* CONFIG_VAR_DI -- diagnostic variety
58 *
59 * Deprecated. The diagnostic variety prints messages about the internals
60 * of the MPS to an output stream. This is being replaced by an extended
61 * telemetry system. RB 2012-08-31
62 */
63
54#elif defined(CONFIG_VAR_DI) /* Diagnostic variety */ 64#elif defined(CONFIG_VAR_DI) /* Diagnostic variety */
55#define CONFIG_ASSERT 65#define CONFIG_ASSERT
56#define CHECKLEVEL_INITIAL CheckLevelMINIMAL 66#define CHECKLEVEL_INITIAL CheckLevelMINIMAL
@@ -63,24 +73,38 @@
63/* #define DIAG_WITH_PRINTF */ 73/* #define DIAG_WITH_PRINTF */
64/* no telemetry log events */ 74/* no telemetry log events */
65 75
66#elif defined(CONFIG_VAR_CI) || defined(CONFIG_VAR_CE) /* Cool varieties */ 76
77/* CONFIG_VAR_CI -- cool variety
78 *
79 * The cool variety is intended for use when developing an integration with
80 * the MPS or debugging memory problems or collecting detailed telemetry
81 * data for performance analysis. It has more thorough consistency checking
82 * and data collection and output, and full debugging information.
83 */
84
85#elif defined(CONFIG_VAR_CI) /* Cool variety */
67#define CONFIG_ASSERT 86#define CONFIG_ASSERT
87#define CONFIG_ASSERT_ALL
68/* ... let PRODUCT determine CHECKLEVEL_INITIAL */ 88/* ... let PRODUCT determine CHECKLEVEL_INITIAL */
69#define CONFIG_STATS 89#define CONFIG_STATS
70/* no telemetry log events */ 90/* no telemetry log events */
71 91
92
93/* CONFIG_VAR_TI -- telemetry variety
94 *
95 * Deprecated. This is the variety with event logging to a telemetry stream.
96 * Currently being reworked to retain event logging with negligible overhead
97 * on all other varieties. RB 2012-08-31
98 */
99
72#elif defined(CONFIG_VAR_TI) /* Telemetry, Internal; variety.ti */ 100#elif defined(CONFIG_VAR_TI) /* Telemetry, Internal; variety.ti */
73#define CONFIG_ASSERT 101#define CONFIG_ASSERT
102#define CONFIG_ASSERT_ALL
74/* ... let PRODUCT determine CHECKLEVEL_INITIAL */ 103/* ... let PRODUCT determine CHECKLEVEL_INITIAL */
75#define CONFIG_STATS 104#define CONFIG_STATS
76#define CONFIG_LOG 105#define CONFIG_LOG
77 106
78#elif defined(CONFIG_VAR_II) /* Ice, Internal; variety.ii (HotLog) */ 107#endif /* CONFIG_VAR_* */
79#define CONFIG_ASSERT
80#define CHECKLEVEL_INITIAL CheckLevelMINIMAL
81/* no statistic meters */
82#define CONFIG_LOG
83#endif
84 108
85 109
86/* Build Features */ 110/* Build Features */
@@ -90,8 +114,13 @@
90/* asserts: AVER, AVERT, NOTREACHED, CHECKx */ 114/* asserts: AVER, AVERT, NOTREACHED, CHECKx */
91/* note: a direct call to ASSERT() will *still* fire */ 115/* note: a direct call to ASSERT() will *still* fire */
92#define AVER_AND_CHECK 116#define AVER_AND_CHECK
117#if defined(CONFIG_ASSERT_ALL)
118#define AVER_AND_CHECK_ALL
119#define MPS_ASSERT_STRING "assertastic"
120#else /* CONFIG_ASSERT_ALL, not */
93#define MPS_ASSERT_STRING "asserted" 121#define MPS_ASSERT_STRING "asserted"
94#else 122#endif /* CONFIG_ASSERT_ALL */
123#else /* CONFIG_ASSERT, not */
95#define AVER_AND_CHECK_NONE 124#define AVER_AND_CHECK_NONE
96#define MPS_ASSERT_STRING "nonasserted" 125#define MPS_ASSERT_STRING "nonasserted"
97#endif 126#endif
diff --git a/mps/code/gc.gmk b/mps/code/gc.gmk
index 75b83bf8118..2aeb61cdbc1 100644
--- a/mps/code/gc.gmk
+++ b/mps/code/gc.gmk
@@ -13,9 +13,8 @@ CFLAGSCOMPILER := \
13 -Wstrict-prototypes -Wmissing-prototypes \ 13 -Wstrict-prototypes -Wmissing-prototypes \
14 -Winline -Waggregate-return -Wnested-externs \ 14 -Winline -Waggregate-return -Wnested-externs \
15 -Wcast-qual -Wshadow 15 -Wcast-qual -Wshadow
16CFLAGSDEBUG = -g -ggdb3 16CFLAGSDEBUG = -O0 -g
17CFLAGSOPT = -O -g -ggdb3 17CFLAGSOPT = -O3 -g
18CFLAGSOPTNODEBUG = -O -g0
19 18
20# gcc -MM generates a dependency line of the form: 19# gcc -MM generates a dependency line of the form:
21# thing.o : thing.c ... 20# thing.o : thing.c ...
diff --git a/mps/code/gp.gmk b/mps/code/gp.gmk
index 229064d3055..8e16b524c38 100644
--- a/mps/code/gp.gmk
+++ b/mps/code/gp.gmk
@@ -16,7 +16,6 @@ CFLAGSCOMPILER = \
16 -Wcast-qual -Wshadow -pg 16 -Wcast-qual -Wshadow -pg
17CFLAGSDEBUG = -g -ggdb3 17CFLAGSDEBUG = -g -ggdb3
18CFLAGSOPT = -O -g -ggdb3 18CFLAGSOPT = -O -g -ggdb3
19CFLAGSOPTNODEBUG = -O -g0
20 19
21# gcc -MM generates a dependency line of the form: 20# gcc -MM generates a dependency line of the form:
22# thing.o : thing.c ... 21# thing.o : thing.c ...