[project @ 2001-03-23 16:36:20 by simonmar]
[ghc-hetmet.git] / ghc / rts / StgMiscClosures.hc
1 /* -----------------------------------------------------------------------------
2  * $Id: StgMiscClosures.hc,v 1.66 2001/03/23 16:36:21 simonmar Exp $
3  *
4  * (c) The GHC Team, 1998-2000
5  *
6  * Entry code for various built-in closure types.
7  *
8  * ---------------------------------------------------------------------------*/
9
10 #include "Stg.h"
11 #include "Rts.h"
12 #include "RtsUtils.h"
13 #include "RtsFlags.h"
14 #include "StgMiscClosures.h"
15 #include "HeapStackCheck.h"   /* for stg_gen_yield */
16 #include "Storage.h"
17 #include "StoragePriv.h"
18 #include "Profiling.h"
19 #include "Prelude.h"
20 #include "Schedule.h"
21 #include "SMP.h"
22 #if defined(GRAN) || defined(PAR)
23 # include "GranSimRts.h"      /* for DumpRawGranEvent */
24 # include "StgRun.h"    /* for StgReturn and register saving */
25 #endif
26
27 #ifdef HAVE_STDIO_H
28 #include <stdio.h>
29 #endif
30
31 /* ToDo: make the printing of panics more win32-friendly, i.e.,
32  *       pop up some lovely message boxes (as well).
33  */
34 #define DUMP_ERRMSG(msg) STGCALL2(fprintf,stderr,msg)
35
36 /*
37   Template for the entry code of non-enterable closures.
38 */
39
40 #define NON_ENTERABLE_ENTRY_CODE(type)                                  \
41 STGFUN(stg_##type##_entry)                                                      \
42 {                                                                       \
43   FB_                                                                   \
44     DUMP_ERRMSG(#type " object entered!\n");                            \
45     STGCALL1(shutdownHaskellAndExit, EXIT_FAILURE);                     \
46     return NULL;                                                        \
47   FE_                                                                   \
48 }
49
50
51 /* -----------------------------------------------------------------------------
52    Support for the bytecode interpreter.
53    -------------------------------------------------------------------------- */
54
55 /* 9 bits of return code for constructors created by the interpreter. */
56 FN_(stg_interp_constr_entry) 
57
58   /* R1 points at the constructor */
59   FB_ 
60     /* STGCALL2(fprintf,stderr,"stg_interp_constr_entry (direct return)!\n"); */
61     /* Pointless, since SET_TAG doesn't do anything */
62     SET_TAG( GET_TAG(GET_INFO(R1.cl))); 
63     JMP_(ENTRY_CODE((P_)(*Sp))); 
64   FE_ 
65 }
66
67 FN_(stg_interp_constr1_entry) { FB_ JMP_(RET_VEC((P_)(*Sp),0)); FE_ }
68 FN_(stg_interp_constr2_entry) { FB_ JMP_(RET_VEC((P_)(*Sp),1)); FE_ }
69 FN_(stg_interp_constr3_entry) { FB_ JMP_(RET_VEC((P_)(*Sp),2)); FE_ }
70 FN_(stg_interp_constr4_entry) { FB_ JMP_(RET_VEC((P_)(*Sp),3)); FE_ }
71 FN_(stg_interp_constr5_entry) { FB_ JMP_(RET_VEC((P_)(*Sp),4)); FE_ }
72 FN_(stg_interp_constr6_entry) { FB_ JMP_(RET_VEC((P_)(*Sp),5)); FE_ }
73 FN_(stg_interp_constr7_entry) { FB_ JMP_(RET_VEC((P_)(*Sp),6)); FE_ }
74 FN_(stg_interp_constr8_entry) { FB_ JMP_(RET_VEC((P_)(*Sp),7)); FE_ }
75  
76 /* Some info tables to be used when compiled code returns a value to
77    the interpreter, i.e. the interpreter pushes one of these onto the
78    stack before entering a value.  What the code does is to
79    impedance-match the compiled return convention (in R1p/R1n/F1/D1 etc) to
80    the interpreter's convention (returned value is on top of stack),
81    and then cause the scheduler to enter the interpreter.
82
83    On entry, the stack (growing down) looks like this:
84
85       ptr to BCO holding return continuation
86       ptr to one of these info tables.
87  
88    The info table code, both direct and vectored, must:
89       * push R1/F1/D1 on the stack, and its tag if necessary
90       * push the BCO (so it's now on the stack twice)
91       * Yield, ie, go to the scheduler.
92
93    Scheduler examines the t.o.s, discovers it is a BCO, and proceeds
94    directly to the bytecode interpreter.  That pops the top element
95    (the BCO, containing the return continuation), and interprets it.
96    Net result: return continuation gets interpreted, with the
97    following stack:
98
99       ptr to this BCO
100       ptr to the info table just jumped thru
101       return value
102
103    which is just what we want -- the "standard" return layout for the
104    interpreter.  Hurrah!
105
106    Don't ask me how unboxed tuple returns are supposed to work.  We
107    haven't got a good story about that yet.
108 */
109
110 /* When the returned value is in R1 and it is a pointer, so doesn't
111    need tagging ... */
112 #define STG_CtoI_RET_R1p_Template(label)        \
113    IFN_(label)                          \
114    {                                    \
115       StgPtr bco;                       \
116       FB_                               \
117       bco = ((StgPtr*)Sp)[1];           \
118       Sp -= 1;                          \
119       ((StgPtr*)Sp)[0] = R1.p;          \
120       Sp -= 1;                          \
121       ((StgPtr*)Sp)[0] = bco;           \
122       JMP_(stg_yield_to_interpreter);   \
123       FE_                               \
124    }
125
126 STG_CtoI_RET_R1p_Template(stg_ctoi_ret_R1p_entry);
127 STG_CtoI_RET_R1p_Template(stg_ctoi_ret_R1p_0_entry);
128 STG_CtoI_RET_R1p_Template(stg_ctoi_ret_R1p_1_entry);
129 STG_CtoI_RET_R1p_Template(stg_ctoi_ret_R1p_2_entry);
130 STG_CtoI_RET_R1p_Template(stg_ctoi_ret_R1p_3_entry);
131 STG_CtoI_RET_R1p_Template(stg_ctoi_ret_R1p_4_entry);
132 STG_CtoI_RET_R1p_Template(stg_ctoi_ret_R1p_5_entry);
133 STG_CtoI_RET_R1p_Template(stg_ctoi_ret_R1p_6_entry);
134 STG_CtoI_RET_R1p_Template(stg_ctoi_ret_R1p_7_entry);
135
136 VEC_POLY_INFO_TABLE(stg_ctoi_ret_R1p,0, NULL/*srt*/, 0/*srt_off*/, 0/*srt_len*/, RET_BCO,, EF_);
137
138
139
140 /* When the returned value is in R1 and it isn't a pointer. */
141 #define STG_CtoI_RET_R1n_Template(label)        \
142    IFN_(label)                          \
143    {                                    \
144       StgPtr bco;                       \
145       FB_                               \
146       bco = ((StgPtr*)Sp)[1];           \
147       Sp -= 1;                          \
148       ((StgPtr*)Sp)[0] = (StgPtr)R1.i;  \
149       Sp -= 1;                          \
150       ((StgPtr*)Sp)[0] = (StgPtr)1; /* tag */   \
151       Sp -= 1;                          \
152       ((StgPtr*)Sp)[0] = bco;           \
153       JMP_(stg_yield_to_interpreter);   \
154       FE_                               \
155    }
156
157 STG_CtoI_RET_R1n_Template(stg_ctoi_ret_R1n_entry);
158 STG_CtoI_RET_R1n_Template(stg_ctoi_ret_R1n_0_entry);
159 STG_CtoI_RET_R1n_Template(stg_ctoi_ret_R1n_1_entry);
160 STG_CtoI_RET_R1n_Template(stg_ctoi_ret_R1n_2_entry);
161 STG_CtoI_RET_R1n_Template(stg_ctoi_ret_R1n_3_entry);
162 STG_CtoI_RET_R1n_Template(stg_ctoi_ret_R1n_4_entry);
163 STG_CtoI_RET_R1n_Template(stg_ctoi_ret_R1n_5_entry);
164 STG_CtoI_RET_R1n_Template(stg_ctoi_ret_R1n_6_entry);
165 STG_CtoI_RET_R1n_Template(stg_ctoi_ret_R1n_7_entry);
166
167 VEC_POLY_INFO_TABLE(stg_ctoi_ret_R1n,0, NULL/*srt*/, 0/*srt_off*/, 0/*srt_len*/, RET_BCO,, EF_);
168
169
170
171 /* When the returned value is in F1 ... */
172 #define STG_CtoI_RET_F1_Template(label)         \
173    IFN_(label)                          \
174    {                                    \
175       StgPtr bco;                       \
176       FB_                               \
177       bco = ((StgPtr*)Sp)[1];           \
178       Sp -= sizeofW(StgFloat);          \
179       ASSIGN_FLT((W_*)Sp, F1);          \
180       Sp -= 1;                          \
181       ((StgPtr*)Sp)[0] = (StgPtr)sizeofW(StgFloat); \
182       Sp -= 1;                          \
183       ((StgPtr*)Sp)[0] = bco;           \
184       JMP_(stg_yield_to_interpreter);   \
185       FE_                               \
186    }
187
188 STG_CtoI_RET_F1_Template(stg_ctoi_ret_F1_entry);
189 STG_CtoI_RET_F1_Template(stg_ctoi_ret_F1_0_entry);
190 STG_CtoI_RET_F1_Template(stg_ctoi_ret_F1_1_entry);
191 STG_CtoI_RET_F1_Template(stg_ctoi_ret_F1_2_entry);
192 STG_CtoI_RET_F1_Template(stg_ctoi_ret_F1_3_entry);
193 STG_CtoI_RET_F1_Template(stg_ctoi_ret_F1_4_entry);
194 STG_CtoI_RET_F1_Template(stg_ctoi_ret_F1_5_entry);
195 STG_CtoI_RET_F1_Template(stg_ctoi_ret_F1_6_entry);
196 STG_CtoI_RET_F1_Template(stg_ctoi_ret_F1_7_entry);
197
198 VEC_POLY_INFO_TABLE(stg_ctoi_ret_F1,0, NULL/*srt*/, 0/*srt_off*/, 0/*srt_len*/, RET_BCO,, EF_);
199
200
201 /* When the returned value is in D1 ... */
202 #define STG_CtoI_RET_D1_Template(label)         \
203    IFN_(label)                          \
204    {                                    \
205       StgPtr bco;                       \
206       FB_                               \
207       bco = ((StgPtr*)Sp)[1];           \
208       Sp -= sizeofW(StgDouble);         \
209       ASSIGN_DBL((W_*)Sp, D1);          \
210       Sp -= 1;                          \
211       ((StgPtr*)Sp)[0] = (StgPtr)sizeofW(StgDouble); \
212       Sp -= 1;                          \
213       ((StgPtr*)Sp)[0] = bco;           \
214       JMP_(stg_yield_to_interpreter);   \
215       FE_                               \
216    }
217
218 STG_CtoI_RET_D1_Template(stg_ctoi_ret_D1_entry);
219 STG_CtoI_RET_D1_Template(stg_ctoi_ret_D1_0_entry);
220 STG_CtoI_RET_D1_Template(stg_ctoi_ret_D1_1_entry);
221 STG_CtoI_RET_D1_Template(stg_ctoi_ret_D1_2_entry);
222 STG_CtoI_RET_D1_Template(stg_ctoi_ret_D1_3_entry);
223 STG_CtoI_RET_D1_Template(stg_ctoi_ret_D1_4_entry);
224 STG_CtoI_RET_D1_Template(stg_ctoi_ret_D1_5_entry);
225 STG_CtoI_RET_D1_Template(stg_ctoi_ret_D1_6_entry);
226 STG_CtoI_RET_D1_Template(stg_ctoi_ret_D1_7_entry);
227
228 VEC_POLY_INFO_TABLE(stg_ctoi_ret_D1,0, NULL/*srt*/, 0/*srt_off*/, 0/*srt_len*/, RET_BCO,, EF_);
229
230
231 /* When the returned value a VoidRep ... */
232 #define STG_CtoI_RET_V_Template(label)  \
233    IFN_(label)                          \
234    {                                    \
235       StgPtr bco;                       \
236       FB_                               \
237       bco = ((StgPtr*)Sp)[1];           \
238       Sp -= 1;                          \
239       ((StgPtr*)Sp)[0] = 0; /* VoidRep tag */ \
240       Sp -= 1;                          \
241       ((StgPtr*)Sp)[0] = bco;           \
242       JMP_(stg_yield_to_interpreter);   \
243       FE_                               \
244    }
245
246 STG_CtoI_RET_V_Template(stg_ctoi_ret_V_entry);
247 STG_CtoI_RET_V_Template(stg_ctoi_ret_V_0_entry);
248 STG_CtoI_RET_V_Template(stg_ctoi_ret_V_1_entry);
249 STG_CtoI_RET_V_Template(stg_ctoi_ret_V_2_entry);
250 STG_CtoI_RET_V_Template(stg_ctoi_ret_V_3_entry);
251 STG_CtoI_RET_V_Template(stg_ctoi_ret_V_4_entry);
252 STG_CtoI_RET_V_Template(stg_ctoi_ret_V_5_entry);
253 STG_CtoI_RET_V_Template(stg_ctoi_ret_V_6_entry);
254 STG_CtoI_RET_V_Template(stg_ctoi_ret_V_7_entry);
255
256 VEC_POLY_INFO_TABLE(stg_ctoi_ret_V,0, NULL/*srt*/, 0/*srt_off*/, 0/*srt_len*/, RET_BCO,, EF_);
257
258
259 /* The other way round: when the interpreter returns a value to
260    compiled code.  The stack looks like this:
261
262       return info table (pushed by compiled code)
263       return value (pushed by interpreter)
264
265    If the value is ptr-rep'd, the interpreter simply returns to the
266    scheduler, instructing it to ThreadEnterGHC.
267
268    Otherwise (unboxed return value), we replace the top stack word,
269    which must be the tag, with stg_gc_unbx_r1_info (or f1_info or d1_info),
270    and return to the scheduler, instructing it to ThreadRunGHC.
271
272    No supporting code needed!
273 */
274
275
276 /* Entering a BCO.  Heave it on the stack and defer to the
277    scheduler. */
278 INFO_TABLE(stg_BCO_info,stg_BCO_entry,4,0,BCO,,EF_,"BCO","BCO");
279 STGFUN(stg_BCO_entry) {
280   FB_
281     Sp -= 1;
282     Sp[0] = R1.w;
283     JMP_(stg_yield_to_interpreter);
284   FE_
285 }
286
287
288 /* -----------------------------------------------------------------------------
289    Entry code for an indirection.
290    -------------------------------------------------------------------------- */
291
292 INFO_TABLE(stg_IND_info,stg_IND_entry,1,0,IND,,EF_,0,0);
293 STGFUN(stg_IND_entry)
294 {
295     FB_
296     TICK_ENT_IND(Node); /* tick */
297
298     R1.p = (P_) ((StgInd*)R1.p)->indirectee;
299     TICK_ENT_VIA_NODE();
300     JMP_(ENTRY_CODE(*R1.p));
301     FE_
302 }
303
304 INFO_TABLE(stg_IND_STATIC_info,stg_IND_STATIC_entry,1,0,IND_STATIC,,EF_,0,0);
305 STGFUN(stg_IND_STATIC_entry)
306 {
307     FB_
308     TICK_ENT_IND(Node); /* tick */
309     R1.p = (P_) ((StgIndStatic*)R1.p)->indirectee;
310     TICK_ENT_VIA_NODE();
311     JMP_(ENTRY_CODE(*R1.p));
312     FE_
313 }
314
315 INFO_TABLE(stg_IND_PERM_info,stg_IND_PERM_entry,1,1,IND_PERM,,EF_,"IND_PERM","IND_PERM");
316 STGFUN(stg_IND_PERM_entry)
317 {
318     FB_
319     /* Don't add INDs to granularity cost */
320     /* Dont: TICK_ENT_IND(Node); for ticky-ticky; this ind is here only to help profiling */
321
322 #if defined(TICKY_TICKY) && !defined(PROFILING)
323     /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, rather than being extra  */
324     TICK_ENT_PERM_IND(R1.p); /* tick */
325 #endif
326
327     /* Enter PAP cost centre -- lexical scoping only */
328     ENTER_CCS_PAP_CL(R1.cl);
329
330     /* For ticky-ticky, change the perm_ind to a normal ind on first
331      * entry, so the number of ent_perm_inds is the number of *thunks*
332      * entered again, not the number of subsequent entries.
333      *
334      * Since this screws up cost centres, we die if profiling and
335      * ticky_ticky are on at the same time.  KSW 1999-01.
336      */
337
338 #ifdef TICKY_TICKY
339 #  ifdef PROFILING
340 #    error Profiling and ticky-ticky do not mix at present!
341 #  endif  /* PROFILING */
342     SET_INFO((StgInd*)R1.p,&stg_IND_info);
343 #endif /* TICKY_TICKY */
344
345     R1.p = (P_) ((StgInd*)R1.p)->indirectee;
346
347     /* Dont: TICK_ENT_VIA_NODE(); for ticky-ticky; as above */
348
349 #if defined(TICKY_TICKY) && !defined(PROFILING)
350     TICK_ENT_VIA_NODE();
351 #endif
352
353     JMP_(ENTRY_CODE(*R1.p));
354     FE_
355 }  
356
357 INFO_TABLE(stg_IND_OLDGEN_info,stg_IND_OLDGEN_entry,1,1,IND_OLDGEN,,EF_,0,0);
358 STGFUN(stg_IND_OLDGEN_entry)
359 {
360     FB_
361     TICK_ENT_IND(Node); /* tick */
362   
363     R1.p = (P_) ((StgInd*)R1.p)->indirectee;
364     TICK_ENT_VIA_NODE();
365     JMP_(ENTRY_CODE(*R1.p));
366     FE_
367 }
368
369 INFO_TABLE(stg_IND_OLDGEN_PERM_info,stg_IND_OLDGEN_PERM_entry,1,1,IND_OLDGEN_PERM,,EF_,0,0);
370 STGFUN(stg_IND_OLDGEN_PERM_entry)
371 {
372     FB_
373     /* Dont: TICK_ENT_IND(Node); for ticky-ticky; this ind is here only to help profiling */
374
375 #if defined(TICKY_TICKY) && !defined(PROFILING)
376     /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, rather than being extra  */
377     TICK_ENT_PERM_IND(R1.p); /* tick */
378 #endif
379   
380     /* Enter PAP cost centre -- lexical scoping only */
381     ENTER_CCS_PAP_CL(R1.cl);
382
383     /* see comment in IND_PERM */
384 #ifdef TICKY_TICKY
385 #  ifdef PROFILING
386 #    error Profiling and ticky-ticky do not mix at present!
387 #  endif  /* PROFILING */
388     SET_INFO((StgInd*)R1.p,&stg_IND_OLDGEN_info);
389 #endif /* TICKY_TICKY */
390
391     R1.p = (P_) ((StgInd*)R1.p)->indirectee;
392     TICK_ENT_VIA_NODE();
393     JMP_(ENTRY_CODE(*R1.p));
394     FE_
395 }
396
397 /* -----------------------------------------------------------------------------
398    Entry code for a black hole.
399
400    Entering a black hole normally causes a cyclic data dependency, but
401    in the concurrent world, black holes are synchronization points,
402    and they are turned into blocking queues when there are threads
403    waiting for the evaluation of the closure to finish.
404    -------------------------------------------------------------------------- */
405
406 /* Note: a BLACKHOLE and BLACKHOLE_BQ must be big enough to be
407  * overwritten with an indirection/evacuee/catch.  Thus we claim it
408  * has 1 non-pointer word of payload (in addition to the pointer word
409  * for the blocking queue in a BQ), which should be big enough for an
410  * old-generation indirection. 
411  */
412
413 INFO_TABLE(stg_BLACKHOLE_info, stg_BLACKHOLE_entry,0,2,BLACKHOLE,,EF_,"BLACKHOLE","BLACKHOLE");
414 STGFUN(stg_BLACKHOLE_entry)
415 {
416   FB_
417 #if defined(GRAN)
418     /* Before overwriting TSO_LINK */
419     STGCALL3(GranSimBlock,CurrentTSO,CurrentProc,(StgClosure *)R1.p /*Node*/);
420 #endif
421
422 #ifdef SMP
423     {
424       bdescr *bd = Bdescr(R1.p);
425       if (bd->back != (bdescr *)BaseReg) {
426         if (bd->gen->no >= 1 || bd->step->no >= 1) {
427           CMPXCHG(R1.cl->header.info, &stg_BLACKHOLE_info, &stg_WHITEHOLE_info);
428         } else {
429           EXTFUN_RTS(stg_gc_enter_1_hponly);
430           JMP_(stg_gc_enter_1_hponly);
431         }
432       }
433     }
434 #endif
435     TICK_ENT_BH();
436
437     /* Put ourselves on the blocking queue for this black hole */
438 #if defined(GRAN) || defined(PAR)
439     /* in fact, only difference is the type of the end-of-queue marker! */
440     CurrentTSO->link = END_BQ_QUEUE;
441     ((StgBlockingQueue *)R1.p)->blocking_queue = (StgBlockingQueueElement *)CurrentTSO;
442 #else
443     CurrentTSO->link = END_TSO_QUEUE;
444     ((StgBlockingQueue *)R1.p)->blocking_queue = CurrentTSO;
445 #endif
446     /* jot down why and on what closure we are blocked */
447     CurrentTSO->why_blocked = BlockedOnBlackHole;
448     CurrentTSO->block_info.closure = R1.cl;
449     /* closure is mutable since something has just been added to its BQ */
450     recordMutable((StgMutClosure *)R1.cl);
451     /* Change the BLACKHOLE into a BLACKHOLE_BQ */
452     ((StgBlockingQueue *)R1.p)->header.info = &stg_BLACKHOLE_BQ_info;
453
454     /* PAR: dumping of event now done in blockThread -- HWL */
455
456     /* stg_gen_block is too heavyweight, use a specialised one */
457     BLOCK_NP(1);
458
459   FE_
460 }
461
462 INFO_TABLE(stg_BLACKHOLE_BQ_info, stg_BLACKHOLE_BQ_entry,1,1,BLACKHOLE_BQ,,EF_,"BLACKHOLE","BLACKHOLE");
463 STGFUN(stg_BLACKHOLE_BQ_entry)
464 {
465   FB_
466 #if defined(GRAN)
467     /* Before overwriting TSO_LINK */
468     STGCALL3(GranSimBlock,CurrentTSO,CurrentProc,(StgClosure *)R1.p /*Node*/);
469 #endif
470
471 #ifdef SMP
472     {
473       bdescr *bd = Bdescr(R1.p);
474       if (bd->back != (bdescr *)BaseReg) {
475         if (bd->gen->no >= 1 || bd->step->no >= 1) {
476           CMPXCHG(R1.cl->header.info, &stg_BLACKHOLE_info, &stg_WHITEHOLE_info);
477         } else {
478           EXTFUN_RTS(stg_gc_enter_1_hponly);
479           JMP_(stg_gc_enter_1_hponly);
480         }
481       }
482     }
483 #endif
484
485     TICK_ENT_BH();
486
487     /* Put ourselves on the blocking queue for this black hole */
488     CurrentTSO->link = ((StgBlockingQueue *)R1.p)->blocking_queue;
489     ((StgBlockingQueue *)R1.p)->blocking_queue = CurrentTSO;
490     /* jot down why and on what closure we are blocked */
491     CurrentTSO->why_blocked = BlockedOnBlackHole;
492     CurrentTSO->block_info.closure = R1.cl;
493 #ifdef SMP
494     ((StgBlockingQueue *)R1.p)->header.info = &stg_BLACKHOLE_BQ_info;
495 #endif
496
497     /* PAR: dumping of event now done in blockThread -- HWL */
498
499     /* stg_gen_block is too heavyweight, use a specialised one */
500     BLOCK_NP(1);
501   FE_
502 }
503
504 /*
505    Revertible black holes are needed in the parallel world, to handle
506    negative acknowledgements of messages containing updatable closures.
507    The idea is that when the original message is transmitted, the closure
508    is turned into a revertible black hole...an object which acts like a
509    black hole when local threads try to enter it, but which can be reverted
510    back to the original closure if necessary.
511
512    It's actually a lot like a blocking queue (BQ) entry, because revertible
513    black holes are initially set up with an empty blocking queue.
514 */
515
516 #if defined(PAR) || defined(GRAN)
517
518 INFO_TABLE(stg_RBH_info, stg_RBH_entry,1,1,RBH,,EF_,0,0);
519 STGFUN(stg_RBH_entry)
520 {
521   FB_
522 # if defined(GRAN)
523     /* mainly statistics gathering for GranSim simulation */
524     STGCALL3(GranSimBlock,CurrentTSO,CurrentProc,(StgClosure *)R1.p /*Node*/);
525 # endif
526
527     /* exactly the same as a BLACKHOLE_BQ_entry -- HWL */
528     /* Put ourselves on the blocking queue for this black hole */
529     CurrentTSO->link = ((StgBlockingQueue *)R1.p)->blocking_queue;
530     ((StgBlockingQueue *)R1.p)->blocking_queue = CurrentTSO;
531     /* jot down why and on what closure we are blocked */
532     CurrentTSO->why_blocked = BlockedOnBlackHole;
533     CurrentTSO->block_info.closure = R1.cl;
534
535     /* PAR: dumping of event now done in blockThread -- HWL */
536
537     /* stg_gen_block is too heavyweight, use a specialised one */
538     BLOCK_NP(1); 
539   FE_
540 }
541
542 INFO_TABLE(stg_RBH_Save_0_info, stg_RBH_Save_0_entry,0,2,CONSTR,,EF_,0,0);
543 NON_ENTERABLE_ENTRY_CODE(RBH_Save_0);
544
545 INFO_TABLE(stg_RBH_Save_1_info, stg_RBH_Save_1_entry,1,1,CONSTR,,EF_,0,0);
546 NON_ENTERABLE_ENTRY_CODE(RBH_Save_1);
547
548 INFO_TABLE(stg_RBH_Save_2_info, stg_RBH_Save_2_entry,2,0,CONSTR,,EF_,0,0);
549 NON_ENTERABLE_ENTRY_CODE(RBH_Save_2);
550 #endif /* defined(PAR) || defined(GRAN) */
551
552 /* identical to BLACKHOLEs except for the infotag */
553 INFO_TABLE(stg_CAF_BLACKHOLE_info, stg_CAF_BLACKHOLE_entry,0,2,CAF_BLACKHOLE,,EF_,"CAF_BLACKHOLE","CAF_BLACKHOLE");
554 STGFUN(stg_CAF_BLACKHOLE_entry)
555 {
556   FB_
557 #if defined(GRAN)
558     /* mainly statistics gathering for GranSim simulation */
559     STGCALL3(GranSimBlock,CurrentTSO,CurrentProc,(StgClosure *)R1.p /*Node*/);
560 #endif
561
562 #ifdef SMP
563     {
564       bdescr *bd = Bdescr(R1.p);
565       if (bd->back != (bdescr *)BaseReg) {
566         if (bd->gen->no >= 1 || bd->step->no >= 1) {
567           CMPXCHG(R1.cl->header.info, &stg_CAF_BLACKHOLE_info, &stg_WHITEHOLE_info);
568         } else {
569           EXTFUN_RTS(stg_gc_enter_1_hponly);
570           JMP_(stg_gc_enter_1_hponly);
571         }
572       }
573     }
574 #endif
575
576     TICK_ENT_BH();
577
578     /* Put ourselves on the blocking queue for this black hole */
579 #if defined(GRAN) || defined(PAR)
580     /* in fact, only difference is the type of the end-of-queue marker! */
581     CurrentTSO->link = END_BQ_QUEUE;
582     ((StgBlockingQueue *)R1.p)->blocking_queue = (StgBlockingQueueElement *)CurrentTSO;
583 #else
584     CurrentTSO->link = END_TSO_QUEUE;
585     ((StgBlockingQueue *)R1.p)->blocking_queue = CurrentTSO;
586 #endif
587     /* jot down why and on what closure we are blocked */
588     CurrentTSO->why_blocked = BlockedOnBlackHole;
589     CurrentTSO->block_info.closure = R1.cl;
590     /* closure is mutable since something has just been added to its BQ */
591     recordMutable((StgMutClosure *)R1.cl);
592     /* Change the CAF_BLACKHOLE into a BLACKHOLE_BQ_STATIC */
593     ((StgBlockingQueue *)R1.p)->header.info = &stg_BLACKHOLE_BQ_info;
594
595     /* PAR: dumping of event now done in blockThread -- HWL */
596
597     /* stg_gen_block is too heavyweight, use a specialised one */
598     BLOCK_NP(1);
599   FE_
600 }
601
602 #ifdef TICKY_TICKY
603 INFO_TABLE(stg_SE_BLACKHOLE_info, stg_SE_BLACKHOLE_entry,0,2,SE_BLACKHOLE,,EF_,0,0);
604 STGFUN(stg_SE_BLACKHOLE_entry)
605 {
606   FB_
607     STGCALL3(fprintf,stderr,"SE_BLACKHOLE at %p entered!\n",R1.p);
608     STGCALL1(shutdownHaskellAndExit,EXIT_FAILURE);
609   FE_
610 }
611
612 INFO_TABLE(SE_CAF_BLACKHOLE_info, SE_CAF_BLACKHOLE_entry,0,2,SE_CAF_BLACKHOLE,,EF_,0,0);
613 STGFUN(stg_SE_CAF_BLACKHOLE_entry)
614 {
615   FB_
616     STGCALL3(fprintf,stderr,"SE_CAF_BLACKHOLE at %p entered!\n",R1.p);
617     STGCALL1(shutdownHaskellAndExit,EXIT_FAILURE);
618   FE_
619 }
620 #endif
621
622 #ifdef SMP
623 INFO_TABLE(stg_WHITEHOLE_info, stg_WHITEHOLE_entry,0,2,CONSTR_NOCAF_STATIC,,EF_,0,0);
624 STGFUN(stg_WHITEHOLE_entry)
625 {
626   FB_
627      JMP_(GET_ENTRY(R1.cl));
628   FE_
629 }
630 #endif
631
632 /* -----------------------------------------------------------------------------
633    Some static info tables for things that don't get entered, and
634    therefore don't need entry code (i.e. boxed but unpointed objects)
635    NON_ENTERABLE_ENTRY_CODE now defined at the beginning of the file
636    -------------------------------------------------------------------------- */
637
638 INFO_TABLE(stg_TSO_info, stg_TSO_entry, 0,0,TSO,,EF_,"TSO","TSO");
639 NON_ENTERABLE_ENTRY_CODE(TSO);
640
641 /* -----------------------------------------------------------------------------
642    Evacuees are left behind by the garbage collector.  Any attempt to enter
643    one is a real bug.
644    -------------------------------------------------------------------------- */
645
646 INFO_TABLE(stg_EVACUATED_info,stg_EVACUATED_entry,1,0,EVACUATED,,EF_,0,0);
647 NON_ENTERABLE_ENTRY_CODE(EVACUATED);
648
649 /* -----------------------------------------------------------------------------
650    Weak pointers
651
652    Live weak pointers have a special closure type.  Dead ones are just
653    nullary constructors (although they live on the heap - we overwrite
654    live weak pointers with dead ones).
655    -------------------------------------------------------------------------- */
656
657 INFO_TABLE(stg_WEAK_info,stg_WEAK_entry,0,4,WEAK,,EF_,"WEAK","WEAK");
658 NON_ENTERABLE_ENTRY_CODE(WEAK);
659
660 INFO_TABLE_CONSTR(stg_DEAD_WEAK_info,stg_DEAD_WEAK_entry,0,1,0,CONSTR,,EF_,"DEAD_WEAK","DEAD_WEAK");
661 NON_ENTERABLE_ENTRY_CODE(DEAD_WEAK);
662
663 /* -----------------------------------------------------------------------------
664    NO_FINALIZER
665
666    This is a static nullary constructor (like []) that we use to mark an empty
667    finalizer in a weak pointer object.
668    -------------------------------------------------------------------------- */
669
670 INFO_TABLE_CONSTR(stg_NO_FINALIZER_info,stg_NO_FINALIZER_entry,0,0,0,CONSTR_NOCAF_STATIC,,EF_,0,0);
671 NON_ENTERABLE_ENTRY_CODE(NO_FINALIZER);
672
673 SET_STATIC_HDR(stg_NO_FINALIZER_closure,stg_NO_FINALIZER_info,0/*CC*/,,EI_)
674 , /*payload*/{} };
675
676 /* -----------------------------------------------------------------------------
677    Foreign Objects are unlifted and therefore never entered.
678    -------------------------------------------------------------------------- */
679
680 INFO_TABLE(stg_FOREIGN_info,stg_FOREIGN_entry,0,1,FOREIGN,,EF_,"FOREIGN","FOREIGN");
681 NON_ENTERABLE_ENTRY_CODE(FOREIGN);
682
683 /* -----------------------------------------------------------------------------
684    Stable Names are unlifted too.
685    -------------------------------------------------------------------------- */
686
687 INFO_TABLE(stg_STABLE_NAME_info,stg_STABLE_NAME_entry,0,1,STABLE_NAME,,EF_,"STABLE_NAME","STABLE_NAME");
688 NON_ENTERABLE_ENTRY_CODE(STABLE_NAME);
689
690 /* -----------------------------------------------------------------------------
691    MVars
692
693    There are two kinds of these: full and empty.  We need an info table
694    and entry code for each type.
695    -------------------------------------------------------------------------- */
696
697 INFO_TABLE(stg_FULL_MVAR_info,stg_FULL_MVAR_entry,4,0,MVAR,,EF_,"MVAR","MVAR");
698 NON_ENTERABLE_ENTRY_CODE(FULL_MVAR);
699
700 INFO_TABLE(stg_EMPTY_MVAR_info,stg_EMPTY_MVAR_entry,4,0,MVAR,,EF_,"MVAR","MVAR");
701 NON_ENTERABLE_ENTRY_CODE(EMPTY_MVAR);
702
703 /* -----------------------------------------------------------------------------
704    END_TSO_QUEUE
705
706    This is a static nullary constructor (like []) that we use to mark the
707    end of a linked TSO queue.
708    -------------------------------------------------------------------------- */
709
710 INFO_TABLE_CONSTR(stg_END_TSO_QUEUE_info,stg_END_TSO_QUEUE_entry,0,0,0,CONSTR_NOCAF_STATIC,,EF_,0,0);
711 NON_ENTERABLE_ENTRY_CODE(END_TSO_QUEUE);
712
713 SET_STATIC_HDR(stg_END_TSO_QUEUE_closure,stg_END_TSO_QUEUE_info,0/*CC*/,,EI_)
714 , /*payload*/{} };
715
716 /* -----------------------------------------------------------------------------
717    Mutable lists
718
719    Mutable lists (used by the garbage collector) consist of a chain of
720    StgMutClosures connected through their mut_link fields, ending in
721    an END_MUT_LIST closure.
722    -------------------------------------------------------------------------- */
723
724 INFO_TABLE_CONSTR(stg_END_MUT_LIST_info,stg_END_MUT_LIST_entry,0,0,0,CONSTR_NOCAF_STATIC,,EF_,0,0);
725 NON_ENTERABLE_ENTRY_CODE(END_MUT_LIST);
726
727 SET_STATIC_HDR(stg_END_MUT_LIST_closure,stg_END_MUT_LIST_info,0/*CC*/,,EI_)
728 , /*payload*/{} };
729
730 INFO_TABLE(stg_MUT_CONS_info, stg_MUT_CONS_entry, 1, 1, MUT_VAR, , EF_, 0, 0);
731 NON_ENTERABLE_ENTRY_CODE(MUT_CONS);
732
733 /* -----------------------------------------------------------------------------
734    Exception lists
735    -------------------------------------------------------------------------- */
736
737 INFO_TABLE_CONSTR(stg_END_EXCEPTION_LIST_info,stg_END_EXCEPTION_LIST_entry,0,0,0,CONSTR_NOCAF_STATIC,,EF_,0,0);
738 NON_ENTERABLE_ENTRY_CODE(END_EXCEPTION_LIST);
739
740 SET_STATIC_HDR(stg_END_EXCEPTION_LIST_closure,stg_END_EXCEPTION_LIST_info,0/*CC*/,,EI_)
741 , /*payload*/{} };
742
743 INFO_TABLE(stg_EXCEPTION_CONS_info, stg_EXCEPTION_CONS_entry, 1, 1, CONSTR, , EF_, 0, 0);
744 NON_ENTERABLE_ENTRY_CODE(EXCEPTION_CONS);
745
746 /* -----------------------------------------------------------------------------
747    Arrays
748
749    These come in two basic flavours: arrays of data (StgArrWords) and arrays of
750    pointers (StgArrPtrs).  They all have a similar layout:
751
752         ___________________________
753         | Info | No. of | data....
754         |  Ptr | Words  |
755         ---------------------------
756
757    These are *unpointed* objects: i.e. they cannot be entered.
758
759    -------------------------------------------------------------------------- */
760
761 #define ArrayInfo(type)                                 \
762 INFO_TABLE(stg_##type##_info, stg_##type##_entry, 0, 0, type, , EF_,"" # type "","" # type "");
763
764 ArrayInfo(ARR_WORDS);
765 NON_ENTERABLE_ENTRY_CODE(ARR_WORDS);
766 ArrayInfo(MUT_ARR_PTRS);
767 NON_ENTERABLE_ENTRY_CODE(MUT_ARR_PTRS);
768 ArrayInfo(MUT_ARR_PTRS_FROZEN);
769 NON_ENTERABLE_ENTRY_CODE(MUT_ARR_PTRS_FROZEN);
770
771 #undef ArrayInfo
772
773 /* -----------------------------------------------------------------------------
774    Mutable Variables
775    -------------------------------------------------------------------------- */
776
777 INFO_TABLE(stg_MUT_VAR_info, stg_MUT_VAR_entry, 1, 1, MUT_VAR, , EF_, "MUT_VAR", "MUT_VAR");
778 NON_ENTERABLE_ENTRY_CODE(MUT_VAR);
779
780 /* -----------------------------------------------------------------------------
781    Standard Error Entry.
782
783    This is used for filling in vector-table entries that can never happen,
784    for instance.
785    -------------------------------------------------------------------------- */
786 /* No longer used; we use NULL, because a) it never happens, right? and b)
787    Windows doesn't like DLL entry points being used as static initialisers
788 STGFUN(stg_error_entry)                                                 \
789 {                                                                       \
790   FB_                                                                   \
791     DUMP_ERRMSG("fatal: stg_error_entry");                              \
792     STGCALL1(shutdownHaskellAndExit, EXIT_FAILURE);                     \
793     return NULL;                                                        \
794   FE_                                                                   \
795 }
796 */
797 /* -----------------------------------------------------------------------------
798    Dummy return closure
799  
800    Entering this closure will just return to the address on the top of the
801    stack.  Useful for getting a thread in a canonical form where we can
802    just enter the top stack word to start the thread.  (see deleteThread)
803  * -------------------------------------------------------------------------- */
804
805 INFO_TABLE(stg_dummy_ret_info, stg_dummy_ret_entry, 0, 0, CONSTR_NOCAF_STATIC, , EF_, 0, 0);
806 STGFUN(stg_dummy_ret_entry)
807 {
808   W_ ret_addr;
809   FB_
810   ret_addr = Sp[0];
811   Sp++;
812   JMP_(ENTRY_CODE(ret_addr));
813   FE_
814 }
815 SET_STATIC_HDR(stg_dummy_ret_closure,stg_dummy_ret_info,CCS_DONT_CARE,,EI_)
816 , /*payload*/{} };
817
818 /* -----------------------------------------------------------------------------
819     Strict IO application - performing an IO action and entering its result.
820     
821     rts_evalIO() lets you perform Haskell IO actions from outside of Haskell-land,
822     returning back to you their result. Want this result to be evaluated to WHNF
823     by that time, so that we can easily get at the int/char/whatever using the
824     various get{Ty} functions provided by the RTS API.
825
826     forceIO takes care of this, performing the IO action and entering the
827     results that comes back.
828
829  * -------------------------------------------------------------------------- */
830
831 #ifdef REG_R1
832 INFO_TABLE_SRT_BITMAP(stg_forceIO_ret_info,stg_forceIO_ret_entry,0,0,0,0,RET_SMALL,,EF_,0,0);
833 STGFUN(stg_forceIO_ret_entry)
834 {
835   FB_
836   Sp++;
837   Sp -= sizeofW(StgSeqFrame);
838   PUSH_SEQ_FRAME(Sp);
839   JMP_(GET_ENTRY(R1.cl));
840 }
841 #else
842 INFO_TABLE_SRT_BITMAP(stg_forceIO_ret_info,stg_forceIO_ret_entry,0,0,0,0,RET_SMALL,,EF_,0,0);
843 STGFUN(stg_forceIO_ret_entry)
844 {
845   StgClosure *rval;
846   FB_
847   rval = (StgClosure *)Sp[0];
848   Sp += 2;
849   Sp -= sizeofW(StgSeqFrame);
850   PUSH_SEQ_FRAME(Sp);
851   R1.cl = rval;
852   JMP_(GET_ENTRY(R1.cl));
853 }
854 #endif
855
856 INFO_TABLE(stg_forceIO_info,stg_forceIO_entry,1,0,FUN_STATIC,,EF_,0,0);
857 FN_(stg_forceIO_entry)
858 {
859   FB_
860   /* Sp[0] contains the IO action we want to perform */
861   R1.p  = (P_)Sp[0];
862   /* Replace it with the return continuation that enters the result. */
863   Sp[0] = (W_)&stg_forceIO_ret_info;
864   Sp--;
865   /* Push the RealWorld# tag and enter */
866   Sp[0] =(W_)REALWORLD_TAG;
867   JMP_(GET_ENTRY(R1.cl));
868   FE_
869 }
870 SET_STATIC_HDR(stg_forceIO_closure,stg_forceIO_info,CCS_DONT_CARE,,EI_)
871 , /*payload*/{} };
872
873
874 /* -----------------------------------------------------------------------------
875    CHARLIKE and INTLIKE closures.  
876
877    These are static representations of Chars and small Ints, so that
878    we can remove dynamic Chars and Ints during garbage collection and
879    replace them with references to the static objects.
880    -------------------------------------------------------------------------- */
881
882 #if defined(INTERPRETER) || defined(ENABLE_WIN32_DLL_SUPPORT)
883 /*
884  * When sticking the RTS in a DLL, we delay populating the
885  * Charlike and Intlike tables until load-time, which is only
886  * when we've got the real addresses to the C# and I# closures.
887  *
888  */
889 static INFO_TBL_CONST StgInfoTable czh_static_info;
890 static INFO_TBL_CONST StgInfoTable izh_static_info;
891 #define Char_hash_static_info czh_static_info
892 #define Int_hash_static_info izh_static_info
893 #else
894 #define Char_hash_static_info PrelBase_Czh_static_info
895 #define Int_hash_static_info PrelBase_Izh_static_info
896 #endif
897
898 #define CHARLIKE_HDR(n)                                         \
899         {                                                       \
900           STATIC_HDR(Char_hash_static_info, /* C# */            \
901                          CCS_DONT_CARE),                        \
902           data : n                                              \
903         }
904                                              
905 #define INTLIKE_HDR(n)                                          \
906         {                                                       \
907           STATIC_HDR(Int_hash_static_info,  /* I# */            \
908                          CCS_DONT_CARE),                        \
909           data : n                                              \
910         }
911
912 /* put these in the *data* section, since the garbage collector relies
913  * on the fact that static closures live in the data section.
914  */
915
916 /* end the name with _closure, to convince the mangler this is a closure */
917
918 StgIntCharlikeClosure stg_CHARLIKE_closure[] = {
919     CHARLIKE_HDR(0),
920     CHARLIKE_HDR(1),
921     CHARLIKE_HDR(2),
922     CHARLIKE_HDR(3),
923     CHARLIKE_HDR(4),
924     CHARLIKE_HDR(5),
925     CHARLIKE_HDR(6),
926     CHARLIKE_HDR(7),
927     CHARLIKE_HDR(8),
928     CHARLIKE_HDR(9),
929     CHARLIKE_HDR(10),
930     CHARLIKE_HDR(11),
931     CHARLIKE_HDR(12),
932     CHARLIKE_HDR(13),
933     CHARLIKE_HDR(14),
934     CHARLIKE_HDR(15),
935     CHARLIKE_HDR(16),
936     CHARLIKE_HDR(17),
937     CHARLIKE_HDR(18),
938     CHARLIKE_HDR(19),
939     CHARLIKE_HDR(20),
940     CHARLIKE_HDR(21),
941     CHARLIKE_HDR(22),
942     CHARLIKE_HDR(23),
943     CHARLIKE_HDR(24),
944     CHARLIKE_HDR(25),
945     CHARLIKE_HDR(26),
946     CHARLIKE_HDR(27),
947     CHARLIKE_HDR(28),
948     CHARLIKE_HDR(29),
949     CHARLIKE_HDR(30),
950     CHARLIKE_HDR(31),
951     CHARLIKE_HDR(32),
952     CHARLIKE_HDR(33),
953     CHARLIKE_HDR(34),
954     CHARLIKE_HDR(35),
955     CHARLIKE_HDR(36),
956     CHARLIKE_HDR(37),
957     CHARLIKE_HDR(38),
958     CHARLIKE_HDR(39),
959     CHARLIKE_HDR(40),
960     CHARLIKE_HDR(41),
961     CHARLIKE_HDR(42),
962     CHARLIKE_HDR(43),
963     CHARLIKE_HDR(44),
964     CHARLIKE_HDR(45),
965     CHARLIKE_HDR(46),
966     CHARLIKE_HDR(47),
967     CHARLIKE_HDR(48),
968     CHARLIKE_HDR(49),
969     CHARLIKE_HDR(50),
970     CHARLIKE_HDR(51),
971     CHARLIKE_HDR(52),
972     CHARLIKE_HDR(53),
973     CHARLIKE_HDR(54),
974     CHARLIKE_HDR(55),
975     CHARLIKE_HDR(56),
976     CHARLIKE_HDR(57),
977     CHARLIKE_HDR(58),
978     CHARLIKE_HDR(59),
979     CHARLIKE_HDR(60),
980     CHARLIKE_HDR(61),
981     CHARLIKE_HDR(62),
982     CHARLIKE_HDR(63),
983     CHARLIKE_HDR(64),
984     CHARLIKE_HDR(65),
985     CHARLIKE_HDR(66),
986     CHARLIKE_HDR(67),
987     CHARLIKE_HDR(68),
988     CHARLIKE_HDR(69),
989     CHARLIKE_HDR(70),
990     CHARLIKE_HDR(71),
991     CHARLIKE_HDR(72),
992     CHARLIKE_HDR(73),
993     CHARLIKE_HDR(74),
994     CHARLIKE_HDR(75),
995     CHARLIKE_HDR(76),
996     CHARLIKE_HDR(77),
997     CHARLIKE_HDR(78),
998     CHARLIKE_HDR(79),
999     CHARLIKE_HDR(80),
1000     CHARLIKE_HDR(81),
1001     CHARLIKE_HDR(82),
1002     CHARLIKE_HDR(83),
1003     CHARLIKE_HDR(84),
1004     CHARLIKE_HDR(85),
1005     CHARLIKE_HDR(86),
1006     CHARLIKE_HDR(87),
1007     CHARLIKE_HDR(88),
1008     CHARLIKE_HDR(89),
1009     CHARLIKE_HDR(90),
1010     CHARLIKE_HDR(91),
1011     CHARLIKE_HDR(92),
1012     CHARLIKE_HDR(93),
1013     CHARLIKE_HDR(94),
1014     CHARLIKE_HDR(95),
1015     CHARLIKE_HDR(96),
1016     CHARLIKE_HDR(97),
1017     CHARLIKE_HDR(98),
1018     CHARLIKE_HDR(99),
1019     CHARLIKE_HDR(100),
1020     CHARLIKE_HDR(101),
1021     CHARLIKE_HDR(102),
1022     CHARLIKE_HDR(103),
1023     CHARLIKE_HDR(104),
1024     CHARLIKE_HDR(105),
1025     CHARLIKE_HDR(106),
1026     CHARLIKE_HDR(107),
1027     CHARLIKE_HDR(108),
1028     CHARLIKE_HDR(109),
1029     CHARLIKE_HDR(110),
1030     CHARLIKE_HDR(111),
1031     CHARLIKE_HDR(112),
1032     CHARLIKE_HDR(113),
1033     CHARLIKE_HDR(114),
1034     CHARLIKE_HDR(115),
1035     CHARLIKE_HDR(116),
1036     CHARLIKE_HDR(117),
1037     CHARLIKE_HDR(118),
1038     CHARLIKE_HDR(119),
1039     CHARLIKE_HDR(120),
1040     CHARLIKE_HDR(121),
1041     CHARLIKE_HDR(122),
1042     CHARLIKE_HDR(123),
1043     CHARLIKE_HDR(124),
1044     CHARLIKE_HDR(125),
1045     CHARLIKE_HDR(126),
1046     CHARLIKE_HDR(127),
1047     CHARLIKE_HDR(128),
1048     CHARLIKE_HDR(129),
1049     CHARLIKE_HDR(130),
1050     CHARLIKE_HDR(131),
1051     CHARLIKE_HDR(132),
1052     CHARLIKE_HDR(133),
1053     CHARLIKE_HDR(134),
1054     CHARLIKE_HDR(135),
1055     CHARLIKE_HDR(136),
1056     CHARLIKE_HDR(137),
1057     CHARLIKE_HDR(138),
1058     CHARLIKE_HDR(139),
1059     CHARLIKE_HDR(140),
1060     CHARLIKE_HDR(141),
1061     CHARLIKE_HDR(142),
1062     CHARLIKE_HDR(143),
1063     CHARLIKE_HDR(144),
1064     CHARLIKE_HDR(145),
1065     CHARLIKE_HDR(146),
1066     CHARLIKE_HDR(147),
1067     CHARLIKE_HDR(148),
1068     CHARLIKE_HDR(149),
1069     CHARLIKE_HDR(150),
1070     CHARLIKE_HDR(151),
1071     CHARLIKE_HDR(152),
1072     CHARLIKE_HDR(153),
1073     CHARLIKE_HDR(154),
1074     CHARLIKE_HDR(155),
1075     CHARLIKE_HDR(156),
1076     CHARLIKE_HDR(157),
1077     CHARLIKE_HDR(158),
1078     CHARLIKE_HDR(159),
1079     CHARLIKE_HDR(160),
1080     CHARLIKE_HDR(161),
1081     CHARLIKE_HDR(162),
1082     CHARLIKE_HDR(163),
1083     CHARLIKE_HDR(164),
1084     CHARLIKE_HDR(165),
1085     CHARLIKE_HDR(166),
1086     CHARLIKE_HDR(167),
1087     CHARLIKE_HDR(168),
1088     CHARLIKE_HDR(169),
1089     CHARLIKE_HDR(170),
1090     CHARLIKE_HDR(171),
1091     CHARLIKE_HDR(172),
1092     CHARLIKE_HDR(173),
1093     CHARLIKE_HDR(174),
1094     CHARLIKE_HDR(175),
1095     CHARLIKE_HDR(176),
1096     CHARLIKE_HDR(177),
1097     CHARLIKE_HDR(178),
1098     CHARLIKE_HDR(179),
1099     CHARLIKE_HDR(180),
1100     CHARLIKE_HDR(181),
1101     CHARLIKE_HDR(182),
1102     CHARLIKE_HDR(183),
1103     CHARLIKE_HDR(184),
1104     CHARLIKE_HDR(185),
1105     CHARLIKE_HDR(186),
1106     CHARLIKE_HDR(187),
1107     CHARLIKE_HDR(188),
1108     CHARLIKE_HDR(189),
1109     CHARLIKE_HDR(190),
1110     CHARLIKE_HDR(191),
1111     CHARLIKE_HDR(192),
1112     CHARLIKE_HDR(193),
1113     CHARLIKE_HDR(194),
1114     CHARLIKE_HDR(195),
1115     CHARLIKE_HDR(196),
1116     CHARLIKE_HDR(197),
1117     CHARLIKE_HDR(198),
1118     CHARLIKE_HDR(199),
1119     CHARLIKE_HDR(200),
1120     CHARLIKE_HDR(201),
1121     CHARLIKE_HDR(202),
1122     CHARLIKE_HDR(203),
1123     CHARLIKE_HDR(204),
1124     CHARLIKE_HDR(205),
1125     CHARLIKE_HDR(206),
1126     CHARLIKE_HDR(207),
1127     CHARLIKE_HDR(208),
1128     CHARLIKE_HDR(209),
1129     CHARLIKE_HDR(210),
1130     CHARLIKE_HDR(211),
1131     CHARLIKE_HDR(212),
1132     CHARLIKE_HDR(213),
1133     CHARLIKE_HDR(214),
1134     CHARLIKE_HDR(215),
1135     CHARLIKE_HDR(216),
1136     CHARLIKE_HDR(217),
1137     CHARLIKE_HDR(218),
1138     CHARLIKE_HDR(219),
1139     CHARLIKE_HDR(220),
1140     CHARLIKE_HDR(221),
1141     CHARLIKE_HDR(222),
1142     CHARLIKE_HDR(223),
1143     CHARLIKE_HDR(224),
1144     CHARLIKE_HDR(225),
1145     CHARLIKE_HDR(226),
1146     CHARLIKE_HDR(227),
1147     CHARLIKE_HDR(228),
1148     CHARLIKE_HDR(229),
1149     CHARLIKE_HDR(230),
1150     CHARLIKE_HDR(231),
1151     CHARLIKE_HDR(232),
1152     CHARLIKE_HDR(233),
1153     CHARLIKE_HDR(234),
1154     CHARLIKE_HDR(235),
1155     CHARLIKE_HDR(236),
1156     CHARLIKE_HDR(237),
1157     CHARLIKE_HDR(238),
1158     CHARLIKE_HDR(239),
1159     CHARLIKE_HDR(240),
1160     CHARLIKE_HDR(241),
1161     CHARLIKE_HDR(242),
1162     CHARLIKE_HDR(243),
1163     CHARLIKE_HDR(244),
1164     CHARLIKE_HDR(245),
1165     CHARLIKE_HDR(246),
1166     CHARLIKE_HDR(247),
1167     CHARLIKE_HDR(248),
1168     CHARLIKE_HDR(249),
1169     CHARLIKE_HDR(250),
1170     CHARLIKE_HDR(251),
1171     CHARLIKE_HDR(252),
1172     CHARLIKE_HDR(253),
1173     CHARLIKE_HDR(254),
1174     CHARLIKE_HDR(255)
1175 };
1176
1177 StgIntCharlikeClosure stg_INTLIKE_closure[] = {
1178     INTLIKE_HDR(-16),   /* MIN_INTLIKE == -16 */
1179     INTLIKE_HDR(-15),
1180     INTLIKE_HDR(-14),
1181     INTLIKE_HDR(-13),
1182     INTLIKE_HDR(-12),
1183     INTLIKE_HDR(-11),
1184     INTLIKE_HDR(-10),
1185     INTLIKE_HDR(-9),
1186     INTLIKE_HDR(-8),
1187     INTLIKE_HDR(-7),
1188     INTLIKE_HDR(-6),
1189     INTLIKE_HDR(-5),
1190     INTLIKE_HDR(-4),
1191     INTLIKE_HDR(-3),
1192     INTLIKE_HDR(-2),
1193     INTLIKE_HDR(-1),
1194     INTLIKE_HDR(0),
1195     INTLIKE_HDR(1),
1196     INTLIKE_HDR(2),
1197     INTLIKE_HDR(3),
1198     INTLIKE_HDR(4),
1199     INTLIKE_HDR(5),
1200     INTLIKE_HDR(6),
1201     INTLIKE_HDR(7),
1202     INTLIKE_HDR(8),
1203     INTLIKE_HDR(9),
1204     INTLIKE_HDR(10),
1205     INTLIKE_HDR(11),
1206     INTLIKE_HDR(12),
1207     INTLIKE_HDR(13),
1208     INTLIKE_HDR(14),
1209     INTLIKE_HDR(15),
1210     INTLIKE_HDR(16)     /* MAX_INTLIKE == 16 */
1211 };