<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Apr 22, 2008, at 3:27 PM, Gordon Henriksen wrote:</div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div>If you'd like to propose clarified language once you've wrapped your head around the framework, I'd be happy to incorporate it. Most ideally, submit a patch against GarbageCollection.html in <a href="http://llvm.org/svn/llvm-project/llvm/trunk/docs/">http://llvm.org/svn/llvm-project/llvm/trunk/docs/</a>.</div></div></div></div></blockquote><div><br></div>Cool. Ok, I have already submitted some svn diffs to Chris to fix typos.</div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><font class="Apple-style-span" color="#144FAE"><br></font>What I was/am missing is the explicit link between types and <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">variables in a GC.c file and the generated machine code. If I can get that last explicit link, I'm off to the races.</span></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">You mean, how do you know what sort of object you're tracing?<br></blockquote><br>I assumed that I needed to generate my object maps or at least a list of pointers for each object type. Related to that, i have two important questions:<br><br>1. How do I know the offset (due to alignment/padding by LLVM) of a pointer within an object using {...} struct type? GEP instruction gets an address, of course, but how does my C collector compute these. Do I need to make a metadata struct and fill it with GEP instructions? I guess that makes sense.<br></blockquote><div><br></div><div>You can use a constant expression to compute this. Specifically:</div><div><br></div></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">i32 ptrtoint(gep %mytype* null, i32 0, i32 ??? to i32)</blockquote><div><br></div>Where ??? is the number of the field within the struct. (Could be a list of indices.)</div></blockquote><div><br></div>Wow! Cool trick. I have verified that this and the next works. BTW, I had no idea that that nested notation was possible! How did I miss that in the documentation...</div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><blockquote type="cite">2. How do I know how big a struct is? I have my gc_allocate() method</blockquote><div><br></div>Note: There's absolutely nothing special about the name @llvm_gc_allocate, it's just a gentle suggestion. In fact, if you're using the "model 1" heap tracing strategy, you probably want to use something like this:</div><div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">%class.object* @alloc_object(%runtime.class* %vtable, i32 %nbytes)</blockquote></div></blockquote><div><br></div>an excellent idea. At the moment I am just doing structs not objects so that I can figure things out.</div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">You can again use a constant expression here. Specifically:</span></div><div><div><br></div></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">i32 ptrtoint(gep %mytype* null, i32 1 to i32)</blockquote><div><div><br></div><div>ConstantExpr has a helper similar to sizeOf(Type*) which build this expression.</div></div></div></blockquote><div><br></div>I'm always using the pure text input headline generating everything from Java...</div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><blockquote type="cite"><blockquote type="cite"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; "><font class="Apple-style-span" color="#144FAE"><span class="Apple-style-span" style="-webkit-text-stroke-width: 0;"><br></span></font>• If you have a type forest (as in C or C++) with optional vtables, then no such assumption is possible, and you can include type layout information in the %metadata parameter to @llvm.gcroot. The FrameMap type includes this data.</span></blockquote></blockquote><blockquote type="cite"><br>Ok, so I pass it an arbitrary struct pointer and it just gives it back later for me to peruse, right?<br></blockquote><div><br></div><div>Yep! You can use any constant pointer (which means: any global variable, alias, or function). For example, something like this:</div><div><br></div></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"></blockquote><div><br></div></div></blockquote>[snip]</div><div><br></div><div>Oooooooh! man! that is exactly what I was looking for. hooray! Input/Output pairs are the best way to learn this stuff as far as I can tell.</div><div><br></div><div>I believe I have enough from this to construct a collector using the "shadow-stack" mechanism. thanks so much!</div><div><br></div><div>"All our roots are belong to you!"</div><div><br></div><div>Ter</div></body></html>