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