<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; ">LLVMers,</span></span></span></div><div><br class="webkit-block-placeholder"></div><div><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; ">Attached for your review: basic infrastructure for efficient garbage collectors. Only enough information is currently gathered to support the runtime I'm working with, and -print-gc is currently the only consumer of this information.</span></span></span></div><div><br class="webkit-block-placeholder"></div><div>All collector policies are presently controlled by constants. There are no regressions (on darwin-i686) if the feature is left disabled. If enabled (EnableGC = true in GC.cpp), the JIT breaks because it doesn't support labels.</div><div><br class="webkit-block-placeholder"></div><div>This obviously needs to be fixed; the collector needs to be turned on and off by a policy object. I'm not sure where best to hang that object off of, though.</div><div><br class="webkit-block-placeholder"></div><div> 1. Attach it to Target/Subtarget?</div><div> 2. Attach it to Function, like the calling convention?</div><div><div> 3. Attach a whole-new TargetCollector (TargetRuntime?) to the Module?</div><div><br></div><div>#1 is simplest, but I think wrong. #2 seems best to me. It would let the inliner merge bare code with managed code, or vice versa, but avoids the risk of silliness like inlining Java into Ocaml.</div><div><br class="webkit-block-placeholder"></div><div>Opinions?</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div>Once a decision is made on that, I'll resurrect the shadow stack GC to ensure I'm maintaining generality. There exists great variability in collectors, so supporting several is important, I think. To support:</div><div><br class="webkit-block-placeholder"></div><div>  [1] no collector</div><div>  [2] ocaml collector</div><div>  [3] shadow stack collector</div><div>  [4] collectors for concurrent systems</div><div>    [4a] zero overhead: safe points are patched to jump into the runtime</div><div>    [4b] intrusive: code must check a "stop" flag at each safe point</div><div>  [5] cooperative collectors, where mutators help with collection</div><div>  [6] incremental and generational collectors</div><div><br class="webkit-block-placeholder"></div><div>I see need for the target-independent code to support the following:</div></div><div><br class="webkit-block-placeholder"></div><div>  • Disable GC? [1*]</div><div>  • Find safe points in tight loops? [4]</div><div>  •    "   at calls? [4]</div><div>  •    "   after calls? [2*]</div><div>  •    "   before returning? [4]</div><div>  • Pad safe points with noops to accommodate a patch? To how many bytes? [4a]</div><div>  • Allow roots in registers? Otherwise force roots into stack slots at safe points [2].</div><div><br></div><div>And additionally provide callbacks to:</div><div><br class="webkit-block-placeholder"></div><div>  • Custom lower gcread/gcwrite intrinsics [5,6]. Otherwise replace with plain load/store [2,3*].</div><div>  • Custom lower gcroot intrinsics [3*]. Otherwise leave for the code generator [2*].</div><div>  • Introduce code at safe points [4b].</div><div>  • Print assembly for per-function metadata.</div><div>  • Print assembly for whole-module metadata [2*].</div><div>  • Record collector metadata in a JIT context.</div><div><br></div><div>Luckily, only those marked with [*] are current needs. :)</div><div><br><div><br class="webkit-block-placeholder"></div><div>Thanks for your feedback!</div><div><br class="webkit-block-placeholder"></div><div>Gordon</div><div> </div><br></div><div><br class="webkit-block-placeholder"></div><div><span></span></div></body></html>