how does a CAF become unreachable?

Simon Peyton Jones simonpj at microsoft.com
Tue Oct 12 22:10:07 UTC 2021


|  Can anyone show an example?

Sure

	xs = [1..1000] :: [Int]
	ys = [2..2000] :: [Float]

	main = do { print xs; print ys }

After printing xs, the CAF for xs is unreachable and can be GC'd.  No point in keeping it around.   Indeed this applies from the moment (print xs) begins work.  But it was
	main = do { print xs; print xs }
then the CAF for xs remains reachable until the second (print xs) starts.

Simon


PS: I am leaving Microsoft at the end of November 2021, at which point simonpj at microsoft.com will cease to work.  Use simon.peytonjones at gmail.com instead.  (For now, it just forwards to simonpj at microsoft.com.)

|  -----Original Message-----
|  From: ghc-devs <ghc-devs-bounces at haskell.org> On Behalf Of Norman
|  Ramsey
|  Sent: 12 October 2021 21:55
|  To: ghc-devs at haskell.org
|  Subject: how does a CAF become unreachable?
|  
|  I spent the afternoon spelunking through some code and the Commentary,
|  and I'm wondering how a CAF becomes unreachable.  I gather it might
|  have to do with GHC floating a static expression out of a context
|  until it becomes a CAF, but I'm still not seeing how a CAF could at
|  one point be reachable, then dynamically become unreachable.
|  
|  Can anyone show an example?
|  
|  
|  Norman
|  _______________________________________________
|  ghc-devs mailing list
|  ghc-devs at haskell.org
|  https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.
|  haskell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fghc-
|  devs&data=04%7C01%7Csimonpj%40microsoft.com%7C788a90f23049467d7636
|  08d98dc2c6ca%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637696690459
|  913210%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJ
|  BTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=8eSDcyPcNe4gSTnKJc8OQcqQI
|  %2B%2FDf9lSp3OksAV0H%2BU%3D&reserved=0


More information about the ghc-devs mailing list