X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Frts%2FStgStartup.cmm;fp=ghc%2Frts%2FStgStartup.cmm;h=d727cb573f0ddb2c41856191ae1c8b9fda0975f2;hb=3595da95b2ca0d60c9100f77541b6ce36e49363c;hp=2d5d4d89415270204b8f8a00012bd18eb47d08cf;hpb=eab2c6c48c6d0d679e2a737388749ac482372110;p=ghc-hetmet.git diff --git a/ghc/rts/StgStartup.cmm b/ghc/rts/StgStartup.cmm index 2d5d4d8..d727cb5 100644 --- a/ghc/rts/StgStartup.cmm +++ b/ghc/rts/StgStartup.cmm @@ -102,6 +102,9 @@ INFO_TABLE_RET( stg_stop_thread, STOP_THREAD_WORDS, STOP_THREAD_BITMAP, Start a thread from the scheduler by returning to the address on the top of the stack. This is used for all entries to STG code from C land. + + On the way back, we (usually) pass through stg_returnToSched which saves + the thread's state away nicely. -------------------------------------------------------------------------- */ stg_returnToStackTop @@ -111,6 +114,24 @@ stg_returnToStackTop jump %ENTRY_CODE(Sp(0)); } +stg_returnToSched +{ + SAVE_THREAD_STATE(); + foreign "C" threadPaused(CurrentTSO); + jump StgReturn; +} + +// A variant of stg_returnToSched, but instead of returning directly to the +// scheduler, we jump to the code fragment pointed to by R2. This lets us +// perform some final actions after making the thread safe, such as unlocking +// the MVar on which we are about to block in SMP mode. +stg_returnToSchedButFirst +{ + SAVE_THREAD_STATE(); + foreign "C" threadPaused(CurrentTSO); + jump R2; +} + /* ----------------------------------------------------------------------------- Strict IO application - performing an IO action and entering its result.