Reorganisation of the source tree
[ghc.git] / rts / StgMiscClosures.cmm
1 /* ----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 1998-2004
4  *
5  * Entry code for various built-in closure types.
6  *
7  * This file is written in a subset of C--, extended with various
8  * features specific to GHC.  It is compiled by GHC directly.  For the
9  * syntax of .cmm files, see the parser in ghc/compiler/cmm/CmmParse.y.
10  *
11  * --------------------------------------------------------------------------*/
12
13 #include "Cmm.h"
14
15 /* ----------------------------------------------------------------------------
16    Support for the bytecode interpreter.
17    ------------------------------------------------------------------------- */
18
19 /* 9 bits of return code for constructors created by the interpreter. */
20 stg_interp_constr_entry
21
22     /* R1 points at the constructor */
23     jump %ENTRY_CODE(Sp(0));
24 }
25
26 stg_interp_constr1_entry { jump %RET_VEC(Sp(0),0); }
27 stg_interp_constr2_entry { jump %RET_VEC(Sp(0),1); }
28 stg_interp_constr3_entry { jump %RET_VEC(Sp(0),2); }
29 stg_interp_constr4_entry { jump %RET_VEC(Sp(0),3); }
30 stg_interp_constr5_entry { jump %RET_VEC(Sp(0),4); }
31 stg_interp_constr6_entry { jump %RET_VEC(Sp(0),5); }
32 stg_interp_constr7_entry { jump %RET_VEC(Sp(0),6); }
33 stg_interp_constr8_entry { jump %RET_VEC(Sp(0),7); }
34
35 /* Some info tables to be used when compiled code returns a value to
36    the interpreter, i.e. the interpreter pushes one of these onto the
37    stack before entering a value.  What the code does is to
38    impedance-match the compiled return convention (in R1p/R1n/F1/D1 etc) to
39    the interpreter's convention (returned value is on top of stack),
40    and then cause the scheduler to enter the interpreter.
41
42    On entry, the stack (growing down) looks like this:
43
44       ptr to BCO holding return continuation
45       ptr to one of these info tables.
46  
47    The info table code, both direct and vectored, must:
48       * push R1/F1/D1 on the stack, and its tag if necessary
49       * push the BCO (so it's now on the stack twice)
50       * Yield, ie, go to the scheduler.
51
52    Scheduler examines the t.o.s, discovers it is a BCO, and proceeds
53    directly to the bytecode interpreter.  That pops the top element
54    (the BCO, containing the return continuation), and interprets it.
55    Net result: return continuation gets interpreted, with the
56    following stack:
57
58       ptr to this BCO
59       ptr to the info table just jumped thru
60       return value
61
62    which is just what we want -- the "standard" return layout for the
63    interpreter.  Hurrah!
64
65    Don't ask me how unboxed tuple returns are supposed to work.  We
66    haven't got a good story about that yet.
67 */
68
69 INFO_TABLE_RET( stg_ctoi_R1p, 
70                 0/*size*/, 0/*bitmap*/,    /* special layout! */
71                 RET_BCO,
72                 RET_LBL(stg_ctoi_R1p),
73                 RET_LBL(stg_ctoi_R1p),
74                 RET_LBL(stg_ctoi_R1p),
75                 RET_LBL(stg_ctoi_R1p),
76                 RET_LBL(stg_ctoi_R1p),
77                 RET_LBL(stg_ctoi_R1p),
78                 RET_LBL(stg_ctoi_R1p),
79                 RET_LBL(stg_ctoi_R1p))
80 {
81     Sp_adj(-2);
82     Sp(1) = R1;
83     Sp(0) = stg_enter_info;
84     jump stg_yield_to_interpreter;
85 }
86
87 #if MAX_VECTORED_RTN != 8
88 #error MAX_VECTORED_RTN has changed: please modify stg_ctoi_R1p too.
89 #endif
90
91 /*
92  * When the returned value is a pointer, but unlifted, in R1 ... 
93  */
94 INFO_TABLE_RET( stg_ctoi_R1unpt,
95                 0/*size*/, 0/*bitmap*/,    /* special layout! */
96                 RET_BCO )
97 {
98     Sp_adj(-2);
99     Sp(1) = R1;
100     Sp(0) = stg_gc_unpt_r1_info;
101     jump stg_yield_to_interpreter;
102 }
103
104 /*
105  * When the returned value is a non-pointer in R1 ...
106  */
107 INFO_TABLE_RET( stg_ctoi_R1n,
108                 0/*size*/, 0/*bitmap*/,    /* special layout! */
109                 RET_BCO )
110 {
111     Sp_adj(-2);
112     Sp(1) = R1;
113     Sp(0) = stg_gc_unbx_r1_info;
114     jump stg_yield_to_interpreter;
115 }
116
117 /*
118  * When the returned value is in F1
119  */
120 INFO_TABLE_RET( stg_ctoi_F1,
121                 0/*size*/, 0/*bitmap*/,    /* special layout! */
122                 RET_BCO )
123 {
124     Sp_adj(-2);
125     F_[Sp + WDS(1)] = F1;
126     Sp(0) = stg_gc_f1_info;
127     jump stg_yield_to_interpreter;
128 }
129
130 /*
131  * When the returned value is in D1
132  */
133 INFO_TABLE_RET( stg_ctoi_D1,
134                 0/*size*/, 0/*bitmap*/,    /* special layout! */
135                 RET_BCO )
136 {
137     Sp_adj(-1) - SIZEOF_DOUBLE;
138     D_[Sp + WDS(1)] = D1;
139     Sp(0) = stg_gc_d1_info;
140     jump stg_yield_to_interpreter;
141 }
142
143 /*
144  * When the returned value is in L1
145  */
146 INFO_TABLE_RET( stg_ctoi_L1,
147                 0/*size*/, 0/*bitmap*/,    /* special layout! */
148                 RET_BCO )
149 {
150     Sp_adj(-1) - 8;
151     L_[Sp + WDS(1)] = L1;
152     Sp(0) = stg_gc_l1_info;
153     jump stg_yield_to_interpreter;
154 }
155
156 /*
157  * When the returned value is a void
158  */
159 INFO_TABLE_RET( stg_ctoi_V,
160                 0/*size*/, 0/*bitmap*/,    /* special layout! */
161                 RET_BCO )
162 {
163     Sp_adj(-1);
164     Sp(0) = stg_gc_void_info;
165     jump stg_yield_to_interpreter;
166 }
167
168 /*
169  * Dummy info table pushed on the top of the stack when the interpreter
170  * should apply the BCO on the stack to its arguments, also on the
171  * stack.
172  */
173 INFO_TABLE_RET( stg_apply_interp,
174                 0/*size*/, 0/*bitmap*/,    /* special layout! */
175                 RET_BCO )
176 {
177     /* Just in case we end up in here... (we shouldn't) */
178     jump stg_yield_to_interpreter;
179 }
180
181 /* ----------------------------------------------------------------------------
182    Entry code for a BCO
183    ------------------------------------------------------------------------- */
184
185 INFO_TABLE_FUN( stg_BCO, 4, 0, BCO, "BCO", "BCO", ARG_BCO )
186 {
187   /* entering a BCO means "apply it", same as a function */
188   Sp_adj(-2);
189   Sp(1) = R1;
190   Sp(0) = stg_apply_interp_info;
191   jump stg_yield_to_interpreter;
192 }
193
194 /* ----------------------------------------------------------------------------
195    Info tables for indirections.
196
197    SPECIALISED INDIRECTIONS: we have a specialised indirection for each
198    kind of return (direct, vectored 0-7), so that we can avoid entering
199    the object when we know what kind of return it will do.  The update
200    code (Updates.hc) updates objects with the appropriate kind of
201    indirection.  We only do this for young-gen indirections.
202    ------------------------------------------------------------------------- */
203
204 INFO_TABLE(stg_IND,1,0,IND,"IND","IND")
205 {
206     TICK_ENT_DYN_IND(); /* tick */
207     R1 = StgInd_indirectee(R1);
208     TICK_ENT_VIA_NODE();
209     jump %GET_ENTRY(R1);
210 }
211
212 #define IND_SPEC(label,ret) \
213 INFO_TABLE(label,1,0,IND,"IND","IND") \
214 {                                               \
215     TICK_ENT_DYN_IND(); /* tick */              \
216     R1 = StgInd_indirectee(R1);                 \
217     TICK_ENT_VIA_NODE();                        \
218     jump ret;                                   \
219 }
220
221 IND_SPEC(stg_IND_direct, %ENTRY_CODE(Sp(0)))
222 IND_SPEC(stg_IND_0, %RET_VEC(Sp(0),0))
223 IND_SPEC(stg_IND_1, %RET_VEC(Sp(0),1))
224 IND_SPEC(stg_IND_2, %RET_VEC(Sp(0),2))
225 IND_SPEC(stg_IND_3, %RET_VEC(Sp(0),3))
226 IND_SPEC(stg_IND_4, %RET_VEC(Sp(0),4))
227 IND_SPEC(stg_IND_5, %RET_VEC(Sp(0),5))
228 IND_SPEC(stg_IND_6, %RET_VEC(Sp(0),6))
229 IND_SPEC(stg_IND_7, %RET_VEC(Sp(0),7))
230
231 INFO_TABLE(stg_IND_STATIC,1,0,IND_STATIC,"IND_STATIC","IND_STATIC")
232 {
233     TICK_ENT_STATIC_IND();      /* tick */
234     R1 = StgInd_indirectee(R1);
235     TICK_ENT_VIA_NODE();
236     jump %GET_ENTRY(R1);
237 }
238
239 INFO_TABLE(stg_IND_PERM,1,0,IND_PERM,"IND_PERM","IND_PERM")
240 {
241     /* Don't add INDs to granularity cost */
242
243     /* Don't: TICK_ENT_STATIC_IND(Node); for ticky-ticky; this ind is
244        here only to help profiling */
245
246 #if defined(TICKY_TICKY) && !defined(PROFILING)
247     /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, rather than
248        being extra  */
249     TICK_ENT_PERM_IND();
250 #endif
251
252     LDV_ENTER(R1);
253
254     /* Enter PAP cost centre */
255     ENTER_CCS_PAP_CL(R1);
256
257     /* For ticky-ticky, change the perm_ind to a normal ind on first
258      * entry, so the number of ent_perm_inds is the number of *thunks*
259      * entered again, not the number of subsequent entries.
260      *
261      * Since this screws up cost centres, we die if profiling and
262      * ticky_ticky are on at the same time.  KSW 1999-01.
263      */
264 #ifdef TICKY_TICKY
265 #  ifdef PROFILING
266 #    error Profiling and ticky-ticky do not mix at present!
267 #  endif  /* PROFILING */
268     StgHeader_info(R1) = stg_IND_info;
269 #endif /* TICKY_TICKY */
270
271     R1 = StgInd_indirectee(R1);
272
273 #if defined(TICKY_TICKY) && !defined(PROFILING)
274     TICK_ENT_VIA_NODE();
275 #endif
276
277     jump %GET_ENTRY(R1);
278 }  
279
280
281 INFO_TABLE(stg_IND_OLDGEN,1,0,IND_OLDGEN,"IND_OLDGEN","IND_OLDGEN")
282 {
283     TICK_ENT_STATIC_IND();      /* tick */
284     R1 = StgInd_indirectee(R1);
285     TICK_ENT_VIA_NODE();
286     jump %GET_ENTRY(R1);
287 }
288
289 INFO_TABLE(stg_IND_OLDGEN_PERM,1,0,IND_OLDGEN_PERM,"IND_OLDGEN_PERM","IND_OLDGEN_PERM")
290 {
291     /* Don't: TICK_ENT_STATIC_IND(Node); for ticky-ticky; 
292        this ind is here only to help profiling */
293
294 #if defined(TICKY_TICKY) && !defined(PROFILING)
295     /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, 
296        rather than being extra  */
297     TICK_ENT_PERM_IND(R1); /* tick */
298 #endif
299
300     LDV_ENTER(R1);
301
302     /* Enter PAP cost centre -- lexical scoping only */
303     ENTER_CCS_PAP_CL(R1);
304
305     /* see comment in IND_PERM */
306 #ifdef TICKY_TICKY
307 #  ifdef PROFILING
308 #    error Profiling and ticky-ticky do not mix at present!
309 #  endif  /* PROFILING */
310     StgHeader_info(R1) = stg_IND_OLDGEN_info;
311 #endif /* TICKY_TICKY */
312
313     R1 = StgInd_indirectee(R1);
314
315     TICK_ENT_VIA_NODE();
316     jump %GET_ENTRY(R1);
317 }
318
319 /* ----------------------------------------------------------------------------
320    Black holes.
321
322    Entering a black hole normally causes a cyclic data dependency, but
323    in the concurrent world, black holes are synchronization points,
324    and they are turned into blocking queues when there are threads
325    waiting for the evaluation of the closure to finish.
326    ------------------------------------------------------------------------- */
327
328 /* Note: a BLACKHOLE must be big enough to be
329  * overwritten with an indirection/evacuee/catch.  Thus we claim it
330  * has 1 non-pointer word of payload. 
331  */
332 INFO_TABLE(stg_BLACKHOLE,0,1,BLACKHOLE,"BLACKHOLE","BLACKHOLE")
333 {
334 #if defined(GRAN)
335     /* Before overwriting TSO_LINK */
336     STGCALL3(GranSimBlock,CurrentTSO,CurrentProc,(StgClosure *)R1 /*Node*/);
337 #endif
338
339     TICK_ENT_BH();
340
341 #ifdef THREADED_RTS
342     // foreign "C" debugBelch("BLACKHOLE entry\n");
343 #endif
344
345     /* Actually this is not necessary because R1 is about to be destroyed. */
346     LDV_ENTER(R1);
347
348 #if defined(THREADED_RTS)
349     foreign "C" ACQUIRE_LOCK(sched_mutex "ptr");
350     // released in stg_block_blackhole_finally
351 #endif
352
353     /* Put ourselves on the blackhole queue */
354     StgTSO_link(CurrentTSO) = W_[blackhole_queue];
355     W_[blackhole_queue] = CurrentTSO;
356
357     /* jot down why and on what closure we are blocked */
358     StgTSO_why_blocked(CurrentTSO) = BlockedOnBlackHole::I16;
359     StgTSO_block_info(CurrentTSO) = R1;
360
361     jump stg_block_blackhole;
362 }
363
364 #if defined(PAR) || defined(GRAN)
365
366 INFO_TABLE(stg_RBH,1,1,RBH,"RBH","RBH")
367 {
368 # if defined(GRAN)
369     /* mainly statistics gathering for GranSim simulation */
370     STGCALL3(GranSimBlock,CurrentTSO,CurrentProc,(StgClosure *)R1 /*Node*/);
371 # endif
372
373     /* exactly the same as a BLACKHOLE_BQ_entry -- HWL */
374     /* Put ourselves on the blocking queue for this black hole */
375     TSO_link(CurrentTSO) = StgBlockingQueue_blocking_queue(R1);
376     StgBlockingQueue_blocking_queue(R1) = CurrentTSO;
377     /* jot down why and on what closure we are blocked */
378     TSO_why_blocked(CurrentTSO) = BlockedOnBlackHole::I16;
379     TSO_block_info(CurrentTSO) = R1;
380
381     /* PAR: dumping of event now done in blockThread -- HWL */
382
383     /* stg_gen_block is too heavyweight, use a specialised one */
384     jump stg_block_1;
385 }
386
387 INFO_TABLE(stg_RBH_Save_0,0,2,CONSTR,"RBH_Save_0","RBH_Save_0")
388 { foreign "C" barf("RBH_Save_0 object entered!"); }
389
390 INFO_TABLE(stg_RBH_Save_1,1,1,CONSTR,"RBH_Save_1","RBH_Save_1");
391 { foreign "C" barf("RBH_Save_1 object entered!"); }
392
393 INFO_TABLE(stg_RBH_Save_2,2,0,CONSTR,"RBH_Save_2","RBH_Save_2");
394 { foreign "C" barf("RBH_Save_2 object entered!"); }
395
396 #endif /* defined(PAR) || defined(GRAN) */
397
398 /* identical to BLACKHOLEs except for the infotag */
399 INFO_TABLE(stg_CAF_BLACKHOLE,0,1,CAF_BLACKHOLE,"CAF_BLACKHOLE","CAF_BLACKHOLE")
400 {
401 #if defined(GRAN)
402     /* mainly statistics gathering for GranSim simulation */
403     STGCALL3(GranSimBlock,CurrentTSO,CurrentProc,(StgClosure *)R1 /*Node*/);
404 #endif
405
406     TICK_ENT_BH();
407     LDV_ENTER(R1);
408
409 #if defined(THREADED_RTS)
410     // foreign "C" debugBelch("BLACKHOLE entry\n");
411 #endif
412
413 #if defined(THREADED_RTS)
414     foreign "C" ACQUIRE_LOCK(sched_mutex "ptr");
415     // released in stg_block_blackhole_finally
416 #endif
417
418     /* Put ourselves on the blackhole queue */
419     StgTSO_link(CurrentTSO) = W_[blackhole_queue];
420     W_[blackhole_queue] = CurrentTSO;
421
422     /* jot down why and on what closure we are blocked */
423     StgTSO_why_blocked(CurrentTSO) = BlockedOnBlackHole::I16;
424     StgTSO_block_info(CurrentTSO) = R1;
425
426     jump stg_block_blackhole;
427 }
428
429 #ifdef EAGER_BLACKHOLING
430 INFO_TABLE(stg_SE_BLACKHOLE,0,1,SE_BLACKHOLE,"SE_BLACKHOLE","SE_BLACKHOLE")
431 { foreign "C" barf("SE_BLACKHOLE object entered!"); }
432
433 INFO_TABLE(stg_SE_CAF_BLACKHOLE,0,1,SE_CAF_BLACKHOLE,"SE_CAF_BLACKHOLE","SE_CAF_BLACKHOLE")
434 { foreign "C" barf("SE_CAF_BLACKHOLE object entered!"); }
435 #endif
436
437 /* ----------------------------------------------------------------------------
438    Whiteholes are used for the "locked" state of a closure (see lockClosure())
439
440    The closure type is BLAKCHOLE, just because we need a valid closure type
441    for sanity checking.
442    ------------------------------------------------------------------------- */
443
444 INFO_TABLE(stg_WHITEHOLE, 0,0, BLACKHOLE, "WHITEHOLE", "WHITEHOLE")
445 { foreign "C" barf("WHITEHOLE object entered!"); }
446
447 /* ----------------------------------------------------------------------------
448    Some static info tables for things that don't get entered, and
449    therefore don't need entry code (i.e. boxed but unpointed objects)
450    NON_ENTERABLE_ENTRY_CODE now defined at the beginning of the file
451    ------------------------------------------------------------------------- */
452
453 INFO_TABLE(stg_TSO, 0,0,TSO, "TSO", "TSO")
454 { foreign "C" barf("TSO object entered!"); }
455
456 /* ----------------------------------------------------------------------------
457    Evacuees are left behind by the garbage collector.  Any attempt to enter
458    one is a real bug.
459    ------------------------------------------------------------------------- */
460
461 INFO_TABLE(stg_EVACUATED,1,0,EVACUATED,"EVACUATED","EVACUATED")
462 { foreign "C" barf("EVACUATED object entered!"); }
463
464 /* ----------------------------------------------------------------------------
465    Weak pointers
466
467    Live weak pointers have a special closure type.  Dead ones are just
468    nullary constructors (although they live on the heap - we overwrite
469    live weak pointers with dead ones).
470    ------------------------------------------------------------------------- */
471
472 INFO_TABLE(stg_WEAK,0,4,WEAK,"WEAK","WEAK")
473 { foreign "C" barf("WEAK object entered!"); }
474
475 /*
476  * It's important when turning an existing WEAK into a DEAD_WEAK
477  * (which is what finalizeWeak# does) that we don't lose the link
478  * field and break the linked list of weak pointers.  Hence, we give
479  * DEAD_WEAK 4 non-pointer fields, the same as WEAK.
480  */
481 INFO_TABLE_CONSTR(stg_DEAD_WEAK,0,4,0,CONSTR,"DEAD_WEAK","DEAD_WEAK")
482 { foreign "C" barf("DEAD_WEAK object entered!"); }
483
484 /* ----------------------------------------------------------------------------
485    NO_FINALIZER
486
487    This is a static nullary constructor (like []) that we use to mark an empty
488    finalizer in a weak pointer object.
489    ------------------------------------------------------------------------- */
490
491 INFO_TABLE_CONSTR(stg_NO_FINALIZER,0,0,0,CONSTR_NOCAF_STATIC,"NO_FINALIZER","NO_FINALIZER")
492 { foreign "C" barf("NO_FINALIZER object entered!"); }
493
494 CLOSURE(stg_NO_FINALIZER_closure,stg_NO_FINALIZER);
495
496 /* ----------------------------------------------------------------------------
497    Stable Names are unlifted too.
498    ------------------------------------------------------------------------- */
499
500 INFO_TABLE(stg_STABLE_NAME,0,1,STABLE_NAME,"STABLE_NAME","STABLE_NAME")
501 { foreign "C" barf("STABLE_NAME object entered!"); }
502
503 /* ----------------------------------------------------------------------------
504    MVars
505
506    There are two kinds of these: full and empty.  We need an info table
507    and entry code for each type.
508    ------------------------------------------------------------------------- */
509
510 INFO_TABLE(stg_FULL_MVAR,3,0,MVAR,"MVAR","MVAR")
511 { foreign "C" barf("FULL_MVAR object entered!"); }
512
513 INFO_TABLE(stg_EMPTY_MVAR,3,0,MVAR,"MVAR","MVAR")
514 { foreign "C" barf("EMPTY_MVAR object entered!"); }
515
516 /* -----------------------------------------------------------------------------
517    STM
518    -------------------------------------------------------------------------- */
519
520 INFO_TABLE(stg_TVAR, 0, 0, TVAR, "TVAR", "TVAR")
521 { foreign "C" barf("TVAR object entered!"); }
522
523 INFO_TABLE(stg_TVAR_WAIT_QUEUE, 0, 0, TVAR_WAIT_QUEUE, "TVAR_WAIT_QUEUE", "TVAR_WAIT_QUEUE")
524 { foreign "C" barf("TVAR_WAIT_QUEUE object entered!"); }
525
526 INFO_TABLE(stg_TREC_CHUNK, 0, 0, TREC_CHUNK, "TREC_CHUNK", "TREC_CHUNK")
527 { foreign "C" barf("TREC_CHUNK object entered!"); }
528
529 INFO_TABLE(stg_TREC_HEADER, 0, 0, TREC_HEADER, "TREC_HEADER", "TREC_HEADER")
530 { foreign "C" barf("TREC_HEADER object entered!"); }
531
532 INFO_TABLE_CONSTR(stg_END_STM_WAIT_QUEUE,0,0,0,CONSTR_NOCAF_STATIC,"END_STM_WAIT_QUEUE","END_STM_WAIT_QUEUE")
533 { foreign "C" barf("END_STM_WAIT_QUEUE object entered!"); }
534
535 INFO_TABLE_CONSTR(stg_END_STM_CHUNK_LIST,0,0,0,CONSTR_NOCAF_STATIC,"END_STM_CHUNK_LIST","END_STM_CHUNK_LIST")
536 { foreign "C" barf("END_STM_CHUNK_LIST object entered!"); }
537
538 INFO_TABLE_CONSTR(stg_NO_TREC,0,0,0,CONSTR_NOCAF_STATIC,"NO_TREC","NO_TREC")
539 { foreign "C" barf("NO_TREC object entered!"); }
540
541 CLOSURE(stg_END_STM_WAIT_QUEUE_closure,stg_END_STM_WAIT_QUEUE);
542
543 CLOSURE(stg_END_STM_CHUNK_LIST_closure,stg_END_STM_CHUNK_LIST);
544
545 CLOSURE(stg_NO_TREC_closure,stg_NO_TREC);
546
547 /* ----------------------------------------------------------------------------
548    END_TSO_QUEUE
549
550    This is a static nullary constructor (like []) that we use to mark the
551    end of a linked TSO queue.
552    ------------------------------------------------------------------------- */
553
554 INFO_TABLE_CONSTR(stg_END_TSO_QUEUE,0,0,0,CONSTR_NOCAF_STATIC,"END_TSO_QUEUE","END_TSO_QUEUE")
555 { foreign "C" barf("END_TSO_QUEUE object entered!"); }
556
557 CLOSURE(stg_END_TSO_QUEUE_closure,stg_END_TSO_QUEUE);
558
559 /* ----------------------------------------------------------------------------
560    Exception lists
561    ------------------------------------------------------------------------- */
562
563 INFO_TABLE_CONSTR(stg_END_EXCEPTION_LIST,0,0,0,CONSTR_NOCAF_STATIC,"END_EXCEPTION_LIST","END_EXCEPTION_LIST")
564 { foreign "C" barf("END_EXCEPTION_LIST object entered!"); }
565
566 CLOSURE(stg_END_EXCEPTION_LIST_closure,stg_END_EXCEPTION_LIST);
567
568 INFO_TABLE(stg_EXCEPTION_CONS,1,1,CONSTR,"EXCEPTION_CONS","EXCEPTION_CONS")
569 { foreign "C" barf("EXCEPTION_CONS object entered!"); }
570
571 /* ----------------------------------------------------------------------------
572    Arrays
573
574    These come in two basic flavours: arrays of data (StgArrWords) and arrays of
575    pointers (StgArrPtrs).  They all have a similar layout:
576
577         ___________________________
578         | Info | No. of | data....
579         |  Ptr | Words  |
580         ---------------------------
581
582    These are *unpointed* objects: i.e. they cannot be entered.
583
584    ------------------------------------------------------------------------- */
585
586 INFO_TABLE(stg_ARR_WORDS, 0, 0, ARR_WORDS, "ARR_WORDS", "ARR_WORDS")
587 { foreign "C" barf("ARR_WORDS object entered!"); }
588
589 INFO_TABLE(stg_MUT_ARR_PTRS_CLEAN, 0, 0, MUT_ARR_PTRS_CLEAN, "MUT_ARR_PTRS_CLEAN", "MUT_ARR_PTRS_CLEAN")
590 { foreign "C" barf("MUT_ARR_PTRS_CLEAN object entered!"); }
591
592 INFO_TABLE(stg_MUT_ARR_PTRS_DIRTY, 0, 0, MUT_ARR_PTRS_DIRTY, "MUT_ARR_PTRS_DIRTY", "MUT_ARR_PTRS_DIRTY")
593 { foreign "C" barf("MUT_ARR_PTRS_DIRTY object entered!"); }
594
595 INFO_TABLE(stg_MUT_ARR_PTRS_FROZEN, 0, 0, MUT_ARR_PTRS_FROZEN, "MUT_ARR_PTRS_FROZEN", "MUT_ARR_PTRS_FROZEN")
596 { foreign "C" barf("MUT_ARR_PTRS_FROZEN object entered!"); }
597
598 INFO_TABLE(stg_MUT_ARR_PTRS_FROZEN0, 0, 0, MUT_ARR_PTRS_FROZEN0, "MUT_ARR_PTRS_FROZEN0", "MUT_ARR_PTRS_FROZEN0")
599 { foreign "C" barf("MUT_ARR_PTRS_FROZEN0 object entered!"); }
600
601 /* ----------------------------------------------------------------------------
602    Mutable Variables
603    ------------------------------------------------------------------------- */
604
605 INFO_TABLE(stg_MUT_VAR_CLEAN, 1, 0, MUT_VAR_CLEAN, "MUT_VAR_CLEAN", "MUT_VAR_CLEAN")
606 { foreign "C" barf("MUT_VAR_CLEAN object entered!"); }
607 INFO_TABLE(stg_MUT_VAR_DIRTY, 1, 0, MUT_VAR_DIRTY, "MUT_VAR_DIRTY", "MUT_VAR_DIRTY")
608 { foreign "C" barf("MUT_VAR_DIRTY object entered!"); }
609
610 /* ----------------------------------------------------------------------------
611    Dummy return closure
612  
613    Entering this closure will just return to the address on the top of the
614    stack.  Useful for getting a thread in a canonical form where we can
615    just enter the top stack word to start the thread.  (see deleteThread)
616  * ------------------------------------------------------------------------- */
617
618 INFO_TABLE( stg_dummy_ret, 0, 0, CONSTR_NOCAF_STATIC, "DUMMY_RET", "DUMMY_RET")
619 {
620   jump %ENTRY_CODE(Sp(0));
621 }
622 CLOSURE(stg_dummy_ret_closure,stg_dummy_ret);
623
624 /* ----------------------------------------------------------------------------
625    CHARLIKE and INTLIKE closures.  
626
627    These are static representations of Chars and small Ints, so that
628    we can remove dynamic Chars and Ints during garbage collection and
629    replace them with references to the static objects.
630    ------------------------------------------------------------------------- */
631
632 #if defined(ENABLE_WIN32_DLL_SUPPORT)
633 /*
634  * When sticking the RTS in a DLL, we delay populating the
635  * Charlike and Intlike tables until load-time, which is only
636  * when we've got the real addresses to the C# and I# closures.
637  *
638  */
639 static INFO_TBL_CONST StgInfoTable czh_static_info;
640 static INFO_TBL_CONST StgInfoTable izh_static_info;
641 #define Char_hash_static_info czh_static_info
642 #define Int_hash_static_info izh_static_info
643 #else
644 #define Char_hash_static_info GHCziBase_Czh_static
645 #define Int_hash_static_info GHCziBase_Izh_static
646 #endif
647
648
649 #define CHARLIKE_HDR(n)  CLOSURE(Char_hash_static_info, n)
650 #define INTLIKE_HDR(n)   CLOSURE(Int_hash_static_info, n)
651
652 /* put these in the *data* section, since the garbage collector relies
653  * on the fact that static closures live in the data section.
654  */
655
656 /* end the name with _closure, to convince the mangler this is a closure */
657
658 section "data" {
659  stg_CHARLIKE_closure:
660     CHARLIKE_HDR(0)
661     CHARLIKE_HDR(1)
662     CHARLIKE_HDR(2)
663     CHARLIKE_HDR(3)
664     CHARLIKE_HDR(4)
665     CHARLIKE_HDR(5)
666     CHARLIKE_HDR(6)
667     CHARLIKE_HDR(7)
668     CHARLIKE_HDR(8)
669     CHARLIKE_HDR(9)
670     CHARLIKE_HDR(10)
671     CHARLIKE_HDR(11)
672     CHARLIKE_HDR(12)
673     CHARLIKE_HDR(13)
674     CHARLIKE_HDR(14)
675     CHARLIKE_HDR(15)
676     CHARLIKE_HDR(16)
677     CHARLIKE_HDR(17)
678     CHARLIKE_HDR(18)
679     CHARLIKE_HDR(19)
680     CHARLIKE_HDR(20)
681     CHARLIKE_HDR(21)
682     CHARLIKE_HDR(22)
683     CHARLIKE_HDR(23)
684     CHARLIKE_HDR(24)
685     CHARLIKE_HDR(25)
686     CHARLIKE_HDR(26)
687     CHARLIKE_HDR(27)
688     CHARLIKE_HDR(28)
689     CHARLIKE_HDR(29)
690     CHARLIKE_HDR(30)
691     CHARLIKE_HDR(31)
692     CHARLIKE_HDR(32)
693     CHARLIKE_HDR(33)
694     CHARLIKE_HDR(34)
695     CHARLIKE_HDR(35)
696     CHARLIKE_HDR(36)
697     CHARLIKE_HDR(37)
698     CHARLIKE_HDR(38)
699     CHARLIKE_HDR(39)
700     CHARLIKE_HDR(40)
701     CHARLIKE_HDR(41)
702     CHARLIKE_HDR(42)
703     CHARLIKE_HDR(43)
704     CHARLIKE_HDR(44)
705     CHARLIKE_HDR(45)
706     CHARLIKE_HDR(46)
707     CHARLIKE_HDR(47)
708     CHARLIKE_HDR(48)
709     CHARLIKE_HDR(49)
710     CHARLIKE_HDR(50)
711     CHARLIKE_HDR(51)
712     CHARLIKE_HDR(52)
713     CHARLIKE_HDR(53)
714     CHARLIKE_HDR(54)
715     CHARLIKE_HDR(55)
716     CHARLIKE_HDR(56)
717     CHARLIKE_HDR(57)
718     CHARLIKE_HDR(58)
719     CHARLIKE_HDR(59)
720     CHARLIKE_HDR(60)
721     CHARLIKE_HDR(61)
722     CHARLIKE_HDR(62)
723     CHARLIKE_HDR(63)
724     CHARLIKE_HDR(64)
725     CHARLIKE_HDR(65)
726     CHARLIKE_HDR(66)
727     CHARLIKE_HDR(67)
728     CHARLIKE_HDR(68)
729     CHARLIKE_HDR(69)
730     CHARLIKE_HDR(70)
731     CHARLIKE_HDR(71)
732     CHARLIKE_HDR(72)
733     CHARLIKE_HDR(73)
734     CHARLIKE_HDR(74)
735     CHARLIKE_HDR(75)
736     CHARLIKE_HDR(76)
737     CHARLIKE_HDR(77)
738     CHARLIKE_HDR(78)
739     CHARLIKE_HDR(79)
740     CHARLIKE_HDR(80)
741     CHARLIKE_HDR(81)
742     CHARLIKE_HDR(82)
743     CHARLIKE_HDR(83)
744     CHARLIKE_HDR(84)
745     CHARLIKE_HDR(85)
746     CHARLIKE_HDR(86)
747     CHARLIKE_HDR(87)
748     CHARLIKE_HDR(88)
749     CHARLIKE_HDR(89)
750     CHARLIKE_HDR(90)
751     CHARLIKE_HDR(91)
752     CHARLIKE_HDR(92)
753     CHARLIKE_HDR(93)
754     CHARLIKE_HDR(94)
755     CHARLIKE_HDR(95)
756     CHARLIKE_HDR(96)
757     CHARLIKE_HDR(97)
758     CHARLIKE_HDR(98)
759     CHARLIKE_HDR(99)
760     CHARLIKE_HDR(100)
761     CHARLIKE_HDR(101)
762     CHARLIKE_HDR(102)
763     CHARLIKE_HDR(103)
764     CHARLIKE_HDR(104)
765     CHARLIKE_HDR(105)
766     CHARLIKE_HDR(106)
767     CHARLIKE_HDR(107)
768     CHARLIKE_HDR(108)
769     CHARLIKE_HDR(109)
770     CHARLIKE_HDR(110)
771     CHARLIKE_HDR(111)
772     CHARLIKE_HDR(112)
773     CHARLIKE_HDR(113)
774     CHARLIKE_HDR(114)
775     CHARLIKE_HDR(115)
776     CHARLIKE_HDR(116)
777     CHARLIKE_HDR(117)
778     CHARLIKE_HDR(118)
779     CHARLIKE_HDR(119)
780     CHARLIKE_HDR(120)
781     CHARLIKE_HDR(121)
782     CHARLIKE_HDR(122)
783     CHARLIKE_HDR(123)
784     CHARLIKE_HDR(124)
785     CHARLIKE_HDR(125)
786     CHARLIKE_HDR(126)
787     CHARLIKE_HDR(127)
788     CHARLIKE_HDR(128)
789     CHARLIKE_HDR(129)
790     CHARLIKE_HDR(130)
791     CHARLIKE_HDR(131)
792     CHARLIKE_HDR(132)
793     CHARLIKE_HDR(133)
794     CHARLIKE_HDR(134)
795     CHARLIKE_HDR(135)
796     CHARLIKE_HDR(136)
797     CHARLIKE_HDR(137)
798     CHARLIKE_HDR(138)
799     CHARLIKE_HDR(139)
800     CHARLIKE_HDR(140)
801     CHARLIKE_HDR(141)
802     CHARLIKE_HDR(142)
803     CHARLIKE_HDR(143)
804     CHARLIKE_HDR(144)
805     CHARLIKE_HDR(145)
806     CHARLIKE_HDR(146)
807     CHARLIKE_HDR(147)
808     CHARLIKE_HDR(148)
809     CHARLIKE_HDR(149)
810     CHARLIKE_HDR(150)
811     CHARLIKE_HDR(151)
812     CHARLIKE_HDR(152)
813     CHARLIKE_HDR(153)
814     CHARLIKE_HDR(154)
815     CHARLIKE_HDR(155)
816     CHARLIKE_HDR(156)
817     CHARLIKE_HDR(157)
818     CHARLIKE_HDR(158)
819     CHARLIKE_HDR(159)
820     CHARLIKE_HDR(160)
821     CHARLIKE_HDR(161)
822     CHARLIKE_HDR(162)
823     CHARLIKE_HDR(163)
824     CHARLIKE_HDR(164)
825     CHARLIKE_HDR(165)
826     CHARLIKE_HDR(166)
827     CHARLIKE_HDR(167)
828     CHARLIKE_HDR(168)
829     CHARLIKE_HDR(169)
830     CHARLIKE_HDR(170)
831     CHARLIKE_HDR(171)
832     CHARLIKE_HDR(172)
833     CHARLIKE_HDR(173)
834     CHARLIKE_HDR(174)
835     CHARLIKE_HDR(175)
836     CHARLIKE_HDR(176)
837     CHARLIKE_HDR(177)
838     CHARLIKE_HDR(178)
839     CHARLIKE_HDR(179)
840     CHARLIKE_HDR(180)
841     CHARLIKE_HDR(181)
842     CHARLIKE_HDR(182)
843     CHARLIKE_HDR(183)
844     CHARLIKE_HDR(184)
845     CHARLIKE_HDR(185)
846     CHARLIKE_HDR(186)
847     CHARLIKE_HDR(187)
848     CHARLIKE_HDR(188)
849     CHARLIKE_HDR(189)
850     CHARLIKE_HDR(190)
851     CHARLIKE_HDR(191)
852     CHARLIKE_HDR(192)
853     CHARLIKE_HDR(193)
854     CHARLIKE_HDR(194)
855     CHARLIKE_HDR(195)
856     CHARLIKE_HDR(196)
857     CHARLIKE_HDR(197)
858     CHARLIKE_HDR(198)
859     CHARLIKE_HDR(199)
860     CHARLIKE_HDR(200)
861     CHARLIKE_HDR(201)
862     CHARLIKE_HDR(202)
863     CHARLIKE_HDR(203)
864     CHARLIKE_HDR(204)
865     CHARLIKE_HDR(205)
866     CHARLIKE_HDR(206)
867     CHARLIKE_HDR(207)
868     CHARLIKE_HDR(208)
869     CHARLIKE_HDR(209)
870     CHARLIKE_HDR(210)
871     CHARLIKE_HDR(211)
872     CHARLIKE_HDR(212)
873     CHARLIKE_HDR(213)
874     CHARLIKE_HDR(214)
875     CHARLIKE_HDR(215)
876     CHARLIKE_HDR(216)
877     CHARLIKE_HDR(217)
878     CHARLIKE_HDR(218)
879     CHARLIKE_HDR(219)
880     CHARLIKE_HDR(220)
881     CHARLIKE_HDR(221)
882     CHARLIKE_HDR(222)
883     CHARLIKE_HDR(223)
884     CHARLIKE_HDR(224)
885     CHARLIKE_HDR(225)
886     CHARLIKE_HDR(226)
887     CHARLIKE_HDR(227)
888     CHARLIKE_HDR(228)
889     CHARLIKE_HDR(229)
890     CHARLIKE_HDR(230)
891     CHARLIKE_HDR(231)
892     CHARLIKE_HDR(232)
893     CHARLIKE_HDR(233)
894     CHARLIKE_HDR(234)
895     CHARLIKE_HDR(235)
896     CHARLIKE_HDR(236)
897     CHARLIKE_HDR(237)
898     CHARLIKE_HDR(238)
899     CHARLIKE_HDR(239)
900     CHARLIKE_HDR(240)
901     CHARLIKE_HDR(241)
902     CHARLIKE_HDR(242)
903     CHARLIKE_HDR(243)
904     CHARLIKE_HDR(244)
905     CHARLIKE_HDR(245)
906     CHARLIKE_HDR(246)
907     CHARLIKE_HDR(247)
908     CHARLIKE_HDR(248)
909     CHARLIKE_HDR(249)
910     CHARLIKE_HDR(250)
911     CHARLIKE_HDR(251)
912     CHARLIKE_HDR(252)
913     CHARLIKE_HDR(253)
914     CHARLIKE_HDR(254)
915     CHARLIKE_HDR(255)
916 }
917
918 section "data" {
919  stg_INTLIKE_closure:
920     INTLIKE_HDR(-16)    /* MIN_INTLIKE == -16 */
921     INTLIKE_HDR(-15)
922     INTLIKE_HDR(-14)
923     INTLIKE_HDR(-13)
924     INTLIKE_HDR(-12)
925     INTLIKE_HDR(-11)
926     INTLIKE_HDR(-10)
927     INTLIKE_HDR(-9)
928     INTLIKE_HDR(-8)
929     INTLIKE_HDR(-7)
930     INTLIKE_HDR(-6)
931     INTLIKE_HDR(-5)
932     INTLIKE_HDR(-4)
933     INTLIKE_HDR(-3)
934     INTLIKE_HDR(-2)
935     INTLIKE_HDR(-1)
936     INTLIKE_HDR(0)
937     INTLIKE_HDR(1)
938     INTLIKE_HDR(2)
939     INTLIKE_HDR(3)
940     INTLIKE_HDR(4)
941     INTLIKE_HDR(5)
942     INTLIKE_HDR(6)
943     INTLIKE_HDR(7)
944     INTLIKE_HDR(8)
945     INTLIKE_HDR(9)
946     INTLIKE_HDR(10)
947     INTLIKE_HDR(11)
948     INTLIKE_HDR(12)
949     INTLIKE_HDR(13)
950     INTLIKE_HDR(14)
951     INTLIKE_HDR(15)
952     INTLIKE_HDR(16)     /* MAX_INTLIKE == 16 */
953 }