Hi Javier,<br><br><div class="gmail_quote">On Thu, Mar 31, 2011 at 6:11 AM, Javier Pimás <span dir="ltr">&lt;<a href="mailto:elpochodelagente@gmail.com">elpochodelagente@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;">
Hi, we are having a problem with callbacks in alien and we would like to see if we are doing something wrong or if it is a bug in the implementation (for the standard old vm).<div><br></div><div>We are receiving the callback just in the middle of a primitiveExternalCall (actually to a function that will fail because the plugin is not present, but i don&#39;t think that&#39;s important). We pinned it to occur always in the same line, which is </div>


<div><br></div><div><div><span style="white-space:pre-wrap">        </span>longAtput((lit + (BASE_HEADER_SIZE)) + (2 &lt;&lt; (SHIFT_FOR_WORD)), ConstZero);</div></div><div><br></div><div>of primitiveExternalCall. When the callback occurs, the thunkEntry is called, which if we understand correctly, saves the active context and runs the interpreter by calling sendInvokeCallbackStackRegistersJmpbuf. The problem is that things like messageSelector and lkupClass, which are global variables are not saved while saving the context, and when the callback returns, the last line of primitiveExternalCall,</div>


<div><br></div><div><div><span style="white-space:pre-wrap">                </span>rewriteMethodCacheSelclassprimIndex(messageSelector, lkupClass, 0);</div>

</div><div><br></div><div>puts a 0 in the wrong place. Also, probably as las message sent was primReturnFromContext:through: (because we just returned from the context), we get a primitiveFailed, but not for the original called function but for primReturnFromContext:through:.</div>


<div><br></div><div>What do you think? are we missing something?</div></blockquote><div><br></div><div>Looks like a bug to me.  I think the rewriteMethodCacheSelclassprimIndex(messageSelector, lkupClass, 0); line needs to be moved before the call.  I&#39;ll take a look soon.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><br></div><div>Regards,</div><div>            Javier.</div><div><br></div><font color="#888888"><div>
<br></div><div><div>-- <br>Javier Pimás<br>Ciudad de Buenos Aires<br>


</div></div>
</font></blockquote></div><br>