-/* -----------------------------------------------------------------------------
+/* -----------------------------------------------------------------------*-c-*-
*
* (c) The GHC Team 1998-2006
*
StgWord info;
#if !defined(MINOR_GC) && defined(THREADED_RTS)
- do {
+spin:
info = xchg((StgPtr)&src->header.info, (W_)&stg_WHITEHOLE_info);
// so.. what is it?
- } while (info == (W_)&stg_WHITEHOLE_info);
- if (info == (W_)&stg_EVACUATED_info) {
+ if (info == (W_)&stg_WHITEHOLE_info) {
+#ifdef PROF_SPIN
+ whitehole_spin++;
+#endif
+ goto spin;
+ }
+ if (info == (W_)&stg_EVACUATED_info || info == (W_)&stg_IND_info) {
+ // NB. a closure might be updated with an IND by
+ // unchain_selector_thunks(), hence the test above.
src->header.info = (const StgInfoTable *)info;
return evacuate(p); // does the failed_to_evac stuff
}
#else
+ ASSERT(n_gc_threads == 1);
info = (W_)src->header.info;
src->header.info = &stg_EVACUATED_info;
#endif
StgWord info;
#if !defined(MINOR_GC) && defined(THREADED_RTS)
- do {
+spin:
info = xchg((StgPtr)&src->header.info, (W_)&stg_WHITEHOLE_info);
- } while (info == (W_)&stg_WHITEHOLE_info);
+ if (info == (W_)&stg_WHITEHOLE_info) {
+#ifdef PROF_SPIN
+ whitehole_spin++;
+#endif
+ goto spin;
+ }
if (info == (W_)&stg_EVACUATED_info) {
src->header.info = (const StgInfoTable *)info;
- return evacuate(p); // does the failed_to_evac stuff
+ evacuate(p); // does the failed_to_evac stuff
+ return ;
}
#else
info = (W_)src->header.info;
switch (info->type) {
case THUNK_STATIC:
- if (info->srt_bitmap != 0 &&
- *THUNK_STATIC_LINK((StgClosure *)q) == NULL) {
- ACQUIRE_SPIN_LOCK(&static_objects_sync);
+ if (info->srt_bitmap != 0) {
if (*THUNK_STATIC_LINK((StgClosure *)q) == NULL) {
- *THUNK_STATIC_LINK((StgClosure *)q) = static_objects;
- static_objects = (StgClosure *)q;
+#ifndef THREADED_RTS
+ *THUNK_STATIC_LINK((StgClosure *)q) = gct->static_objects;
+ gct->static_objects = (StgClosure *)q;
+#else
+ StgPtr link;
+ link = (StgPtr)cas((StgPtr)THUNK_STATIC_LINK((StgClosure *)q),
+ (StgWord)NULL,
+ (StgWord)gct->static_objects);
+ if (link == NULL) {
+ gct->static_objects = (StgClosure *)q;
+ }
+#endif
}
- RELEASE_SPIN_LOCK(&static_objects_sync);
}
return;
-
+
case FUN_STATIC:
if (info->srt_bitmap != 0 &&
*FUN_STATIC_LINK((StgClosure *)q) == NULL) {
- ACQUIRE_SPIN_LOCK(&static_objects_sync);
- if (*FUN_STATIC_LINK((StgClosure *)q) == NULL) {
- *FUN_STATIC_LINK((StgClosure *)q) = static_objects;
- static_objects = (StgClosure *)q;
- }
- RELEASE_SPIN_LOCK(&static_objects_sync);
+#ifndef THREADED_RTS
+ *FUN_STATIC_LINK((StgClosure *)q) = gct->static_objects;
+ gct->static_objects = (StgClosure *)q;
+#else
+ StgPtr link;
+ link = (StgPtr)cas((StgPtr)FUN_STATIC_LINK((StgClosure *)q),
+ (StgWord)NULL,
+ (StgWord)gct->static_objects);
+ if (link == NULL) {
+ gct->static_objects = (StgClosure *)q;
+ }
+#endif
}
return;
* scavenge it later).
*/
if (((StgIndStatic *)q)->saved_info == NULL) {
- ACQUIRE_SPIN_LOCK(&static_objects_sync);
if (*IND_STATIC_LINK((StgClosure *)q) == NULL) {
- *IND_STATIC_LINK((StgClosure *)q) = static_objects;
- static_objects = (StgClosure *)q;
+#ifndef THREADED_RTS
+ *IND_STATIC_LINK((StgClosure *)q) = gct->static_objects;
+ gct->static_objects = (StgClosure *)q;
+#else
+ StgPtr link;
+ link = (StgPtr)cas((StgPtr)IND_STATIC_LINK((StgClosure *)q),
+ (StgWord)NULL,
+ (StgWord)gct->static_objects);
+ if (link == NULL) {
+ gct->static_objects = (StgClosure *)q;
+ }
+#endif
}
- RELEASE_SPIN_LOCK(&static_objects_sync);
}
return;
case CONSTR_STATIC:
if (*STATIC_LINK(info,(StgClosure *)q) == NULL) {
- ACQUIRE_SPIN_LOCK(&static_objects_sync);
- // re-test, after acquiring lock
- if (*STATIC_LINK(info,(StgClosure *)q) == NULL) {
- *STATIC_LINK(info,(StgClosure *)q) = static_objects;
- static_objects = (StgClosure *)q;
- }
- RELEASE_SPIN_LOCK(&static_objects_sync);
- /* I am assuming that static_objects pointers are not
- * written to other objects, and thus, no need to retag. */
- }
+#ifndef THREADED_RTS
+ *STATIC_LINK(info,(StgClosure *)q) = gct->static_objects;
+ gct->static_objects = (StgClosure *)q;
+#else
+ StgPtr link;
+ link = (StgPtr)cas((StgPtr)STATIC_LINK(info,(StgClosure *)q),
+ (StgWord)NULL,
+ (StgWord)gct->static_objects);
+ if (link == NULL) {
+ gct->static_objects = (StgClosure *)q;
+ }
+#endif
+ }
+ /* I am assuming that static_objects pointers are not
+ * written to other objects, and thus, no need to retag. */
return;
case CONSTR_NOCAF_STATIC:
StgClosure *e = ((StgEvacuated*)q)->evacuee;
*p = e;
if (stp < gct->evac_step) { // optimisation
- if (HEAP_ALLOCED(e) && Bdescr((P_)e)->step < gct->evac_step) {
+ if (Bdescr((P_)e)->step < gct->evac_step) {
gct->failed_to_evac = rtsTrue;
TICK_GC_FAILED_PROMOTION();
}
barf("evacuate");
}
+
+#undef copy
+#undef copy_tag
+#undef copyPart
+#undef evacuate