+Evacuating events is necessary in GRAN since some TSOs and closures are only
+pointed at by events we have to schedule later on.
+
+\begin{code}
+#if defined(GRAN)
+void
+EvacuateEvents(STG_NO_ARGS)
+{
+ eventq event = EventHd;
+
+# if defined(GRAN) && defined(GRAN_CHECK)
+ if ( RTSflags.GcFlags.giveStats && (RTSflags.GranFlags.debug & 0x40) )
+ fprintf(RTSflags.GcFlags.statsFile,"Evacuating Events ...\n");
+#endif
+
+ DEBUG_STRING("Evacuate Events:");
+ while(event != NULL)
+ {
+ if(EVENT_TYPE(event) == RESUMETHREAD ||
+ EVENT_TYPE(event) == MOVETHREAD ||
+ EVENT_TYPE(event) == CONTINUETHREAD ||
+ EVENT_TYPE(event) == STARTTHREAD )
+
+ MAYBE_EVACUATE_CLOSURE( EVENT_TSO(event) );
+
+ else if(EVENT_TYPE(event) == MOVESPARK)
+
+ MAYBE_EVACUATE_CLOSURE( SPARK_NODE(EVENT_SPARK(event)) );
+
+ else if (EVENT_TYPE(event) == FETCHNODE ||
+ EVENT_TYPE(event) == FETCHREPLY )
+ {
+
+ MAYBE_EVACUATE_CLOSURE( EVENT_TSO(event) );
+
+ /* In the case of packet fetching, EVENT_NODE(event) points to */
+ /* the packet (currently, malloced). The packet is just a list of */
+ /* closure addresses, with the length of the list at index 1 (the */
+ /* structure of the packet is defined in Pack.lc). */
+ if ( RTSflags.GranFlags.DoGUMMFetching &&
+ (EVENT_TYPE(event)==FETCHREPLY)) {
+ P_ buffer = (P_) EVENT_NODE(event);
+ int size = (int) buffer[PACK_SIZE_LOCN], i;
+
+ for (i = PACK_HDR_SIZE; i <= size-1; i++) {
+ MAYBE_EVACUATE_CLOSURE( (P_)buffer[i] );
+ }
+ } else
+ MAYBE_EVACUATE_CLOSURE( EVENT_NODE(event) );
+ }
+ else if (EVENT_TYPE(event) == GLOBALBLOCK)
+ {
+ MAYBE_EVACUATE_CLOSURE( EVENT_TSO(event) );
+ MAYBE_EVACUATE_CLOSURE( EVENT_NODE(event) );
+ }
+ else if (EVENT_TYPE(event) == UNBLOCKTHREAD)
+ {
+ MAYBE_EVACUATE_CLOSURE( EVENT_TSO(event) );
+ }
+ event = EVENT_NEXT(event);
+ }
+}
+#endif /* GRAN */
+\end{code}
+