- if (!HEAP_ALLOCED(q)) {
-
- if (!major_gc) return q;
-
- info = get_itbl(q);
- switch (info->type) {
-
- case THUNK_STATIC:
- if (info->srt_bitmap != 0 &&
- *THUNK_STATIC_LINK((StgClosure *)q) == NULL) {
- *THUNK_STATIC_LINK((StgClosure *)q) = static_objects;
- static_objects = (StgClosure *)q;
- }
- return q;
-
- case FUN_STATIC:
- if (info->srt_bitmap != 0 &&
- *FUN_STATIC_LINK((StgClosure *)q) == NULL) {
- *FUN_STATIC_LINK((StgClosure *)q) = static_objects;
- static_objects = (StgClosure *)q;
- }
- return q;
-
- case IND_STATIC:
- /* If q->saved_info != NULL, then it's a revertible CAF - it'll be
- * on the CAF list, so don't do anything with it here (we'll
- * scavenge it later).
- */
- if (((StgIndStatic *)q)->saved_info == NULL
- && *IND_STATIC_LINK((StgClosure *)q) == NULL) {
- *IND_STATIC_LINK((StgClosure *)q) = static_objects;
- static_objects = (StgClosure *)q;
- }
- return q;
-
- case CONSTR_STATIC:
- if (*STATIC_LINK(info,(StgClosure *)q) == NULL) {
- *STATIC_LINK(info,(StgClosure *)q) = static_objects;
- static_objects = (StgClosure *)q;
- }
- return q;
-
- case CONSTR_NOCAF_STATIC:
- /* no need to put these on the static linked list, they don't need
- * to be scavenged.
- */
- return q;
-
- default:
- barf("evacuate(static): strange closure type %d", (int)(info->type));
- }
- }
-
- bd = Bdescr((P_)q);
-
- if (bd->gen_no > N) {
- /* Can't evacuate this object, because it's in a generation
- * older than the ones we're collecting. Let's hope that it's
- * in evac_gen or older, or we will have to arrange to track
- * this pointer using the mutable list.
- */
- if (bd->gen_no < evac_gen) {
- // nope
- failed_to_evac = rtsTrue;
- TICK_GC_FAILED_PROMOTION();
- }
- return q;
- }
-
- if ((bd->flags & (BF_LARGE | BF_COMPACTED | BF_EVACUATED)) != 0) {
-
- /* pointer into to-space: just return it. This normally
- * shouldn't happen, but alllowing it makes certain things
- * slightly easier (eg. the mutable list can contain the same
- * object twice, for example).
- */
- if (bd->flags & BF_EVACUATED) {
- if (bd->gen_no < evac_gen) {
- failed_to_evac = rtsTrue;
- TICK_GC_FAILED_PROMOTION();
- }
- return q;
- }
-
- /* evacuate large objects by re-linking them onto a different list.
- */
- if (bd->flags & BF_LARGE) {
- info = get_itbl(q);
- if (info->type == TSO &&
- ((StgTSO *)q)->what_next == ThreadRelocated) {
- q = (StgClosure *)((StgTSO *)q)->link;
- goto loop;
- }
- evacuate_large((P_)q);
- return q;
- }
-
- /* If the object is in a step that we're compacting, then we
- * need to use an alternative evacuate procedure.
- */
- if (bd->flags & BF_COMPACTED) {
- if (!is_marked((P_)q,bd)) {
- mark((P_)q,bd);
- if (mark_stack_full()) {
- mark_stack_overflowed = rtsTrue;
- reset_mark_stack();
- }
- push_mark_stack((P_)q);
- }
- return q;
- }
- }
-
- stp = bd->step->to;
-
- info = get_itbl(q);
-
- switch (info->type) {
-
- case MUT_VAR_CLEAN:
- case MUT_VAR_DIRTY:
- case MVAR:
- return copy(q,sizeW_fromITBL(info),stp);
-
- case CONSTR_0_1:
- {
- StgWord w = (StgWord)q->payload[0];
- if (q->header.info == Czh_con_info &&
- // unsigned, so always true: (StgChar)w >= MIN_CHARLIKE &&
- (StgChar)w <= MAX_CHARLIKE) {
- return (StgClosure *)CHARLIKE_CLOSURE((StgChar)w);
- }
- if (q->header.info == Izh_con_info &&
- (StgInt)w >= MIN_INTLIKE && (StgInt)w <= MAX_INTLIKE) {
- return (StgClosure *)INTLIKE_CLOSURE((StgInt)w);
- }
- // else
- return copy_noscav(q,sizeofW(StgHeader)+1,stp);
- }
-
- case FUN_0_1:
- case FUN_1_0:
- case CONSTR_1_0:
- return copy(q,sizeofW(StgHeader)+1,stp);
-
- case THUNK_1_0:
- case THUNK_0_1:
- return copy(q,sizeofW(StgThunk)+1,stp);
-
- case THUNK_1_1:
- case THUNK_2_0:
- case THUNK_0_2:
-#ifdef NO_PROMOTE_THUNKS
- if (bd->gen_no == 0 &&
- bd->step->no != 0 &&
- bd->step->no == generations[bd->gen_no].n_steps-1) {
- stp = bd->step;
- }
-#endif
- return copy(q,sizeofW(StgThunk)+2,stp);
-
- case FUN_1_1:
- case FUN_2_0:
- case CONSTR_1_1:
- case CONSTR_2_0:
- case FUN_0_2:
- return copy(q,sizeofW(StgHeader)+2,stp);
-
- case CONSTR_0_2:
- return copy_noscav(q,sizeofW(StgHeader)+2,stp);
-
- case THUNK:
- return copy(q,thunk_sizeW_fromITBL(info),stp);
-
- case FUN:
- case CONSTR:
- case IND_PERM:
- case IND_OLDGEN_PERM:
- case WEAK:
- case STABLE_NAME:
- return copy(q,sizeW_fromITBL(info),stp);
-
- case BCO:
- return copy(q,bco_sizeW((StgBCO *)q),stp);
-
- case CAF_BLACKHOLE:
- case SE_CAF_BLACKHOLE:
- case SE_BLACKHOLE:
- case BLACKHOLE:
- return copyPart(q,BLACKHOLE_sizeW(),sizeofW(StgHeader),stp);
-
- case THUNK_SELECTOR: