1 \section[SM-compacting]{Compacting Collector Subroutines}
3 This is a collection of C functions used in implementing the compacting
6 The motivation for making this a separate file/section is twofold:
8 1) It lets us focus on one thing.
10 2) If we don't do this, there will be a huge amount of repetition
11 between the various GC schemes --- a maintenance nightmare.
13 The second is the major motivation.
15 ToDo ADR: trash contents of other semispace after GC in debugging version
18 #if defined(GC1s) || defined(GCdu) || defined(GCap) || defined(GCgn)
24 #include "SMinternal.h"
27 #else /* GCdu, GCap, GCgn */
30 #include "SMinternal.h"
35 #include "SMcompacting.h"
40 LinkRoots(roots, rootno)
46 DEBUG_STRING("Linking Roots:");
47 for (root = 0; root < rootno; root++) {
48 LINK_LOCATION_TO_CLOSURE(&(roots[root]));
58 LinkSparks(STG_NO_ARGS)
63 DEBUG_STRING("Linking Sparks:");
64 for (pool = 0; pool < SPARK_POOLS; pool++) {
65 for (sparkptr = PendingSparksHd[pool];
66 sparkptr < PendingSparksTl[pool]; sparkptr++) {
67 LINK_LOCATION_TO_CLOSURE(sparkptr);
80 LinkLiveGAs(base, bits)
87 long _hp_word, bit_index, bit;
89 DEBUG_STRING("Linking Live GAs:");
91 for (gala = liveIndirections, prev = NULL; gala != NULL; gala = next) {
93 ASSERT(gala->ga.loc.gc.gtid == mytid);
94 if (gala->ga.weight != MAX_GA_WEIGHT) {
95 LINK_LOCATION_TO_CLOSURE(&gala->la);
99 /* Since we have all of the weight, this GA is no longer needed */
100 W_ pga = PACK_GA(thisPE, gala->ga.loc.gc.slot);
103 fprintf(stderr, "Freeing slot %d\n", gala->ga.loc.gc.slot);
105 gala->next = freeIndirections;
106 freeIndirections->next = gala;
107 (void) removeHashTable(pGAtoGALAtable, pga, (void *) gala);
109 gala->ga.weight = 0x0d0d0d0d;
110 gala->la = (P_) 0xbadbad;
114 liveIndirections = prev;
116 prepareFreeMsgBuffers();
118 for (gala = liveRemoteGAs, prev = NULL; gala != NULL; gala = next) {
120 ASSERT(gala->ga.loc.gc.gtid != mytid);
122 _hp_word = gala->la - base;
123 bit_index = _hp_word / BITS_IN(BitWord);
124 bit = 1L << (_hp_word & (BITS_IN(BitWord) - 1));
125 if (!(bits[bit_index] & bit)) {
126 int pe = taskIDtoPE(gala->ga.loc.gc.gtid);
127 W_ pga = PACK_GA(pe, gala->ga.loc.gc.slot);
130 (void) removeHashTable(pGAtoGALAtable, pga, (void *) gala);
131 freeRemoteGA(pe, &(gala->ga));
132 gala->next = freeGALAList;
135 LINK_LOCATION_TO_CLOSURE(&gala->la);
140 liveRemoteGAs = prev;
142 /* If we have any remaining FREE messages to send off, do so now */
150 Note: no \tr{Link[AB]Stack} for ``parallel'' systems, because they
151 don't have a single main stack.
156 LinkAStack(stackA, botA)
162 DEBUG_STRING("Linking A Stack:");
163 for (stackptr = stackA;
164 SUBTRACT_A_STK(stackptr, botA) >= 0;
165 stackptr = stackptr + AREL(1)) {
166 LINK_LOCATION_TO_CLOSURE(stackptr);
172 ToDo (Patrick?): Dont explicitly mark & compact unmarked Bstack frames
177 LinkBStack(stackB, botB)
179 P_ botB; /* stackB points to topmost update frame */
183 DEBUG_STRING("Linking B Stack:");
184 for (updateFramePtr = stackB;
185 SUBTRACT_B_STK(updateFramePtr, botB) > 0;
186 /* re-initialiser given explicitly */ ) {
188 P_ updateClosurePtr = updateFramePtr + BREL(UF_UPDATEE);
190 LINK_LOCATION_TO_CLOSURE(updateClosurePtr);
192 updateFramePtr = GRAB_SuB(updateFramePtr);
205 for (caf_no = 0; CAFlist != NULL; CAFlist = (P_) IND_CLOSURE_LINK(CAFlist))
217 DEBUG_STRING("Linking CAF Ptr Locations:");
218 while(CAFlist != NULL) {
219 DEBUG_LINK_CAF(CAFlist);
220 LINK_LOCATION_TO_CLOSURE(&IND_CLOSURE_PTR(CAFlist));
221 CAFlist = (P_) IND_CLOSURE_LINK(CAFlist);
233 #endif /* defined(_INFO_COMPACTING) */