<div dir="ltr"><div dir="ltr">Or even better, it looks like cmmGetClosureType already combines the two for me.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 6, 2019 at 3:49 PM Andrew Martin <<a href="mailto:andrew.thaddeus@gmail.com">andrew.thaddeus@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Thanks. The source code of ghc-heap has led me to what I was looking for. That whole library hinges upon unpackClosure# (stg_unpackClosurezh), whose implementation opens with the telling:</div><div dir="ltr"><br></div><div dir="ltr">    info  = %GET_STD_INFO(UNTAG(closure));</div><div dir="ltr"><br></div><div>In CmmParse.y, we find the implementation of GET_STD_INFO, and just a few lines below is the INFO_TYPE macro. The combination of these (along with a cmm implementation of UNTAG, which I am still unsure of exactly how to accomplish) should do the trick.</div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 6, 2019 at 2:53 PM Matthew Pickering <<a href="mailto:matthewtpickering@gmail.com" target="_blank">matthewtpickering@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Unless I am misunderstanding you want something which works like ghc-heap.<br>
<br>
If so, perhaps these three files will be instructive?<br>
<br>
<a href="https://gitlab.haskell.org/ghc/ghc/blob/master/libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" rel="noreferrer" target="_blank">https://gitlab.haskell.org/ghc/ghc/blob/master/libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc</a><br>
<a href="https://gitlab.haskell.org/ghc/ghc/blob/master/libraries/ghc-heap/GHC/Exts/Heap/InfoTableProf.hsc" rel="noreferrer" target="_blank">https://gitlab.haskell.org/ghc/ghc/blob/master/libraries/ghc-heap/GHC/Exts/Heap/InfoTableProf.hsc</a><br>
<a href="https://gitlab.haskell.org/ghc/ghc/blob/master/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs#L25" rel="noreferrer" target="_blank">https://gitlab.haskell.org/ghc/ghc/blob/master/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs#L25</a><br>
<br>
Cheers,<br>
<br>
Matt<br>
<br>
On Wed, Feb 6, 2019 at 7:29 PM Andrew Martin <<a href="mailto:andrew.thaddeus@gmail.com" target="_blank">andrew.thaddeus@gmail.com</a>> wrote:<br>
><br>
> For an optimization I’m implementing, I’m trying to write an inline primop that gives me lets me inspect the closure type of an arbitrary heap-allocated value. I’m close to figuring this out, and the FCode machinery is starting to make sense, but one thing eludes me. Starting from a StgHeader, I get the info table pointer. This is easy since it’s the first field in the struct. But next I have to deference the info table pointer and get the closure type. There are two fields at the beginning of an info table that may or may not be present. I don’t know how to figure out if they are present or not. I suspect that there is something I can get out of DynFlags that tells me this, but I can’t find anything else in the stg-to-cmm pass that reads from an info table.<br>
><br>
> Sent from my iPhone<br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_4813859541152143770gmail_signature">-Andrew Thaddeus Martin</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">-Andrew Thaddeus Martin</div>