<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Guidi,</div><div><br>On Mar 2, 2018, at 6:44 AM, Guido Chari <<a href="mailto:charig@gmail.com">charig@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><span></span></div></blockquote><blockquote type="cite"><div><div dir="ltr">Hi Eliot,<br><div class="gmail_extra"><br><div class="gmail_quote">2018-02-28 16:03 GMT+01:00 Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi Javier,<br>
<br>
<br>
> On Feb 28, 2018, at 5:16 AM, Javier Pimás <<a href="mailto:elpochodelagente@gmail.com" target="_blank">elpochodelagente@gmail.com</a>> wrote:<br>
><br>
> Hi! This time I'm investigating how cog jit handles pointers to objects in native code. In x86-32 its easier because you have immediates of the size of a pointer, but in x64 the immediates are restricted to 32bits (and I think less in arm).<br>
<br>
That's not quite right.  On x86_64 instructions can load 64-bit constants into registers.  What is restricted is loading/storing through a 64-bit immediate address.  That can only be done to/from %rax.  So when loading an arbitrary register from memory the JIT often generates sequences like:<br>
<br>
    xchgq %r15,%rax<br>
    moveq 123456789AB0,%rax<br>
    xchgq %r15,%rax<br>
<br>
> So I wonder how people works around that, if using a movabs instruction every time you need a pointer or if doing something else. I found a mail in the list dated from 2011 (titled "questions about cog internals") where you (Eliot) said that pointers were inlined in jit code, but I don't know if that's still the case.<br>
<br>
Yes.  The easy way to see this is to use in-image compilation.  e.g. in a VMMaker.oscog image (scripts to build them being in the image directory) run the following with a Transcript open:<br>
<br>
StackToRegisterMappingCogit<br>
    genAndDis: Object>>#printOn: "includes 'a ' and 'an '"<br>
    options: #(ObjectMemory Spur64BitCoMemoryManager)<br>
<br>
and the generated machine code method will be output to the transcript.<br></blockquote><div><br></div><div>There are plenty of scripts. I ran a few that failed while loading code. Could you point us to the one you are using?</div></div></div></div></div></blockquote><div><br></div><div><span style="background-color: rgba(255, 255, 255, 0);">image/buildspurtrunk64vmmaker.sh</span></div>image/buildspurtrunkvmmaker.sh<div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><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>
> Looking at the slang code I found CogOutOfLineLiteralsX64Compile<wbr>r, but it seems it is not used (yet?).<br>
<br>
Yes, we should implement this and see how it compares.  It's not particularly compelling in x86_64 because we can load 64-bit immediates inline but performance might differ significantly.<br>
<br>
> Cheers!<br>
> Pocho<br>
<span class="m_5200049313112914963HOEnZb"><font color="#888888">><br>
> --<br>
> Javier Pimás<br>
> Ciudad de Buenos Aires<br>
</font></span></blockquote></div><br></div></div>
</div></blockquote></div></body></html>