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