diff options
author | Simon Marlow <simonmar@microsoft.com> | 2007-10-31 14:36:34 +0000 |
---|---|---|
committer | Simon Marlow <simonmar@microsoft.com> | 2007-10-31 14:36:34 +0000 |
commit | bf1197b67163d9f5b6509cf836e07ff83cc0a063 (patch) | |
tree | e01bc2f69a3f3581667334db3c72032ff0eb7a7b /rts/sm/MarkWeak.c | |
parent | 698364afaf2f346227910c0cf8d4f1929cdc56ef (diff) | |
download | haskell-bf1197b67163d9f5b6509cf836e07ff83cc0a063.tar.gz |
GC refactoring: make evacuate() take an StgClosure**
Change the type of evacuate() from
StgClosure *evacuate(StgClosure *);
to
void evacuate(StgClosure **);
So evacuate() itself writes the source pointer, rather than the
caller. This is slightly cleaner, and avoids a few memory writes:
sometimes evacuate() doesn't move the object, and in these cases the
source pointer doesn't need to be written. It doesn't have a
measurable impact on performance, though.
Diffstat (limited to 'rts/sm/MarkWeak.c')
-rw-r--r-- | rts/sm/MarkWeak.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/rts/sm/MarkWeak.c b/rts/sm/MarkWeak.c index bfa78e5836..62ac8e0397 100644 --- a/rts/sm/MarkWeak.c +++ b/rts/sm/MarkWeak.c @@ -137,8 +137,8 @@ traverseWeakPtrList(void) if (new != NULL) { w->key = new; // evacuate the value and finalizer - w->value = evacuate(w->value); - w->finalizer = evacuate(w->finalizer); + evacuate(&w->value); + evacuate(&w->finalizer); // remove this weak ptr from the old_weak_ptr list *last_w = w->link; // and put it on the new weak ptr list @@ -169,7 +169,7 @@ traverseWeakPtrList(void) */ if (flag == rtsFalse) { for (w = old_weak_ptr_list; w; w = w->link) { - w->finalizer = evacuate(w->finalizer); + evacuate(&w->finalizer); } // Next, move to the WeakThreads stage after fully @@ -241,7 +241,8 @@ traverseWeakPtrList(void) StgTSO *t, *tmp, *next; for (t = old_all_threads; t != END_TSO_QUEUE; t = next) { next = t->global_link; - tmp = (StgTSO *)evacuate((StgClosure *)t); + tmp = t; + evacuate((StgClosure **)&tmp); tmp->global_link = resurrected_threads; resurrected_threads = tmp; } @@ -301,7 +302,8 @@ traverseBlackholeQueue (void) continue; } } - t = (StgTSO *)evacuate((StgClosure *)t); + tmp = t; + evacuate((StgClosure **)&tmp); if (prev) prev->link = t; flag = rtsTrue; } @@ -324,14 +326,15 @@ traverseBlackholeQueue (void) void markWeakPtrList ( void ) { - StgWeak *w, **last_w; + StgWeak *w, **last_w, *tmp; last_w = &weak_ptr_list; for (w = weak_ptr_list; w; w = w->link) { // w might be WEAK, EVACUATED, or DEAD_WEAK (actually CON_STATIC) here ASSERT(w->header.info == &stg_DEAD_WEAK_info || get_itbl(w)->type == WEAK || get_itbl(w)->type == EVACUATED); - w = (StgWeak *)evacuate((StgClosure *)w); + tmp = w; + evacuate((StgClosure **)&tmp); *last_w = w; last_w = &(w->link); } |