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