void sweep(){ // puts( "bbGC::sweep()" );fflush( stdout ); markFrames(); markQueued(); if( unmarkedList->succ!=unmarkedList ){ //append unmarked to end of free queue unmarkedList->succ->pred=freeList.pred; unmarkedList->pred->succ=&freeList; freeList.pred->succ=unmarkedList->succ; freeList.pred=unmarkedList->pred; //clear unmarkedmpor unmarkedList->succ=unmarkedList->pred=unmarkedList; } std::swap( markedList,unmarkedList ); std::swap( markedBit,unmarkedBit ); unmarkedBytes=markedBytes; markedBytes=0; allocedBytes=0; markRoots(); }
/* A trail slot is marked iff it contains an unbound constrained variable reference or a goal. */ static CVOID__PROTO(markChoicepoints) { /* Mark choicepoints and corresponding chains of frames */ /* and mark remaining trail entries */ node_t *cp = Gc_Aux_Node; tagged_t *tr = w->trail_top; tagged_t *limit; while (ChoiceYounger(cp,Gc_Choice_Start)) { intmach_t n = cp->next_alt->node_offset; intmach_t i = OffsetToArity(n); markFrames(Arg, cp->frame, cp->next_insn); while ((i--)>0) { if (IsHeapTerm(cp->term[i])) markVariable(Arg, &cp->term[i]); } cp = ChoiceCharOffset(cp, -n); /* mark goals and unbound constrained variables; reset unmarked bound variables between cp->trail_top and tr */ limit = TagToPointer(cp->trail_top); while (TrailYounger(tr,limit)) { tagged_t v = TrailPop(tr); if (v==(tagged_t)NULL || gc_IsMarked(v)) ; else if (!IsVar(v)) markVariable(Arg, tr); #ifdef EARLY_RESET else if (TagIsCVA(v)) { if (!gc_IsMarked(*TagToCVA(v))) *TagToCVA(v)= v, markVariable(Arg, tr), *tr= 0; } else { if (!gc_IsMarked(*TagToPointer(v))) *TagToPointer(v)= v, *tr= 0; } #else else if (TagIsCVA(v)) markVariable(Arg, tr); #endif } }