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