diff options
-rw-r--r-- | rts/Apply.cmm | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/rts/Apply.cmm b/rts/Apply.cmm index b3a04ca58c..4c34f0f3d8 100644 --- a/rts/Apply.cmm +++ b/rts/Apply.cmm @@ -156,13 +156,26 @@ again: THUNK_STATIC, THUNK_SELECTOR: { - // The thunk might evaluate to a function, so we have to come - // back here again to adjust its CCS if necessary. The - // stg_restore_ccs_eval stack frame does that. + // We have a thunk of some kind, so evaluate it. + + // The thunk might evaluate to a function, so we have to + // come back here again to adjust its CCS if necessary. + // Therefore we need to push a stack frame to look at the + // function that gets returned (a stg_restore_ccs_eval + // frame), and therefore we need a stack check. STK_CHK_GEN(); + + // We can't use the value of 'info' any more, because if + // STK_CHK_GEN() did a GC then the closure we're looking + // at may have changed, e.g. a THUNK_SELECTOR may have + // been evaluated by the GC. So we reload the info + // pointer now. + untaggedfun = UNTAG(fun); + info = %INFO_PTR(untaggedfun); + jump %ENTRY_CODE(info) (stg_restore_cccs_eval_info, CCCS) - (UNTAG(fun)); + (untaggedfun); } default: { |