[project @ 2005-07-27 15:32:12 by simonmar]
[ghc-hetmet.git] / ghc / rts / PrimOps.cmm
index 082cb01..01205c6 100644 (file)
@@ -240,26 +240,6 @@ atomicModifyMutVarzh_fast
 }
 
 /* -----------------------------------------------------------------------------
-   Foreign Object Primitives
-   -------------------------------------------------------------------------- */
-
-mkForeignObjzh_fast
-{
-  /* R1 = ptr to foreign object,
-  */
-  W_ result;
-
-  ALLOC_PRIM( SIZEOF_StgForeignObj, NO_PTRS, mkForeignObjzh_fast);
-
-  result = Hp - SIZEOF_StgForeignObj + WDS(1);
-  SET_HDR(result,stg_FOREIGN_info,W_[CCCS]);
-  StgForeignObj_data(result) = R1;
-
-  /* returns (# s#, ForeignObj# #) */
-  RET_P(result);
-}
-
-/* -----------------------------------------------------------------------------
    Weak Pointer Primitives
    -------------------------------------------------------------------------- */
 
@@ -1181,6 +1161,7 @@ atomicallyzh_fast
 
   /* Start the memory transcation */
   old_trec = StgTSO_trec(CurrentTSO);
+  ASSERT(old_trec == NO_TREC);
   "ptr" new_trec = foreign "C" stmStartTransaction(BaseReg "ptr", old_trec "ptr");
   StgTSO_trec(CurrentTSO) = new_trec;
 
@@ -1330,22 +1311,13 @@ retry_pop_stack:
 newTVarzh_fast
 {
   W_ tv;
-  W_ trec;
+  W_ new_value;
 
   /* Args: R1 = initialisation value */
 
-  ALLOC_PRIM( SIZEOF_StgTVar, R1_PTR, newTVarzh_fast);
-  tv = Hp - SIZEOF_StgTVar + WDS(1);
-  SET_HDR(tv,stg_TVAR_info,W_[CCCS]);
-  StgTVar_current_value(tv) = R1;
-  StgTVar_first_wait_queue_entry(tv) = stg_END_STM_WAIT_QUEUE_closure;
-#if defined(SMP)
-  trec = StgTSO_trec(CurrentTSO);
-  StgTVar_last_update_by(tv) = trec;
-#else
-  StgTVar_last_update_by(tv) = NO_TREC;
-#endif
-    
+  MAYBE_GC (R1_PTR, newTVarzh_fast); 
+  new_value = R1;
+  tv = foreign "C" stmNewTVar(BaseReg "ptr", new_value "ptr");
   RET_P(tv);
 }