Hi Eliot. Now I found another thing which took my attention. I would also like to trace when objects receives messages from the special selectors (special bytecode associated). So for example, I would like to trace an object that receives the message #new, #x, etc etc etc. With a StackVM I need to call my method #traceObjectUsage: from the bytecodePrim* methods. Usually, only when those methods answers before than the #normalSend. For example, in #bytecodePrimAdd I trace both the argument and the receiver when they are floats. If I do not add my sends to #traceObjectUsage:, then they receivers are not marked (logically).<br>
<br>Now, what I don&#39;t understand is what happens with CogVM. In Cog, even if I don&#39;t put my calls to #traceObjectUsage:  the receiver is always marked. I guess this is because I have put #traceObjectUsage: in a lot of general places of Cog. The &quot;problem&quot; is that with #class and #== the receiver is not marked  (right now I don&#39;t want to discuss whether I should trace this or not) . Previously, with StackVM, if I have the call to #traceObjectUsage: in #bytecodePrimClass and #bytecodePrimEquivalent  then the receiver is marked perfectly. But with Cog I noticed that it doesn&#39;t matter what I put in #bytecodePrim*   because they seem they are never executed.  Is this correct?  Are these special bytecode always jitted from the very first time?  or they are jitted on demand (when they are found in the cache) like the rest of the normal methods ?    And the main question, what can be the cause of why I can trace with all the #bytecodePrim*  but not with #class and #== ?   I am obviously missing a place where I should trace....<br>
<br>Thanks a lot in advance,<br><br><br><br><div class="gmail_quote">On Mon, Dec 26, 2011 at 10:00 AM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>Then the test fails in  self assert: (tracer isMarked: obj2).  I imagine it is because it is executing the machine code of #foo: . So my question is if there is a way where I could intercept and trace the receiver also there?   I tried to do it but I failed.<br>


</blockquote><div><br></div></div><div>See the flag word traceLinkedSends in cogit.c.  A bit in the flags causes the JIT to generate a call at the start of a method for tracing:</div><div><br></div><div>#define recordSendTrace() (traceLinkedSends &amp; 2)</div>


<div><br></div><div>The result is that ceTraceLinkedSend is called on every send.</div><div><br></div></div></blockquote><div><br>Wow. I cannot believe how easy it was :)  Thanks Eliot. So what I did is to change Cogit class &gt;&gt; declareCVarsIn:  <br>

to set 2 rather than 8: <br><br>        var: #traceLinkedSends<br>            declareC: &#39;int traceLinkedSends = 2&#39;;<br>    <br><br>And then just add my tracing stuff in #ceTraceLinkedSend<br><br>Thank you very much Eliot and Happy Christmas to all VM hackers<br>

<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div></div><div>HTH</div><div>Eliot</div><div><div class="h5"><div>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>Thanks a lot in advance,<br><br><br><br><div class="gmail_quote">On Fri, Dec 23, 2011 at 11:23 AM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div><br>Weird ehh, because you use #internalStackValue:  along StackInterpreter in a lot of other places and you don&#39;t have problems there. <br>
</div></div></blockquote><div><br></div></div><div>Turns out it&#39;s not weird at all.  Since  lookupInMethodCacheSel:class: is used outside of interpret in findNewMethodInClass: and in callback lookup it can&#39;t be inlined and hence can&#39;t access localSP.  </div>




</div></blockquote><div><br><br>Hi Eliot. Thanks for you answer. It also turns out that I don&#39;t know enough about SLANG ;)  so it was not weird at all but expected. Ok, I am learning in the way. So I understand that sentence. But  (down)<br>




 </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div>If you want to get the receiver you&#39;ll need to use stackValue: *and* you&#39;ll need to ensure that stackPointer is updated when calling lookupInMethodCacheSel:class: from internalFindNewMethod (see externalizeFPandSP), which may slow down the interpreter slightly.</div>





<div><br></div></div></blockquote><div><br>I DO understand what #externalizeFPandSP does, but what I don&#39;t understand is why I should only do it in #internalFindNewMethod. I mean, what happens with all the rest of the senders of #lookupInMethodCacheSel:class:   ?  maybe if one of those senders do not update stackPointer (externalizeFPandSP), then in #lookupInMethodCacheSel:class:  I will be accessing something wrong ? <br>




<br>Anyway, I wanted to trace the receiver in #lookupInMethodCacheSel:class:  to avoid doing it in all its senders. But with the problem found, I workarrounded by tracing the receiver in its senders (only those inlined) and that seems to work :)<br>




<br><br> </div><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div class="gmail_quote"><div>
<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div> You&#39;re going to have to delve into the inliner in Slang.  This is, um, not fun.  I liken it to getting hit on the head with a stick by your guru, except that no enlightenment results.  Good luck.</div>







<div><br></div></div></blockquote><div><br>:(   thanks. <br><br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div>






</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>Thanks in advance,<br><br><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>








<br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
<br></blockquote></div></div><span><font color="#888888"><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>
<br></blockquote></div></div></div><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br>best,<div>Eliot</div><br>
<br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>