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