summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2013-12-04 10:38:47 -0500
committerPatrick Palka <patrick@parcs.ath.cx>2013-12-04 12:22:34 -0500
commitfe68ad50f3fa7d73df691f9fd9decd17a72b8b46 (patch)
treebb1e44f74f6492714eb8732bc9485552cdb81b6e /compiler/codeGen
parent55c703b8fdb040c51bf8784beb3dc02332db417a (diff)
downloadhaskell-fe68ad50f3fa7d73df691f9fd9decd17a72b8b46.tar.gz
Update and deduplicate the comments on CAF management (#8590)
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/StgCmmBind.hs35
1 files changed, 4 insertions, 31 deletions
diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs
index 05aae0aeeb..23367926c7 100644
--- a/compiler/codeGen/StgCmmBind.hs
+++ b/compiler/codeGen/StgCmmBind.hs
@@ -695,44 +695,17 @@ emitUpdateFrame dflags frame lbl updatee = do
-----------------------------------------------------------------------------
-- Entering a CAF
--
--- When a CAF is first entered, it creates a black hole in the heap,
--- and updates itself with an indirection to this new black hole.
---
--- We update the CAF with an indirection to a newly-allocated black
--- hole in the heap. We also set the blocking queue on the newly
--- allocated black hole to be empty.
---
--- Why do we make a black hole in the heap when we enter a CAF?
---
--- - for a generational garbage collector, which needs a fast
--- test for whether an updatee is in an old generation or not
---
--- - for the parallel system, which can implement updates more
--- easily if the updatee is always in the heap. (allegedly).
---
--- When debugging, we maintain a separate CAF list so we can tell when
--- a CAF has been garbage collected.
-
--- newCAF must be called before the itbl ptr is overwritten, since
--- newCAF records the old itbl ptr in order to do CAF reverting
--- (which Hugs needs to do in order that combined mode works right.)
---
+-- See Note [CAF management] in rts/sm/Storage.c
link_caf :: LocalReg -- pointer to the closure
-> Bool -- True <=> updatable, False <=> single-entry
-> FCode CmmExpr -- Returns amode for closure to be updated
--- To update a CAF we must allocate a black hole, link the CAF onto the
--- CAF list, then update the CAF to point to the fresh black hole.
-- This function returns the address of the black hole, so it can be
--- updated with the new value when available. The reason for all of this
--- is that we only want to update dynamic heap objects, not static ones,
--- so that generational GC is easier.
+-- updated with the new value when available.
link_caf node _is_upd = do
{ dflags <- getDynFlags
- -- Call the RTS function newCAF to add the CAF to the CafList
- -- so that the garbage collector can find them
- -- This must be done *before* the info table pointer is overwritten,
- -- because the old info table ptr is needed for reversion
+ -- Call the RTS function newCAF, returning the newly-allocated
+ -- blackhole indirection closure
; let newCAF_lbl = mkForeignLabel (fsLit "newCAF") Nothing
ForeignLabelInExternalPackage IsFunction
; bh <- newTemp (bWord dflags)