<div dir="ltr">Hi David,<div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 11, 2014 at 8:32 PM, David T. Lewis <span dir="ltr"><<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
On Thu, Dec 11, 2014 at 10:28:04AM -0800, Eliot Miranda wrote:<br>
><br>
> On Thu, Dec 11, 2014 at 3:12 AM, Bert Freudenberg <<a href="mailto:bert@freudenbergs.de">bert@freudenbergs.de</a>> wrote:<br>
> ><br>
> > On 11.12.2014, at 03:01, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br>
> ><br>
> > There's an oddity of a 32-bit VM compiled in 64-bit mode on a 64-bit<br>
> > machine. I don't know of anyone using it.<br>
> ><br>
> Right. But since the rationale for this VM is only to interface with<br>
> 64-bit libraries, it depends on a 64-bit FFI, which we do not have.<br>
<br>
I realize that this refers to the VMs and FFI implementations that are<br>
actually available in released VMs, but just for the historical record:<br>
<br>
A working 64-bit FFI has been available since 2008, but the patches were not<br>
adopted. Source patches and issue status are here:<br></blockquote><div><br></div><div>I'm sorry to be so relentlessly negative but are you sure this is a working FFI? Having read the change comments I see nothing which will cope with the key problem of implementing an FFI for x86_64 ABIs which is that struct parameters are fragmented across available integer and floating-point argument registers as available with the remainder being passed on the stack. So given</div><div><br></div><div>typedef struct {</div><div> long a;</div><div> double b;</div><div> long c;</div><div> double d;</div><div>} foo;</div><div><br></div><div>void (long p, foo s)</div><div><br></div><div>p is passed in arg reg 0, s.a in arg reg 1, s.b in fp arg reg 0, s.c in arg reg 2 and s.d in fp arg reg 1. AFAICT none of this is handled in the 2008 code. Am I wrong?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
<a href="http://bugs.squeak.org/view.php?id=7237" target="_blank">http://bugs.squeak.org/view.php?id=7237</a><br>
<br>
My intention had been to make this a top priority for the VM team circa 2009,<br>
but other priorities took precedence.<br>
<br>
Since then, the original FFI has been rendered obsolete by later development,<br>
and as a practical matter there is no 64-bit FFI available today.<br>
<br>
There were image side changes to the Mantis 7237 patches, and I'm not sure<br>
if these will be relevant to Eliot's newer FFI implementation. I'll try<br>
to look into this and report back if I find anything of interest.<br></blockquote><div><br></div><div>While I could cobble together an x86_64 FFI in the ThreadedFFIPlugin framework that depends on the argument metadata for structs being sufficiently detailed and I've yet to check that. But in any case such an interpreted implementation is doomed to have poor performance so I'm collaborating in producing a more powerful FFI framework that will use an in-image ABI compiler to generate and cache marshalling code just-in-time, targeting Ronie Salgado's Lowcode, the same RTL instruction set we're using to implement the optimized code for Sista. SO whether the existing FFI will properly support x86_64 will depend on whether the metadata is present, whether the new UFFI project is quick to deliver results or not, and how much time is available for a ThreadedX64FFIPlugin.</div><div><br></div><div>In the mean time I'll try and remember to add test cases to platforms/Cross/plugins/SqueakFFIPrims/sqFFITestFuncs.c that probe the fabulously complex x86-64 ABI.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Dave<br></blockquote></div><div><br></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div></div>