X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FPrimOps.cmm;h=437ce55ac5218ca5b28be5318c34e17f2f1719ac;hb=aee2068e034aca6ddaf6f20f85902137ecf718b7;hp=b58baa099583b5e6a647b637981b98fd963f2cbf;hpb=da66d07a47f6314351790a9186dcbcdf5b1f2965;p=ghc-hetmet.git diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index b58baa0..437ce55 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -2130,3 +2130,23 @@ asyncDoProczh_fast #endif } #endif + +// noDuplicate# tries to ensure that none of the thunks under +// evaluation by the current thread are also under evaluation by +// another thread. It relies on *both* threads doing noDuplicate#; +// the second one will get blocked if they are duplicating some work. +noDuplicatezh_fast +{ + SAVE_THREAD_STATE(); + ASSERT(StgTSO_what_next(CurrentTSO) == ThreadRunGHC::I16); + foreign "C" threadPaused (MyCapability() "ptr", CurrentTSO "ptr") []; + + if (StgTSO_what_next(CurrentTSO) == ThreadKilled::I16) { + R1 = ThreadFinished; + jump StgReturn; + } else { + LOAD_THREAD_STATE(); + ASSERT(StgTSO_what_next(CurrentTSO) == ThreadRunGHC::I16); + jump %ENTRY_CODE(Sp(0)); + } +}