}
/* -----------------------------------------------------------------------------
- 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
-------------------------------------------------------------------------- */
/* 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;
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);
}