<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Aug 14, 2007, at 06:24, Gordon Henriksen wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>The two major problems I had really boil down to identifying GC points in machine code and statically identifying live roots at those GC points, both problems common to many collection techniques. Looking at the problem from that perspective makes the problem much more tractable, actually…</div></blockquote></div><br><div>Chris,</div><div><br class="webkit-block-placeholder"></div><div>This is much more generic than what I was originally thinking, but what do you think of providing a facility like this?</div><div><br></div><div><span class="Apple-style-span" style="font-family: Courier; ">    enum GCPointKind {</span></div><div><span class="Apple-style-span" style="font-family: Courier; ">      GCPSubroutineReturn,</span></div><div><span class="Apple-style-span" style="font-family: Courier; ">      GCPFunctionExit,</span></div><div><font class="Apple-style-span" face="Courier">      GCPSubroutineCall,</font></div><div><font class="Apple-style-span" face="Courier">      GCPBackBranch</font></div><div><span class="Apple-style-span" style="font-family: Courier; ">    };</span></div><div><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></div><div><font class="Apple-style-span" face="Courier">    class ??? {</font></div><div><span class="Apple-style-span" style="font-family: Courier; ">    public:</span></div><div><font class="Apple-style-span" face="Courier">      // Allows the code generator to avoid inserting unnecessary GC points.</font></div><div><font class="Apple-style-span" face="Courier">      bool RequiresGCPointsOfKind(GCPointKind Kind) const;</font></div><div><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></div><div><font class="Apple-style-span" face="Courier">      // If false, instructs the code generator to keep all GC roots on the</font></div><div><font class="Apple-style-span" face="Courier">      // stack at GC points.</font></div><div><font class="Apple-style-span" face="Courier">      bool SupportsRegisterRoots() const; // false for now...</font></div><div><font class="Apple-style-span" face="Courier">      </font></div><div><span class="Apple-style-span" style="font-family: Courier; ">      // Visits a GC point, including information necessary to identify all</span></div><div><font class="Apple-style-span" face="Courier">      // live GC roots in the stack frame.</font></div><div><span class="Apple-style-span" style="font-family: Courier; ">      virtual bool VisitGCPoint(MachineInstruction *Point,</span></div><div><font class="Apple-style-span" face="Courier">                                GCPointKind Kind,</font></div><div><font class="Apple-style-span" face="Courier">                                intptr_t *StackRoots, size_t StackCount,</font></div><div><font class="Apple-style-span" face="Courier">                                int *RegisterRoots, size_t RegisterCount);</font></div><div><font class="Apple-style-span" face="Courier">    };</font></div><div><br></div><div>That could enable several kinds of conservative collectors.</div><div><br class="webkit-block-placeholder"></div><div>The code generator would need to cooperate by:</div><div><br class="webkit-block-placeholder"></div><div> 1. Inserting nodes for GC points if required, recording the corresponding original Instruction*.</div><div> 2. Recording the physical location of each llvm.gcroot'd alloca.</div><div><br class="webkit-block-placeholder"></div><div>Later, a MachineFunctionPass could walk the MachineFunction to lower these nodes. Live roots can be identified using domination information.</div><div><br class="webkit-block-placeholder"></div><div>In addition to providing a stack and register map for building tables, such an interface offers a collector a chance to insert any necessary landing pads at exit/call/back-branch.</div><div><br class="webkit-block-placeholder"></div><div>If the collector supports it, LLVM could be allowed to scalarize GC roots down the road.</div><div><br class="webkit-block-placeholder"></div><div>— Gordon</div><br></body></html>