X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FException.cmm;h=9d8d9d69544c040263a2348e454eeb2dd0ef1941;hb=ce9d03fa27ce85072d8ac1426d5420a5c0c215ee;hp=4007b7866fbfd30d2324ee67a1cc86c70aaf4daf;hpb=03a9ff01812afc81eb5236fd3063cbec44cf469e;p=ghc-hetmet.git diff --git a/ghc/rts/Exception.cmm b/ghc/rts/Exception.cmm index 4007b78..9d8d9d6 100644 --- a/ghc/rts/Exception.cmm +++ b/ghc/rts/Exception.cmm @@ -360,7 +360,7 @@ retry_pop_stack: W_ r; trec = StgTSO_trec(CurrentTSO); r = foreign "C" stmValidateNestOfTransactions(trec "ptr"); - foreign "C" stmAbortTransaction(trec "ptr"); + foreign "C" stmAbortTransaction(MyCapability() "ptr", trec "ptr"); StgTSO_trec(CurrentTSO) = NO_TREC; if (r) { // Transaction was valid: continue searching for a catch frame @@ -369,7 +369,7 @@ retry_pop_stack: } else { // Transaction was not valid: we retry the exception (otherwise continue // with a further call to raiseExceptionHelper) - "ptr" trec = foreign "C" stmStartTransaction(BaseReg "ptr", NO_TREC "ptr"); + "ptr" trec = foreign "C" stmStartTransaction(MyCapability() "ptr", NO_TREC "ptr"); StgTSO_trec(CurrentTSO) = trec; R1 = StgAtomicallyFrame_code(Sp); Sp_adj(-1); @@ -378,13 +378,22 @@ retry_pop_stack: } if (frame_type == STOP_FRAME) { - /* We've stripped the entire stack, the thread is now dead. */ - Sp = CurrentTSO + OFFSET_StgTSO_stack - + WDS(StgTSO_stack_size(CurrentTSO)) - WDS(1); - Sp(0) = R1; /* save the exception */ + /* + * We've stripped the entire stack, the thread is now dead. + * We will leave the stack in a GC'able state, see the stg_stop_thread + * entry code in StgStartup.cmm. + */ + Sp = CurrentTSO + TSO_OFFSET_StgTSO_stack + + WDS(StgTSO_stack_size(CurrentTSO)) - WDS(2); + Sp(1) = R1; /* save the exception */ + Sp(0) = stg_enter_info; /* so that GC can traverse this stack */ StgTSO_what_next(CurrentTSO) = ThreadKilled::I16; SAVE_THREAD_STATE(); /* inline! */ - R1 = ThreadFinished; + + /* The return code goes in BaseReg->rRet, and BaseReg is returned in R1 */ + StgRegTable_rRet(BaseReg) = ThreadFinished; + R1 = BaseReg; + jump StgReturn; }