<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On 2008-04-20, at 21:05, Terence Parr wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Apr 20, 2008, at 5:36 PM, Gordon Henriksen wrote:</div></div></div></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Since the semispace heap doesn't actually work (it's an example, at best), I suggest you simply copy the stack visitor into your project; it's only a dozen lines of code or so.</span></div></blockquote></div><div><div><br></div>Ok, copying; can't find ShadowStackEntry though. Even make in that dir doesn't work:</div></div></blockquote><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Please use the version from subversion; this is broken in 2.2 release, unfortunately.</div><div><br></div></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">how does the gc "shadow-stack" gcroot intrinsic work exactly? I couldn't read the assembly very well. Seems my example above wouldn't work would it unless i create/fill in a shadow stack record?</span></div></blockquote></div></div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"></blockquote></div><div></div></div></blockquote><div><br></div><div>'gc "shadow-stack"' in the LLVM IR instructs the code generator to automatically maintain the linked list of stack frames. You don't have to do anything to maintain these shadow stack frames except to keep your variables in the llvm.gcroot'd allocas. Essentially, it does this:</div><div><br></div><div> struct ShadowStackEntry {</div><div> ShadowStackLink *next;</div><div> const ShadowStackMetadata *metadata;</div><div> void *roots[0];</div><div> };</div><div> </div><div> template <size_t count></div><div> struct Roots {</div><div> ShadowStackLink *next;</div><div> const ShadowStackMetadata *metadata;</div><div> void *roots[0];</div><div> };</div><div> </div><div> ShadowStackEntry *shadowStackHead;</div><div> </div><div> // Defined by the code generator.</div><div> const ShadowStackMetadata f_metadata = ...;</div><div> </div><div> void f() {</div><div> Roots<3> roots;</div><div> roots.next = shadowStackHead;</div><div> roots.metadata = f_metadata;</div><div> roots.roots[0] = NULL;</div><div> roots.roots[1] = NULL;</div><div> roots.roots[2] = NULL;</div><div> shadowStackHead = (ShadowStackEntry *) &roots;</div><div> </div><div> ... user code ...</div><div> </div><div> shadowStackHead = entry.next; // before any exit</div><div> return;</div><div> }</div><div><br></div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Taking a giant step back, I can build something similar to semispace.c myself so I'm in control of my world, right? i would set up the shadow stack using IR instructions and could avoid gcroot by notifying my collector as I see fit... </div><div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; "></span></div></div></blockquote><div><br></div><div>That's true; the shadow stack design is explicitly for uncooperative environments, after all.</div><div><br></div><div>When you want to eliminate the shadow stack overhead, you will need to (a.) use a conservative GC or (b.) emit stack frame metadata using the LLVM GC support.</div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Sorry I'm so lost...just trying to figure out what llvm does for me and what I have to do.</span></div></div></blockquote><div><br></div>No problem!</div><div><br></div><div>Generally speaking, LLVM is going to help you find roots on the stack, which is the part that the compiler backend <i>must</i> help with; the rest is your playground. The infrastructure is more suited toward interfacing with an existing GC rather than necessarily making writing a new runtime trivial. (See exception handling for precedent…)<br><br></div><div apple-content-edited="true"><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; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><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; "><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; ">— Gordon<br class="Apple-interchange-newline"></span></span></span></span></span></div></span> </div><br></body></html>