<br><br><div class="gmail_quote">On Thu, Feb 12, 2009 at 9:15 AM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@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><br><div class="gmail_quote"><div class="Ih2E3d">On Thu, Feb 12, 2009 at 1:32 AM, Andreas Raab <span dir="ltr">&lt;<a href="mailto:andreas.raab@gmx.de" target="_blank">andreas.raab@gmx.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Folks -<br>
<br>
Has anyone tried porting the FFI to 64 bit? I&#39;m loosely considering using a 64bit VM for our servers but I do need the FFI (mostly for ODBC integration) and I&#39;ve never looked at any of the ABIs. Alternatively, is it reasonable to try to use 64bit libs from within a 32bit Squeak VM?</blockquote>

<div><br></div></div><div>Depends on what one wants to pass through the FFI. &nbsp;On x86-64/EMT64 structure passing conventions are efficient and complex, distributing structure fields across integer and floating-point registers. &nbsp;It is possible to interpret such calls given a type signature for the structure to be passed (I did it for VisualWorks) but it is not easy and it is slow. &nbsp;I would counsel writing a proper ABI compiler in Smalltalk that generates e.g. RTL that is either interpreted or compiled by the VM to make the actual call.</div>

<div><br></div><div>In theory the use of 64-bit libs, provided one has the relevant FFI support should work fine. &nbsp;Smalltalk has the ability to deal with 64-bit and 128-bit values easily. &nbsp;But one does have to write all the support.</div>
</div></blockquote><div><br></div><div>I should expand on this, and could be completely wrong. &nbsp;One would have to use a 64-bit address space, which implies compiling the 32-bit VM using a 64-bit compiler. &nbsp;When DEC and ParcPlace co-implemented 32-bit VisualWorks (my first job on joining ParcPlace was to productise this port) we used the DEC C compiler&#39;s ability to define &quot;short&quot; (32-bit) pointers and put the executable in the lower 32-bits of the address space (google for e.g. -xtaso or taso). &nbsp;Hence the VM was a 64-bit executable which had a 32-bit Smalltalk living in the bottom 32-bits. &nbsp;If x86-64 compilers have the same short pointer support then the compilation of a 32-bit Squeak VM should be relatively easy. &nbsp;Otherwise one will have to define the longAt: longAt:put: et al machinery to extend 32-bit addresses into full 64-bit pointers and genuflect to the linker and/or memory allocator to get it to place the heap low in the address space.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div></div>
<div><br></div><div>To get acquainted with the de facto standard x86-64 ABI read the</div><div><span style="border-collapse:collapse;white-space:pre"><a href="http://www.x86-64.org/documentation/abi-0.98.pdf" target="_blank"><span style="font-family:arial, helvetica, sans-serif"><span style="font-size:small">System V Application Binary Interface AMD64 Architecture Processor Supplement</span></span></a><span style="font-family:arial, helvetica, sans-serif"><span style="font-size:small">&nbsp;</span></span></span><span style="font-family:arial, helvetica, sans-serif"><span style="font-size:small"><br>

</span></span></div><div><span style="border-collapse:collapse;white-space:pre"><span style="font-family:arial, helvetica, sans-serif"><span style="font-size:small">pages 13 through 22 (section Function Calling Sequence) paying particular attention to the 3 1/2 page algorithm for marshalling :)</span></span></span></div>

<div><span style="border-collapse:collapse;white-space:pre"><span style="font-family:arial, helvetica, sans-serif"><span style="font-size:small"><br>
</span></span></span></div><div><span style="font-family:arial, helvetica, sans-serif"><span style="font-size:small">and start going to bed earlier ;)</span></span></div><div class="Ih2E3d">
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Thanks for any info!<br>
<br>
Cheers,<br><font color="#888888">
 &nbsp;- Andreas<br>
</font></blockquote></div></div><br>
</blockquote></div><br>