1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team 1998-2006
5 * Generational garbage collector: evacuation functions
7 * Documentation on the architecture of the Garbage Collector can be
8 * found in the online commentary:
10 * http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC
12 * ---------------------------------------------------------------------------*/
22 #include "LdvProfile.h"
24 /* Used to avoid long recursion due to selector thunks
26 #define MAX_THUNK_SELECTOR_DEPTH 16
28 static void eval_thunk_selector (StgClosure **q, StgSelector * p, rtsBool);
31 alloc_for_copy (nat size, step *stp)
37 /* Find out where we're going, using the handy "to" pointer in
38 * the step of the source object. If it turns out we need to
39 * evacuate to an older generation, adjust it here (see comment
42 if (stp < gct->evac_step) {
43 if (gct->eager_promotion) {
46 gct->failed_to_evac = rtsTrue;
50 ws = &gct->steps[stp->gen_no][stp->no];
52 /* chain a new block onto the to-space for the destination step if
57 if (to + size >= bd->start + BLOCK_SIZE_W) {
58 bd = gc_alloc_todo_block(ws);
67 alloc_for_copy_noscav (nat size, step *stp)
73 /* Find out where we're going, using the handy "to" pointer in
74 * the step of the source object. If it turns out we need to
75 * evacuate to an older generation, adjust it here (see comment
78 if (stp < gct->evac_step) {
79 if (gct->eager_promotion) {
82 gct->failed_to_evac = rtsTrue;
86 ws = &gct->steps[stp->gen_no][stp->no];
88 /* chain a new block onto the to-space for the destination step if
93 if (to + size >= bd->start + BLOCK_SIZE_W) {
94 bd = gc_alloc_scavd_block(ws);
103 copy_tag(StgClosure **p, StgClosure *src, nat size, step *stp,StgWord tag)
105 StgPtr to, tagged_to, from;
111 info = xchg((StgPtr)&src->header.info, (W_)&stg_WHITEHOLE_info);
113 } while (info == (W_)&stg_WHITEHOLE_info);
114 if (info == (W_)&stg_EVACUATED_info) {
115 src->header.info = (const StgInfoTable *)info;
116 return evacuate(p); // does the failed_to_evac stuff
119 info = (W_)src->header.info;
120 src->header.info = &stg_EVACUATED_info;
123 to = alloc_for_copy(size,stp);
124 tagged_to = (StgPtr)TAG_CLOSURE(tag,(StgClosure*)to);
125 *p = (StgClosure *)tagged_to;
127 TICK_GC_WORDS_COPIED(size);
131 for (i = 1; i < size; i++) { // unroll for small i
135 ((StgEvacuated*)from)->evacuee = (StgClosure *)tagged_to;
137 // retag pointer before updating EVACUATE closure and returning
139 // if (to+size+2 < bd->start + BLOCK_SIZE_W) {
140 // __builtin_prefetch(to + size + 2, 1);
145 ((StgEvacuated*)from)->header.info = &stg_EVACUATED_info;
149 // We store the size of the just evacuated object in the LDV word so that
150 // the profiler can guess the position of the next object later.
151 SET_EVACUAEE_FOR_LDV(from, size);
156 // Same as copy() above, except the object will be allocated in memory
157 // that will not be scavenged. Used for object that have no pointer
160 copy_noscav_tag(StgClosure **p, StgClosure *src, nat size, step *stp, StgWord tag)
162 StgPtr to, tagged_to, from;
168 info = xchg((StgPtr)&src->header.info, (W_)&stg_WHITEHOLE_info);
169 } while (info == (W_)&stg_WHITEHOLE_info);
170 if (info == (W_)&stg_EVACUATED_info) {
171 src->header.info = (const StgInfoTable *)info;
172 return evacuate(p); // does the failed_to_evac stuff
175 info = (W_)src->header.info;
176 src->header.info = &stg_EVACUATED_info;
179 to = alloc_for_copy_noscav(size,stp);
180 tagged_to = (StgPtr)TAG_CLOSURE(tag,(StgClosure*)to);
181 *p = (StgClosure *)tagged_to;
183 TICK_GC_WORDS_COPIED(size);
187 for (i = 1; i < size; i++) { // unroll for small i
191 ((StgEvacuated*)from)->evacuee = (StgClosure *)tagged_to;
195 ((StgEvacuated*)from)->header.info = &stg_EVACUATED_info;
199 // We store the size of the just evacuated object in the LDV word so that
200 // the profiler can guess the position of the next object later.
201 SET_EVACUAEE_FOR_LDV(from, size);
206 /* Special version of copy() for when we only want to copy the info
207 * pointer of an object, but reserve some padding after it. This is
208 * used to optimise evacuation of BLACKHOLEs.
211 copyPart(StgClosure **p, StgClosure *src, nat size_to_reserve, nat size_to_copy, step *stp)
219 info = xchg((StgPtr)&src->header.info, (W_)&stg_WHITEHOLE_info);
220 } while (info == (W_)&stg_WHITEHOLE_info);
221 if (info == (W_)&stg_EVACUATED_info) {
222 src->header.info = (const StgInfoTable *)info;
223 return evacuate(p); // does the failed_to_evac stuff
226 info = (W_)src->header.info;
227 src->header.info = &stg_EVACUATED_info;
230 to = alloc_for_copy(size_to_reserve, stp);
231 *p = (StgClosure *)to;
233 TICK_GC_WORDS_COPIED(size_to_copy);
237 for (i = 1; i < size_to_copy; i++) { // unroll for small i
241 ((StgEvacuated*)from)->evacuee = (StgClosure *)to;
244 ((StgEvacuated*)from)->header.info = &stg_EVACUATED_info;
248 // We store the size of the just evacuated object in the LDV word so that
249 // the profiler can guess the position of the next object later.
250 SET_EVACUAEE_FOR_LDV(from, size_to_reserve);
252 if (size_to_reserve - size_to_copy > 0)
253 LDV_FILL_SLOP(to + size_to_copy - 1, (int)(size_to_reserve - size_to_copy));
258 /* Copy wrappers that don't tag the closure after copying */
260 copy(StgClosure **p, StgClosure *src, nat size, step *stp)
262 copy_tag(p,src,size,stp,0);
266 copy_noscav(StgClosure **p, StgClosure *src, nat size, step *stp)
268 copy_noscav_tag(p,src,size,stp,0);
271 /* -----------------------------------------------------------------------------
272 Evacuate a large object
274 This just consists of removing the object from the (doubly-linked)
275 step->large_objects list, and linking it on to the (singly-linked)
276 step->new_large_objects list, from where it will be scavenged later.
278 Convention: bd->flags has BF_EVACUATED set for a large object
279 that has been evacuated, or unset otherwise.
280 -------------------------------------------------------------------------- */
284 evacuate_large(StgPtr p)
286 bdescr *bd = Bdescr(p);
290 // object must be at the beginning of the block (or be a ByteArray)
291 ASSERT(get_itbl((StgClosure *)p)->type == ARR_WORDS ||
292 (((W_)p & BLOCK_MASK) == 0));
294 // already evacuated?
295 if (bd->flags & BF_EVACUATED) {
296 /* Don't forget to set the gct->failed_to_evac flag if we didn't get
297 * the desired destination (see comments in evacuate()).
299 if (bd->step < gct->evac_step) {
300 gct->failed_to_evac = rtsTrue;
301 TICK_GC_FAILED_PROMOTION();
308 ACQUIRE_SPIN_LOCK(&stp->sync_large_objects);
309 // remove from large_object list
311 bd->u.back->link = bd->link;
312 } else { // first object in the list
313 stp->large_objects = bd->link;
316 bd->link->u.back = bd->u.back;
318 RELEASE_SPIN_LOCK(&stp->sync_large_objects);
320 /* link it on to the evacuated large object list of the destination step
323 if (stp < gct->evac_step) {
324 if (gct->eager_promotion) {
325 stp = gct->evac_step;
327 gct->failed_to_evac = rtsTrue;
331 ws = &gct->steps[stp->gen_no][stp->no];
333 bd->gen_no = stp->gen_no;
334 bd->link = ws->todo_large_objects;
335 ws->todo_large_objects = bd;
336 bd->flags |= BF_EVACUATED;
339 /* -----------------------------------------------------------------------------
342 This is called (eventually) for every live object in the system.
344 The caller to evacuate specifies a desired generation in the
345 gct->evac_step thread-local variable. The following conditions apply to
346 evacuating an object which resides in generation M when we're
347 collecting up to generation N
349 if M >= gct->evac_step
351 else evac to step->to
353 if M < gct->evac_step evac to gct->evac_step, step 0
355 if the object is already evacuated, then we check which generation
358 if M >= gct->evac_step do nothing
359 if M < gct->evac_step set gct->failed_to_evac flag to indicate that we
360 didn't manage to evacuate this object into gct->evac_step.
365 evacuate() is the single most important function performance-wise
366 in the GC. Various things have been tried to speed it up, but as
367 far as I can tell the code generated by gcc 3.2 with -O2 is about
368 as good as it's going to get. We pass the argument to evacuate()
369 in a register using the 'regparm' attribute (see the prototype for
370 evacuate() near the top of this file).
372 Changing evacuate() to take an (StgClosure **) rather than
373 returning the new pointer seems attractive, because we can avoid
374 writing back the pointer when it hasn't changed (eg. for a static
375 object, or an object in a generation > N). However, I tried it and
376 it doesn't help. One reason is that the (StgClosure **) pointer
377 gets spilled to the stack inside evacuate(), resulting in far more
378 extra reads/writes than we save.
379 -------------------------------------------------------------------------- */
382 evacuate(StgClosure **p)
387 const StgInfoTable *info;
393 /* The tag and the pointer are split, to be merged after evacing */
394 tag = GET_CLOSURE_TAG(q);
395 q = UNTAG_CLOSURE(q);
397 ASSERT(LOOKS_LIKE_CLOSURE_PTR(q));
399 if (!HEAP_ALLOCED(q)) {
401 if (!major_gc) return;
404 switch (info->type) {
407 if (info->srt_bitmap != 0 &&
408 *THUNK_STATIC_LINK((StgClosure *)q) == NULL) {
409 ACQUIRE_SPIN_LOCK(&static_objects_sync);
410 if (*THUNK_STATIC_LINK((StgClosure *)q) == NULL) {
411 *THUNK_STATIC_LINK((StgClosure *)q) = static_objects;
412 static_objects = (StgClosure *)q;
414 RELEASE_SPIN_LOCK(&static_objects_sync);
419 if (info->srt_bitmap != 0 &&
420 *FUN_STATIC_LINK((StgClosure *)q) == NULL) {
421 ACQUIRE_SPIN_LOCK(&static_objects_sync);
422 if (*FUN_STATIC_LINK((StgClosure *)q) == NULL) {
423 *FUN_STATIC_LINK((StgClosure *)q) = static_objects;
424 static_objects = (StgClosure *)q;
426 RELEASE_SPIN_LOCK(&static_objects_sync);
431 /* If q->saved_info != NULL, then it's a revertible CAF - it'll be
432 * on the CAF list, so don't do anything with it here (we'll
433 * scavenge it later).
435 if (((StgIndStatic *)q)->saved_info == NULL) {
436 ACQUIRE_SPIN_LOCK(&static_objects_sync);
437 if (*IND_STATIC_LINK((StgClosure *)q) == NULL) {
438 *IND_STATIC_LINK((StgClosure *)q) = static_objects;
439 static_objects = (StgClosure *)q;
441 RELEASE_SPIN_LOCK(&static_objects_sync);
446 if (*STATIC_LINK(info,(StgClosure *)q) == NULL) {
447 ACQUIRE_SPIN_LOCK(&static_objects_sync);
448 // re-test, after acquiring lock
449 if (*STATIC_LINK(info,(StgClosure *)q) == NULL) {
450 *STATIC_LINK(info,(StgClosure *)q) = static_objects;
451 static_objects = (StgClosure *)q;
453 RELEASE_SPIN_LOCK(&static_objects_sync);
454 /* I am assuming that static_objects pointers are not
455 * written to other objects, and thus, no need to retag. */
459 case CONSTR_NOCAF_STATIC:
460 /* no need to put these on the static linked list, they don't need
466 barf("evacuate(static): strange closure type %d", (int)(info->type));
472 if (bd->gen_no > N) {
473 /* Can't evacuate this object, because it's in a generation
474 * older than the ones we're collecting. Let's hope that it's
475 * in gct->evac_step or older, or we will have to arrange to track
476 * this pointer using the mutable list.
478 if (bd->step < gct->evac_step) {
480 gct->failed_to_evac = rtsTrue;
481 TICK_GC_FAILED_PROMOTION();
486 if ((bd->flags & (BF_LARGE | BF_COMPACTED | BF_EVACUATED)) != 0) {
488 /* pointer into to-space: just return it. This normally
489 * shouldn't happen, but alllowing it makes certain things
490 * slightly easier (eg. the mutable list can contain the same
491 * object twice, for example).
493 if (bd->flags & BF_EVACUATED) {
494 if (bd->step < gct->evac_step) {
495 gct->failed_to_evac = rtsTrue;
496 TICK_GC_FAILED_PROMOTION();
501 /* evacuate large objects by re-linking them onto a different list.
503 if (bd->flags & BF_LARGE) {
505 if (info->type == TSO &&
506 ((StgTSO *)q)->what_next == ThreadRelocated) {
507 q = (StgClosure *)((StgTSO *)q)->link;
511 evacuate_large((P_)q);
515 /* If the object is in a step that we're compacting, then we
516 * need to use an alternative evacuate procedure.
518 if (bd->flags & BF_COMPACTED) {
519 if (!is_marked((P_)q,bd)) {
521 if (mark_stack_full()) {
522 mark_stack_overflowed = rtsTrue;
525 push_mark_stack((P_)q);
535 switch (info->type) {
544 copy(p,q,sizeW_fromITBL(info),stp);
549 StgWord w = (StgWord)q->payload[0];
550 if (q->header.info == Czh_con_info &&
551 // unsigned, so always true: (StgChar)w >= MIN_CHARLIKE &&
552 (StgChar)w <= MAX_CHARLIKE) {
553 *p = TAG_CLOSURE(tag,
554 (StgClosure *)CHARLIKE_CLOSURE((StgChar)w)
557 if (q->header.info == Izh_con_info &&
558 (StgInt)w >= MIN_INTLIKE && (StgInt)w <= MAX_INTLIKE) {
559 *p = TAG_CLOSURE(tag,
560 (StgClosure *)INTLIKE_CLOSURE((StgInt)w)
564 copy_noscav_tag(p,q,sizeofW(StgHeader)+1,stp,tag);
572 copy_tag(p,q,sizeofW(StgHeader)+1,stp,tag);
577 copy(p,q,sizeofW(StgThunk)+1,stp);
583 #ifdef NO_PROMOTE_THUNKS
584 if (bd->gen_no == 0 &&
586 bd->step->no == generations[bd->gen_no].n_steps-1) {
590 copy(p,q,sizeofW(StgThunk)+2,stp);
598 copy_tag(p,q,sizeofW(StgHeader)+2,stp,tag);
602 copy_noscav_tag(p,q,sizeofW(StgHeader)+2,stp,tag);
606 copy(p,q,thunk_sizeW_fromITBL(info),stp);
611 case IND_OLDGEN_PERM:
615 copy_tag(p,q,sizeW_fromITBL(info),stp,tag);
619 copy(p,q,bco_sizeW((StgBCO *)q),stp);
623 case SE_CAF_BLACKHOLE:
626 copyPart(p,q,BLACKHOLE_sizeW(),sizeofW(StgHeader),stp);
630 eval_thunk_selector(p, (StgSelector *)q, rtsTrue);
635 // follow chains of indirections, don't evacuate them
636 q = ((StgInd*)q)->indirectee;
647 case CATCH_STM_FRAME:
648 case CATCH_RETRY_FRAME:
649 case ATOMICALLY_FRAME:
650 // shouldn't see these
651 barf("evacuate: stack frame at %p\n", q);
654 copy(p,q,pap_sizeW((StgPAP*)q),stp);
658 copy(p,q,ap_sizeW((StgAP*)q),stp);
662 copy(p,q,ap_stack_sizeW((StgAP_STACK*)q),stp);
666 /* Already evacuated, just return the forwarding address.
667 * HOWEVER: if the requested destination generation (gct->evac_step) is
668 * older than the actual generation (because the object was
669 * already evacuated to a younger generation) then we have to
670 * set the gct->failed_to_evac flag to indicate that we couldn't
671 * manage to promote the object to the desired generation.
674 * Optimisation: the check is fairly expensive, but we can often
675 * shortcut it if either the required generation is 0, or the
676 * current object (the EVACUATED) is in a high enough generation.
677 * We know that an EVACUATED always points to an object in the
678 * same or an older generation. stp is the lowest step that the
679 * current object would be evacuated to, so we only do the full
680 * check if stp is too low.
683 StgClosure *e = ((StgEvacuated*)q)->evacuee;
685 if (stp < gct->evac_step) { // optimisation
686 if (HEAP_ALLOCED(e) && Bdescr((P_)e)->step < gct->evac_step) {
687 gct->failed_to_evac = rtsTrue;
688 TICK_GC_FAILED_PROMOTION();
695 // just copy the block
696 copy_noscav(p,q,arr_words_sizeW((StgArrWords *)q),stp);
699 case MUT_ARR_PTRS_CLEAN:
700 case MUT_ARR_PTRS_DIRTY:
701 case MUT_ARR_PTRS_FROZEN:
702 case MUT_ARR_PTRS_FROZEN0:
703 // just copy the block
704 copy(p,q,mut_arr_ptrs_sizeW((StgMutArrPtrs *)q),stp);
709 StgTSO *tso = (StgTSO *)q;
711 /* Deal with redirected TSOs (a TSO that's had its stack enlarged).
713 if (tso->what_next == ThreadRelocated) {
714 q = (StgClosure *)tso->link;
719 /* To evacuate a small TSO, we need to relocate the update frame
726 copyPart(p,(StgClosure *)tso, tso_sizeW(tso), sizeofW(StgTSO), stp);
727 new_tso = (StgTSO *)*p;
728 move_TSO(tso, new_tso);
729 for (r = tso->sp, s = new_tso->sp;
730 r < tso->stack+tso->stack_size;) {
738 copy(p,q,sizeofW(StgTRecHeader),stp);
741 case TVAR_WATCH_QUEUE:
742 copy(p,q,sizeofW(StgTVarWatchQueue),stp);
746 copy(p,q,sizeofW(StgTVar),stp);
750 copy(p,q,sizeofW(StgTRecChunk),stp);
753 case ATOMIC_INVARIANT:
754 copy(p,q,sizeofW(StgAtomicInvariant),stp);
757 case INVARIANT_CHECK_QUEUE:
758 copy(p,q,sizeofW(StgInvariantCheckQueue),stp);
762 barf("evacuate: strange closure type %d", (int)(info->type));
769 unchain_thunk_selectors(StgSelector *p, StgClosure *val)
776 ASSERT(p->header.info == &stg_BLACKHOLE_info);
777 prev = (StgSelector*)((StgClosure *)p)->payload[0];
779 // Update the THUNK_SELECTOR with an indirection to the
780 // EVACUATED closure now at p. Why do this rather than
781 // upd_evacuee(q,p)? Because we have an invariant that an
782 // EVACUATED closure always points to an object in the
783 // same or an older generation (required by the short-cut
784 // test in the EVACUATED case, below).
785 SET_INFO(p, &stg_IND_info);
786 ((StgInd *)p)->indirectee = val;
788 // For the purposes of LDV profiling, we have created an
790 LDV_RECORD_CREATE(p);
796 /* -----------------------------------------------------------------------------
797 Evaluate a THUNK_SELECTOR if possible.
799 p points to a THUNK_SELECTOR that we want to evaluate. The
800 result of "evaluating" it will be evacuated and a pointer to the
801 to-space closure will be returned.
803 If the THUNK_SELECTOR could not be evaluated (its selectee is still
804 a THUNK, for example), then the THUNK_SELECTOR itself will be
806 -------------------------------------------------------------------------- */
809 eval_thunk_selector (StgClosure **q, StgSelector * p, rtsBool evac)
810 // NB. for legacy reasons, p & q are swapped around :(
814 const StgInfoTable *info_ptr;
815 StgClosure *selectee;
816 StgSelector *prev_thunk_selector;
820 prev_thunk_selector = NULL;
821 // this is a chain of THUNK_SELECTORs that we are going to update
822 // to point to the value of the current THUNK_SELECTOR. Each
823 // closure on the chain is a BLACKHOLE, and points to the next in the
824 // chain with payload[0].
828 // The selectee might be a constructor closure,
829 // so we untag the pointer.
830 selectee = UNTAG_CLOSURE(p->selectee);
832 // Save the real info pointer (NOTE: not the same as get_itbl()).
833 info_ptr = p->header.info;
834 field = get_itbl(p)->layout.selector_offset;
836 bd = Bdescr((StgPtr)p);
837 if (HEAP_ALLOCED(p)) {
838 // If the THUNK_SELECTOR is in to-space or in a generation that we
839 // are not collecting, then bale out early. We won't be able to
840 // save any space in any case, and updating with an indirection is
841 // trickier in a non-collected gen: we would have to update the
843 if ((bd->gen_no > N) || (bd->flags & BF_EVACUATED)) {
844 unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p);
845 *q = (StgClosure *)p;
848 // we don't update THUNK_SELECTORS in the compacted
849 // generation, because compaction does not remove the INDs
850 // that result, this causes confusion later
851 // (scavenge_mark_stack doesn't deal with IND). BEWARE! This
852 // bit is very tricky to get right. If you make changes
853 // around here, test by compiling stage 3 with +RTS -c -RTS.
854 if (bd->flags & BF_COMPACTED) {
855 // must call evacuate() to mark this closure if evac==rtsTrue
856 *q = (StgClosure *)p;
857 if (evac) evacuate(q);
858 unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p);
863 // BLACKHOLE the selector thunk, since it is now under evaluation.
864 // This is important to stop us going into an infinite loop if
865 // this selector thunk eventually refers to itself.
866 SET_INFO(p,&stg_BLACKHOLE_info);
869 // selectee now points to the closure that we're trying to select
870 // a field from. It may or may not be in to-space: we try not to
871 // end up in to-space, but it's impractical to avoid it in
872 // general. The compacting GC scatters to-space pointers in
873 // from-space during marking, for example. We rely on the property
874 // that evacuate() doesn't mind if it gets passed a to-space pointer.
876 info = get_itbl(selectee);
877 switch (info->type) {
885 case CONSTR_NOCAF_STATIC:
887 // check that the size is in range
888 ASSERT(field < (StgWord32)(info->layout.payload.ptrs +
889 info->layout.payload.nptrs));
891 // Select the right field from the constructor
892 val = selectee->payload[field];
895 // For the purposes of LDV profiling, we have destroyed
896 // the original selector thunk, p.
897 SET_INFO(p, info_ptr);
898 LDV_RECORD_DEAD_FILL_SLOP_DYNAMIC((StgClosure *)p);
899 SET_INFO(p, &stg_BLACKHOLE_info);
902 // the closure in val is now the "value" of the
903 // THUNK_SELECTOR in p. However, val may itself be a
904 // THUNK_SELECTOR, in which case we want to continue
905 // evaluating until we find the real value, and then
906 // update the whole chain to point to the value.
908 info = get_itbl(UNTAG_CLOSURE(val));
909 switch (info->type) {
913 case IND_OLDGEN_PERM:
915 val = ((StgInd *)val)->indirectee;
918 ((StgClosure*)p)->payload[0] = (StgClosure *)prev_thunk_selector;
919 prev_thunk_selector = p;
920 p = (StgSelector*)val;
923 ((StgClosure*)p)->payload[0] = (StgClosure *)prev_thunk_selector;
924 prev_thunk_selector = p;
927 if (evac) evacuate(q);
929 // evacuate() cannot recurse through
930 // eval_thunk_selector(), because we know val is not
932 unchain_thunk_selectors(prev_thunk_selector, val);
940 case IND_OLDGEN_PERM:
942 // Again, we might need to untag a constructor.
943 selectee = UNTAG_CLOSURE( ((StgInd *)selectee)->indirectee );
947 // We don't follow pointers into to-space; the constructor
948 // has already been evacuated, so we won't save any space
949 // leaks by evaluating this selector thunk anyhow.
956 // recursively evaluate this selector. We don't want to
957 // recurse indefinitely, so we impose a depth bound.
958 if (gct->thunk_selector_depth >= MAX_THUNK_SELECTOR_DEPTH) {
962 gct->thunk_selector_depth++;
963 // rtsFalse says "don't evacuate the result". It will,
964 // however, update any THUNK_SELECTORs that are evaluated
966 eval_thunk_selector(&val, (StgSelector*)selectee, rtsFalse);
967 gct->thunk_selector_depth--;
969 // did we actually manage to evaluate it?
970 if (val == selectee) goto bale_out;
972 // Of course this pointer might be tagged...
973 selectee = UNTAG_CLOSURE(val);
987 case SE_CAF_BLACKHOLE:
994 barf("eval_thunk_selector: strange selectee %d",
999 // We didn't manage to evaluate this thunk; restore the old info
1000 // pointer. But don't forget: we still need to evacuate the thunk itself.
1001 SET_INFO(p, info_ptr);
1003 copy(&val,(StgClosure *)p,THUNK_SELECTOR_sizeW(),bd->step->to);
1005 val = (StgClosure *)p;
1008 unchain_thunk_selectors(prev_thunk_selector, val);
1012 /* -----------------------------------------------------------------------------
1013 move_TSO is called to update the TSO structure after it has been
1014 moved from one place to another.
1015 -------------------------------------------------------------------------- */
1018 move_TSO (StgTSO *src, StgTSO *dest)
1022 // relocate the stack pointer...
1023 diff = (StgPtr)dest - (StgPtr)src; // In *words*
1024 dest->sp = (StgPtr)dest->sp + diff;