aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/event.c50
-rw-r--r--mps/code/event.h27
2 files changed, 38 insertions, 39 deletions
diff --git a/mps/code/event.c b/mps/code/event.c
index ca50a4ea32f..b97714f62b4 100644
--- a/mps/code/event.c
+++ b/mps/code/event.c
@@ -38,7 +38,7 @@ static Count eventUserCount;
38static Serial EventInternSerial; 38static Serial EventInternSerial;
39 39
40char *EventNext, *EventLimit; /* Used by macros in <code/event.h> */ 40char *EventNext, *EventLimit; /* Used by macros in <code/event.h> */
41Word EventKindControl; /* Bit set used to control output. */ 41EventControlSet EventKindControl; /* Bit set used to control output. */
42 42
43 43
44/* EventFlush -- flush event buffer to the event stream */ 44/* EventFlush -- flush event buffer to the event stream */
@@ -162,11 +162,14 @@ void EventFinish(void)
162 * Reset(M) EventControl(M,0) 162 * Reset(M) EventControl(M,0)
163 * Flip(M) EventControl(0,M) 163 * Flip(M) EventControl(0,M)
164 * Read() EventControl(0,0) 164 * Read() EventControl(0,0)
165 *
166 * FIXME: Candy-machine interface is a transgression.
165 */ 167 */
166 168
167Word EventControl(Word resetMask, Word flipMask) 169EventControlSet EventControl(EventControlSet resetMask,
170 EventControlSet flipMask)
168{ 171{
169 Word oldValue = EventKindControl; 172 EventControlSet oldValue = EventKindControl;
170 173
171 /* EventKindControl = (EventKindControl & ~resetMask) ^ flipMask */ 174 /* EventKindControl = (EventKindControl & ~resetMask) ^ flipMask */
172 EventKindControl = 175 EventKindControl =
@@ -178,37 +181,33 @@ Word EventControl(Word resetMask, Word flipMask)
178 181
179/* EventInternString -- emit an Intern event on the (null-term) string given */ 182/* EventInternString -- emit an Intern event on the (null-term) string given */
180 183
181Word EventInternString(const char *label) 184EventStringId EventInternString(const char *label)
182{ 185{
183 Word id;
184
185 AVER(label != NULL); 186 AVER(label != NULL);
186 187 return EventInternGenString(StringLength(label), label);
187 id = (Word)EventInternSerial;
188 ++EventInternSerial;
189 EVENT2S(Intern, id, StringLength(label), label);
190 return id;
191} 188}
192 189
193 190
194/* EventInternGenString -- emit an Intern event on the string given */ 191/* EventInternGenString -- emit an Intern event on the string given */
195 192
196Word EventInternGenString(size_t len, const char *label) 193EventStringId EventInternGenString(size_t len, const char *label)
197{ 194{
198 Word id; 195 EventStringId id;
199 196
200 AVER(label != NULL); 197 AVER(label != NULL);
201 198
202 id = (Word)EventInternSerial; 199 id = EventInternSerial;
203 ++EventInternSerial; 200 ++EventInternSerial;
201
204 EVENT2S(Intern, id, len, label); 202 EVENT2S(Intern, id, len, label);
203
205 return id; 204 return id;
206} 205}
207 206
208 207
209/* EventLabelAddr -- emit event to label address with the given id */ 208/* EventLabelAddr -- emit event to label address with the given id */
210 209
211void EventLabelAddr(Addr addr, Word id) 210void EventLabelAddr(Addr addr, EventStringId id)
212{ 211{
213 AVER((Serial)id < EventInternSerial); 212 AVER((Serial)id < EventInternSerial);
214 213
@@ -221,13 +220,13 @@ void EventLabelAddr(Addr addr, Word id)
221 220
222Res (EventSync)(void) 221Res (EventSync)(void)
223{ 222{
224 return(ResOK); 223 return ResOK;
225} 224}
226 225
227 226
228Res (EventInit)(void) 227Res (EventInit)(void)
229{ 228{
230 return(ResOK); 229 return ResOK;
231} 230}
232 231
233 232
@@ -237,28 +236,28 @@ void (EventFinish)(void)
237} 236}
238 237
239 238
240Word (EventControl)(Word resetMask, Word flipMask) 239EventControlSet (EventControl)(EventControlSet resetMask,
240 EventControlSet flipMask)
241{ 241{
242 UNUSED(resetMask); 242 UNUSED(resetMask);
243 UNUSED(flipMask); 243 UNUSED(flipMask);
244 244 return BS_EMPTY(EventControlSet);
245 return (Word)0;
246} 245}
247 246
248 247
249Word (EventInternString)(const char *label) 248EventStringId (EventInternString)(const char *label)
250{ 249{
251 UNUSED(label); 250 UNUSED(label);
252 251 NOTREACHED;
253 return (Word)0; 252 return (EventInternString)0x9024EACH;
254} 253}
255 254
256 255
257Word (EventInternGenString)(size_t len, const char *label) 256Word (EventInternGenString)(size_t len, const char *label)
258{ 257{
259 UNUSED(len); UNUSED(label); 258 UNUSED(len); UNUSED(label);
260 259 NOTREACHED;
261 return (Word)0; 260 return (EventInternString)0x9024EACH;
262} 261}
263 262
264 263
@@ -266,6 +265,7 @@ void (EventLabelAddr)(Addr addr, Word id)
266{ 265{
267 UNUSED(addr); 266 UNUSED(addr);
268 UNUSED(id); 267 UNUSED(id);
268 NOTREACHED;
269} 269}
270 270
271 271
diff --git a/mps/code/event.h b/mps/code/event.h
index 161aa32d2e5..9af0225d7fd 100644
--- a/mps/code/event.h
+++ b/mps/code/event.h
@@ -20,13 +20,17 @@
20#include "eventdef.h" 20#include "eventdef.h"
21 21
22 22
23typedef Word EventStringId;
24typedef Word EventControlSet;
25
23extern Res EventSync(void); 26extern Res EventSync(void);
24extern Res EventInit(void); 27extern Res EventInit(void);
25extern void EventFinish(void); 28extern void EventFinish(void);
26extern Word EventControl(Word, Word); 29extern EventControlSet EventControl(EventControlSet resetMask,
27extern Word EventInternString(const char *); 30 EventControlSet flipMask);
28extern Word EventInternGenString(size_t, const char *); 31extern EventStringId EventInternString(const char *label);
29extern void EventLabelAddr(Addr, Word); 32extern EventStringId EventInternGenString(size_t, const char *label);
33extern void EventLabelAddr(Addr addr, Word id);
30extern Res EventFlush(void); 34extern Res EventFlush(void);
31 35
32 36
@@ -38,10 +42,13 @@ extern char *EventNext, *EventLimit;
38extern Word EventKindControl; 42extern Word EventKindControl;
39 43
40 44
45/* TODO: Append a size at EventNext - sizeof(EventSize) so that a backtrace
46 can step backwards through the event buffer. */
47
41#define EVENT_BEGIN(name, structSize) \ 48#define EVENT_BEGIN(name, structSize) \
42 BEGIN \ 49 BEGIN \
43 if(Event##name##Always && \ 50 if(/* Event##name##Always && FIXME: depend on variety */ \
44 BS_IS_MEMBER(EventKindControl, ((Index)Event##name##Kind))) { \ 51 BS_IS_MEMBER(EventKindControl, (Index)Event##name##Kind)) { \
45 Event##name##Struct *_event; \ 52 Event##name##Struct *_event; \
46 size_t _size = size_tAlignUp(structSize, MPS_PF_ALIGN); \ 53 size_t _size = size_tAlignUp(structSize, MPS_PF_ALIGN); \
47 if (_size > (size_t)(EventLimit - EventNext)) \ 54 if (_size > (size_t)(EventLimit - EventNext)) \
@@ -103,14 +110,6 @@ extern Word EventKindControl;
103#else /* EVENT not */ 110#else /* EVENT not */
104 111
105 112
106#define EventInit() NOOP
107#define EventFinish() NOOP
108#define EventControl(r, f) (UNUSED(r), UNUSED(f), (Word)0)
109#define EventInternString(s) (UNUSED(s), (Word)0)
110#define EventInternGenString(l, s) (UNUSED(l), UNUSED(s), (Word)0)
111#define EventLabelAddr(a, i) BEGIN UNUSED(a); UNUSED(i); END
112
113
114#define EVENT0(name) NOOP 113#define EVENT0(name) NOOP
115/* The following lines were generated with 114/* The following lines were generated with
116 python -c 'for i in range(1,15): print "#define EVENT%d(name, %s) NOOP" % (i, ", ".join(["p%d" % j for j in range(0, i)]))' 115 python -c 'for i in range(1,15): print "#define EVENT%d(name, %s) NOOP" % (i, ", ".join(["p%d" % j for j in range(0, i)]))'