Big collection of patches for the new codegen branch.
[ghc-hetmet.git] / rts / StgMiscClosures.cmm
index 205d7ac..7f7cf78 100644 (file)
@@ -14,7 +14,7 @@
 
 import pthread_mutex_lock;
 import ghczmprim_GHCziTypes_Czh_static_info;
-import base_GHCziBase_Izh_static_info;
+import ghczmprim_GHCziTypes_Izh_static_info;
 import EnterCriticalSection;
 import LeaveCriticalSection;
 
@@ -384,14 +384,33 @@ INFO_TABLE(stg_CAF_BLACKHOLE,0,1,CAF_BLACKHOLE,"CAF_BLACKHOLE","CAF_BLACKHOLE")
     jump stg_block_blackhole;
 }
 
-#ifdef EAGER_BLACKHOLING
-INFO_TABLE(stg_SE_BLACKHOLE,0,1,SE_BLACKHOLE,"SE_BLACKHOLE","SE_BLACKHOLE")
-{ foreign "C" barf("SE_BLACKHOLE object entered!") never returns; }
+INFO_TABLE(__stg_EAGER_BLACKHOLE,0,1,BLACKHOLE,"EAGER_BLACKHOLE","EAGER_BLACKHOLE")
+{
+    TICK_ENT_BH();
+
+#ifdef THREADED_RTS
+    // foreign "C" debugBelch("BLACKHOLE entry\n");
+#endif
 
-INFO_TABLE(stg_SE_CAF_BLACKHOLE,0,1,SE_CAF_BLACKHOLE,"SE_CAF_BLACKHOLE","SE_CAF_BLACKHOLE")
-{ foreign "C" barf("SE_CAF_BLACKHOLE object entered!") never returns; }
+    /* Actually this is not necessary because R1 is about to be destroyed. */
+    LDV_ENTER(R1);
+
+#if defined(THREADED_RTS)
+    ACQUIRE_LOCK(sched_mutex "ptr");
+    // released in stg_block_blackhole_finally
 #endif
 
+    /* Put ourselves on the blackhole queue */
+    StgTSO__link(CurrentTSO) = W_[blackhole_queue];
+    W_[blackhole_queue] = CurrentTSO;
+
+    /* jot down why and on what closure we are blocked */
+    StgTSO_why_blocked(CurrentTSO) = BlockedOnBlackHole::I16;
+    StgTSO_block_info(CurrentTSO) = R1;
+
+    jump stg_block_blackhole;
+}
+
 /* ----------------------------------------------------------------------------
    Whiteholes are used for the "locked" state of a closure (see lockClosure())
    ------------------------------------------------------------------------- */
@@ -596,10 +615,10 @@ CLOSURE(stg_dummy_ret_closure,stg_dummy_ret);
  */
 #warning Is this correct? _imp is a pointer!
 #define Char_hash_static_info _imp__ghczmprim_GHCziTypes_Czh_static_info
-#define Int_hash_static_info _imp__base_GHCziBase_Izh_static_info
+#define Int_hash_static_info _imp__ghczmprim_GHCziTypes_Izh_static_info
 #else
 #define Char_hash_static_info ghczmprim_GHCziTypes_Czh_static_info
-#define Int_hash_static_info base_GHCziBase_Izh_static_info
+#define Int_hash_static_info ghczmprim_GHCziTypes_Izh_static_info
 #endif