- rga_GLOBAL = ((StgFetchMe *)R1.p)->ga;
- ASSERT(rga->payload.gc.gtid != mytid);
-
- /* Turn the FETCH_ME into a FETCH_ME_BQ, and place the current thread
- * on the blocking queue.
- */
- // R1.cl->header.info = FETCH_ME_BQ_info;
- SET_INFO((StgClosure *)R1.cl, &FETCH_ME_BQ_info);
-
- CurrentTSO->link = END_BQ_QUEUE;
- ((StgFetchMeBlockingQueue *)R1.cl)->blocking_queue = (StgBlockingQueueElement *)CurrentTSO;
-
- /* record onto which closure the current thread is blcoking */
- CurrentTSO->block_info.closure = R1.cl;
- //recordMutable((StgMutClosure *)R1.cl);
- p_GLOBAL = R1.cl;
-
- /* Save the Thread State here, before calling RTS routines below! */
- //BLOCK_NP_NO_JUMP(1);
- SAVE_THREAD_STATE(1);
-
- /* unknown junk... needed? --SDM yes, want to see what's happening -- HWL */
- if (RtsFlags.ParFlags.ParStats.Full) {
- /* Note that CURRENT_TIME may perform an unsafe call */
- //rtsTime now = CURRENT_TIME; /* Now */
- CurrentTSO->par.exectime += CURRENT_TIME - CurrentTSO->par.blockedat;
- CurrentTSO->par.fetchcount++;
- /* TSO_QUEUE(CurrentTSO) = Q_FETCHING; */
- CurrentTSO->par.blockedat = CURRENT_TIME;
- /* we are about to send off a FETCH message, so dump a FETCH event */
- /* following should be an STGCALL --SDM */
- DumpRawGranEvent(CURRENT_PROC, taskIDtoPE(rga_GLOBAL->payload.gc.gtid),
- GR_FETCH, CurrentTSO, (StgClosure *)R1.p, 0);
- }
-
- /* Phil T. claims that this was a workaround for a hard-to-find
- * bug, hence I'm leaving it out for now --SDM
- */
- /* Assign a brand-new global address to the newly created FMBQ */
- lga_GLOBAL = makeGlobal(p_GLOBAL, rtsFalse);
- splitWeight(&fmbqga_GLOBAL, lga_GLOBAL);
- ASSERT(fmbqga_GLOBAL.weight == 1L << (BITS_IN(unsigned) - 1));
-
- STGCALL3(sendFetch, rga_GLOBAL, &fmbqga_GLOBAL, 0/*load*/);
-
- // sendFetch now called from processTheRealFetch, to make SDM happy
- //theGlobalFromGA.payload.gc.gtid = rga->payload.gc.gtid;
- //theGlobalFromGA.payload.gc.slot = rga->payload.gc.slot;
- //theGlobalFromGA.weight = rga->weight;
- //theGlobalToGA.payload.gc.gtid = fmbqga.payload.gc.gtid;
- //theGlobalToGA.payload.gc.slot = fmbqga.payload.gc.slot;
- //theGlobalToGA.weight = fmbqga.weight;
-
- // STGCALL6(fprintf,stderr,"%% Fetching %p from remote PE ((%x,%d,%x))\n",R1.p,rga->payload.gc.gtid, rga->payload.gc.slot, rga->weight);
-
- THREAD_RETURN(1); /* back to the scheduler */
- // was: BLOCK_NP(1);
+ TICK_ENT_BH();
+
+ ASSERT(((StgFetchMe *)R1.p)->ga->payload.gc.gtid != mytid);
+
+ /* Turn the FETCH_ME into a FETCH_ME_BQ, and place the current thread
+ * on the blocking queue.
+ */
+ // ((StgFetchMeBlockingQueue *)R1.cl)->header.info = &FETCH_ME_BQ_info; // does the same as SET_INFO
+ SET_INFO((StgClosure *)R1.cl, &stg_FETCH_ME_BQ_info);
+
+ /* Remember GA as a global var (used in blockThread); NB: not thread safe! */
+ ASSERT(theGlobalFromGA.payload.gc.gtid == (GlobalTaskId)0);
+ theGlobalFromGA = *((StgFetchMe *)R1.p)->ga;
+
+ /* Put ourselves on the blocking queue for this black hole */
+ ASSERT(looks_like_ga(((StgFetchMe *)R1.p)->ga));
+ CurrentTSO->link = END_BQ_QUEUE;
+ ((StgFetchMeBlockingQueue *)R1.cl)->blocking_queue = (StgBlockingQueueElement *)CurrentTSO;
+
+ /* jot down why and on what closure we are blocked */
+ CurrentTSO->why_blocked = BlockedOnGA;
+ CurrentTSO->block_info.closure = R1.cl;
+ /* closure is mutable since something has just been added to its BQ */
+ //recordMutable((StgMutClosure *)R1.cl);
+
+ /* sendFetch etc is now done in blockThread, which is called from the
+ scheduler -- HWL */
+
+ BLOCK_NP(1);