<div dir="ltr"><div dir="ltr">On Sat, 27 Apr 2019 at 07:44, Ömer Sinan Ağacan <<a href="mailto:omeragacan@gmail.com">omeragacan@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Simon,<br>
<br>
I'm wondering why in the GC we don't short out IND_STATICs like we do in INDs<br>
and BLACKHOLEs. Is there a reason for that? In this code in evacuate():<br>
<br>
      case IND_STATIC:<br>
          evacuate_static_object(IND_STATIC_LINK((StgClosure *)q), q);<br>
          return;<br>
<br>
Why not do something like<br>
<br>
      case IND_STATIC:<br>
          q = ((StgIndStatic*)q)->indirectee;<br>
          *p = q;<br>
          goto loop;<br>
<br>
I actually tried it and it broke a lot of things, but I don't understand why.<br>
We basically turn this<br>
<br>
    heap closure -> IND_STATIC -> heap closure<br>
<br>
into<br>
<br>
    heap closure -> heap closure<br>
<br>
To me this should work, but for some reason it doesn't. Could you comment on why<br>
this doesn't work?<br></blockquote><div><br></div></div><div class="gmail_quote">I think it might be to do with generational GC, although I'm not completely sure and it would be good to nail down the precise reasoning and document it.</div><div class="gmail_quote"><br></div><div class="gmail_quote">CAFs live in the old generation, and when we first enter a CAF we add it to the mutable list (remembered set). If we ignore the IND_STATIC, then the closure will never get re-added to the mutable list, even if it still points into the young generation. So the data will remain live for one GC, but not the next GC. When we do an old-generation GC we might find the CAF to be live (via the SRTs), but we've already GC'd the value it pointed to, so it's too late.<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">Cheers</div><div class="gmail_quote">Simon<br></div><div class="gmail_quote"> <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks,<br>
<br>
Ömer<br>
</blockquote></div></div>