Commit 73566e25 authored by Simon Marlow's avatar Simon Marlow

Replace inline C functions with C-- macros in .cmm code

So that we can build the RTS with the NCG.
parent 6bf790ba
...@@ -514,4 +514,32 @@ ...@@ -514,4 +514,32 @@
#define TICK_MILLISECS (1000/TICK_FREQUENCY) /* ms per tick */ #define TICK_MILLISECS (1000/TICK_FREQUENCY) /* ms per tick */
#define NO_TREC stg_NO_TREC_closure
#define END_TSO_QUEUE stg_END_TSO_QUEUE_closure
#define dirtyTSO(tso) \
StgTSO_flags(tso) = StgTSO_flags(tso) | TSO_DIRTY::I32;
#define recordMutableCap(p, gen, regs) \
W_ __bd; \
W_ mut_list; \
mut_list = Capability_mut_lists(MyCapability()) + WDS(gen); \
__bd = W_[mut_list]; \
if (bdescr_free(__bd) >= bdescr_start(__bd) + BLOCK_SIZE) { \
W_ __new_bd; \
"ptr" __new_bd = foreign "C" allocBlock_lock() [regs]; \
bdescr_link(__new_bd) = __bd; \
__bd = __new_bd; \
W_[mut_list] = __bd; \
} \
W_ free; \
free = bdescr_free(__bd); \
W_[free] = p; \
bdescr_free(__bd) = free + WDS(1);
#define recordMutable(p, regs) \
W_ __p; \
__p = p; \
recordMutableCap(__p, TO_W_(bdescr_gen_no(Bdescr(__p))), regs)
#endif /* CMM_H */ #endif /* CMM_H */
...@@ -221,11 +221,7 @@ extern void stmWriteTVar(Capability *cap, ...@@ -221,11 +221,7 @@ extern void stmWriteTVar(Capability *cap,
#define END_STM_WAIT_QUEUE ((StgTVarWaitQueue *)(void *)&stg_END_STM_WAIT_QUEUE_closure) #define END_STM_WAIT_QUEUE ((StgTVarWaitQueue *)(void *)&stg_END_STM_WAIT_QUEUE_closure)
#define END_STM_CHUNK_LIST ((StgTRecChunk *)(void *)&stg_END_STM_CHUNK_LIST_closure) #define END_STM_CHUNK_LIST ((StgTRecChunk *)(void *)&stg_END_STM_CHUNK_LIST_closure)
#if IN_STG_CODE
#define NO_TREC (stg_NO_TREC_closure)
#else
#define NO_TREC ((StgTRecHeader *)(void *)&stg_NO_TREC_closure) #define NO_TREC ((StgTRecHeader *)(void *)&stg_NO_TREC_closure)
#endif
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
......
...@@ -248,11 +248,7 @@ extern StgTSO dummy_tso; ...@@ -248,11 +248,7 @@ extern StgTSO dummy_tso;
/* this is the NIL ptr for a TSO queue (e.g. runnable queue) */ /* this is the NIL ptr for a TSO queue (e.g. runnable queue) */
#if IN_STG_CODE
#define END_TSO_QUEUE (stg_END_TSO_QUEUE_closure)
#else
#define END_TSO_QUEUE ((StgTSO *)(void*)&stg_END_TSO_QUEUE_closure) #define END_TSO_QUEUE ((StgTSO *)(void*)&stg_END_TSO_QUEUE_closure)
#endif
#if defined(PAR) || defined(GRAN) #if defined(PAR) || defined(GRAN)
/* this is the NIL ptr for a blocking queue */ /* this is the NIL ptr for a blocking queue */
......
...@@ -229,6 +229,7 @@ main(int argc, char *argv[]) ...@@ -229,6 +229,7 @@ main(int argc, char *argv[])
field_offset(Capability, r); field_offset(Capability, r);
field_offset(Capability, lock); field_offset(Capability, lock);
struct_field(Capability, mut_lists);
struct_field(bdescr, start); struct_field(bdescr, start);
struct_field(bdescr, free); struct_field(bdescr, free);
......
...@@ -138,7 +138,7 @@ unsafeThawArrayzh_fast ...@@ -138,7 +138,7 @@ unsafeThawArrayzh_fast
// //
if (StgHeader_info(R1) != stg_MUT_ARR_PTRS_FROZEN0_info) { if (StgHeader_info(R1) != stg_MUT_ARR_PTRS_FROZEN0_info) {
SET_INFO(R1,stg_MUT_ARR_PTRS_DIRTY_info); SET_INFO(R1,stg_MUT_ARR_PTRS_DIRTY_info);
foreign "C" recordMutableLock(R1 "ptr") [R1]; recordMutable(R1, R1);
// must be done after SET_INFO, because it ASSERTs closure_MUTABLE() // must be done after SET_INFO, because it ASSERTs closure_MUTABLE()
RET_P(R1); RET_P(R1);
} else { } else {
...@@ -1522,7 +1522,7 @@ takeMVarzh_fast ...@@ -1522,7 +1522,7 @@ takeMVarzh_fast
/* actually perform the putMVar for the thread that we just woke up */ /* actually perform the putMVar for the thread that we just woke up */
tso = StgMVar_head(mvar); tso = StgMVar_head(mvar);
PerformPut(tso,StgMVar_value(mvar)); PerformPut(tso,StgMVar_value(mvar));
foreign "C" dirtyTSO(tso "ptr") []; dirtyTSO(tso);
#if defined(GRAN) || defined(PAR) #if defined(GRAN) || defined(PAR)
/* ToDo: check 2nd arg (mvar) is right */ /* ToDo: check 2nd arg (mvar) is right */
...@@ -1596,7 +1596,7 @@ tryTakeMVarzh_fast ...@@ -1596,7 +1596,7 @@ tryTakeMVarzh_fast
/* actually perform the putMVar for the thread that we just woke up */ /* actually perform the putMVar for the thread that we just woke up */
tso = StgMVar_head(mvar); tso = StgMVar_head(mvar);
PerformPut(tso,StgMVar_value(mvar)); PerformPut(tso,StgMVar_value(mvar));
foreign "C" dirtyTSO(tso "ptr") []; dirtyTSO(tso);
#if defined(GRAN) || defined(PAR) #if defined(GRAN) || defined(PAR)
/* ToDo: check 2nd arg (mvar) is right */ /* ToDo: check 2nd arg (mvar) is right */
...@@ -1666,7 +1666,7 @@ putMVarzh_fast ...@@ -1666,7 +1666,7 @@ putMVarzh_fast
/* actually perform the takeMVar */ /* actually perform the takeMVar */
tso = StgMVar_head(mvar); tso = StgMVar_head(mvar);
PerformTake(tso, R2); PerformTake(tso, R2);
foreign "C" dirtyTSO(tso "ptr") []; dirtyTSO(tso);
#if defined(GRAN) || defined(PAR) #if defined(GRAN) || defined(PAR)
/* ToDo: check 2nd arg (mvar) is right */ /* ToDo: check 2nd arg (mvar) is right */
...@@ -1732,7 +1732,7 @@ tryPutMVarzh_fast ...@@ -1732,7 +1732,7 @@ tryPutMVarzh_fast
/* actually perform the takeMVar */ /* actually perform the takeMVar */
tso = StgMVar_head(mvar); tso = StgMVar_head(mvar);
PerformTake(tso, R2); PerformTake(tso, R2);
foreign "C" dirtyTSO(tso "ptr") []; dirtyTSO(tso);
#if defined(GRAN) || defined(PAR) #if defined(GRAN) || defined(PAR)
/* ToDo: check 2nd arg (mvar) is right */ /* ToDo: check 2nd arg (mvar) is right */
......
...@@ -280,9 +280,7 @@ FILL_SLOP(StgClosure *p) ...@@ -280,9 +280,7 @@ FILL_SLOP(StgClosure *p)
prim %write_barrier() []; \ prim %write_barrier() []; \
bd = Bdescr(p1); \ bd = Bdescr(p1); \
if (bdescr_gen_no(bd) != 0 :: CInt) { \ if (bdescr_gen_no(bd) != 0 :: CInt) { \
foreign "C" recordMutableCap(p1 "ptr", \ recordMutableCap(p1, TO_W_(bdescr_gen_no(bd)), R1); \
MyCapability() "ptr", \
bdescr_gen_no(bd)) [R1]; \
SET_INFO(p1, stg_IND_OLDGEN_info); \ SET_INFO(p1, stg_IND_OLDGEN_info); \
LDV_RECORD_CREATE(p1); \ LDV_RECORD_CREATE(p1); \
TICK_UPD_OLD_IND(); \ TICK_UPD_OLD_IND(); \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment