<br><br><div class="gmail_quote">On Thu, Sep 3, 2009 at 12:17 AM, John M McIntosh <span dir="ltr">&lt;<a href="mailto:johnmci@smalltalkconsulting.com">johnmci@smalltalkconsulting.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>
I believe I had all the VMMaker changes in the alien vmmaker MC changesets. For the macintosh I have those in my current build image and currently I am merging in the production Vmmaker source.   Obviously it would be good if the alien vmmaker stuff was folded into the production vmmaker.<br>

<br>
Also there was some confusion about the earlier changes for vm callback submitted by qwaq a few years back.<br>
I have for example in my PRIVATE sqVirtualMachine.h (did I mention PRIVATE)  this code to expose the<br>
callbackEnter:  callbackID: addGCRoot  removeGCRoot<br>
<br>
If these are to be replaced by Alien then someone should clarify that since Mar on Squeak is exploiting the callbackEnter:<br>
to do Cocoa controller callbacks on os-x via the Objective-C plugin SqueakProxy logic<br></blockquote><div><br></div><div>SAo keep the callback machinery.  But I think we should not include the internalIsImmutable &amp; internalIsMutable calls, which are so far specific to Newspeak, (and that I misnamed; they should be isImmutable &amp; isMutable).</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
#if VM_PROXY_MINOR &gt; 7<br>
        sqInt  (*internalIsImmutable)(sqInt oop);<br>
        sqInt  (*internalIsMutable)(sqInt oop);<br>
        sqInt  (*primitiveFailFor)(sqInt code);<br>
        sqInt  (*classAlien)(void);<br>
        sqInt *(*getStackPointer)(void);<br>
        sqInt  (*sendInvokeCallbackStackRegistersJmpbuf)(sqInt thunkPtrAsInt, sqInt stackPtrAsInt, sqInt regsPtrAsInt, sqInt jmpBufPtrAsInt);<br>
        sqInt  (*reestablishContextPriorToCallback)(sqInt callbackContext);<br>
        sqInt  (*classUnsafeAlien)(void);<br>
        /* New methods for proxy version 1.8 */<br>
        <br>
        /* callbackEnter: Re-enter the interpreter loop for a callback.<br>
        Arguments:<br>
        callbackID: Pointer to a location receiving the callback ID<br>
        used in callbackLeave<br>
        Returns: True if successful, false otherwise */<br>
        sqInt (*callbackEnter)(sqInt *callbackID);<br>
        <br>
        /* callbackLeave: Leave the interpreter from a previous callback<br>
        Arguments:<br>
        callbackID: The ID of the callback received from callbackEnter()<br>
        Returns: True if succcessful, false otherwise. */<br>
        sqInt (*callbackLeave)(sqInt  callbackID);<br>
        <br>
        /* addGCRoot: Add a variable location to the garbage collector.<br>
        The contents of the variable location will be updated accordingly.<br>
        Arguments:<br>
        varLoc: Pointer to the variable location<br>
        Returns: True if successful, false otherwise. */<br>
        sqInt (*addGCRoot)(sqInt *varLoc);<br>
        <br>
        /* removeGCRoot: Remove a variable location from the garbage collector.<br>
        Arguments:<br>
        varLoc: Pointer to the variable location<br>
        Returns: True if successful, false otherwise.<br>
        */<br>
        sqInt (*removeGCRoot)(sqInt *varLoc);<br>
#endif<div><div></div><div class="h5"><br>
<br>
<br>
On 2-Sep-09, at 7:00 PM, Eliot Miranda wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
On Wed, Sep 2, 2009 at 9:54 AM, Andreas Raab &lt;<a href="mailto:andreas.raab@gmx.de" target="_blank">andreas.raab@gmx.de</a>&gt; wrote:<br>
<br>
Actually, I think Michael&#39;s question was more on an immediate basis. As it stands there is a significant number of patches that one needs to scrape from the four corners of the universe before one can even begin to build the Alien FFI plugin. It would be helpful if this could be folded into VMMaker so that the plugin can be built out of the box.<br>

<br>
Right.  But before it can go into the VM we need to throw away the x86-specificities.  And that means splitting the data manipulation facilities from the ABI machinery.  I can do that, but Michael volunteered :)<br>
<br>
I think the pragma issue has already been solved right?  There was a commit for the compiler yesterday that did that.<br>
<br>
<br>
Cheers,<br>
 - Andreas<br>
<br>
Eliot Miranda wrote:<br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
<br>
<br>
<br>
On Wed, Sep 2, 2009 at 9:08 AM, Michael Haupt &lt;<a href="mailto:mhaupt@gmail.com" target="_blank">mhaupt@gmail.com</a> &lt;mailto:<a href="mailto:mhaupt@gmail.com" target="_blank">mhaupt@gmail.com</a>&gt;&gt; wrote:<br>

<br>
<br>
   Hi,<br>
<br>
   would it be a problem to package Alien support with the VMs by<br>
   default? Are there any reasons for not doing it? Can I help making<br>
   this happen?<br>
<br>
   I think delivering standard images with Alien right away would be a<br>
   strong plus, but of course the VMs need to support that.<br>
<br>
<br>
Two things need to happen.<br>
1. Alien&#39;s data manipulation facilities need to be separated from Alien&#39;s very limited call facilities.<br>
2. FFI&#39;s marshalling needs to be extended to marshal Aliens.<br>
<br>
Alien&#39;s call support only works on very simple ABIs such as typical IA32 (x86) ones.  As soon as one confronts a machine with a register-based calling convention the simple approach falls apart for many cases (structure arguments, floating-point).<br>

<br>
Further on I want to build an ABI interface compiler above the JIT that can efficiently marshal arbitrary calls in arbitrary ABIs, essentially reimplementing libffi.<br>
<br>
So Michael, it would help if you would extract the data manipulation parts of the IA32ABI plugin into e.g. Alienlugin and rewrite all the data manipulation methods to use it.  Then shoe-horn Alien marshalling into the FFIPlugin.<br>

<br>
<br>
Why reimplement libffi instead of use it directly?<br>
<br>
First, libffi only does call-outs, not call-backs.  Alien&#39;s callback architecture is quite nice; one gets a pointer to a register struct (null on x86) and the stack pointer at the point of callback, wrapped up in Aliens and extracts the arguments there-from.  But this needs to be wrapped up in some platform-specific abstractions to present the programmer with a portable interface.<br>

<br>
Second, libffi does nothing to help translating Smalltalk objects to C equivalents (mapping String instances to to null-terminated char * or wchar_t * arrays, etc, etc).<br>
<br>
Third, libffi&#39;s architecture involves building up an AST of a call signature, passing the AST to a compiler which answers some marshalling thunk, and then using the marshallng thunk to make a call.  The AST and the marshalling thunk are C objects that one has to associate with e.g. a Smalltalk compiled method and arrange that if the compiled method is GCed the marshalling thunk is reclaimed.<br>

<br>
Fourth, the marshalling thunk itself looks to be interpreted, and to apply it one must call the marshaling machinery with the thunk and a pointer to the vector of arguments, to have the call made.  This is a little bit too much intervening machinery.<br>

<br>
I&#39;d rather have the JIT build the marshalling code directly into the machine code generated for an external call method, translating some RTL sequence that describes the marshalling operations in a platform-specific manner, and write the call spec to RTL compiler in Smalltalk and have it live in the image.<br>

<br>
libffi makes a great reference for the ABI semantics, and can also be a source of tests.<br>
<br>
<br>
   Best,<br>
<br>
   Michael<br>
<br>
<br>
cheers!<br>
Eliot<br>
<br>
</blockquote>
<br></div></div><font color="#888888">
--<br>
===========================================================================<br>
John M. McIntosh &lt;<a href="mailto:johnmci@smalltalkconsulting.com" target="_blank">johnmci@smalltalkconsulting.com</a>&gt;   Twitter:  squeaker68882<br>
Corporate Smalltalk Consulting Ltd.  <a href="http://www.smalltalkconsulting.com" target="_blank">http://www.smalltalkconsulting.com</a><br>
===========================================================================<br>
<br>
<br>
<br>
<br>
</font></blockquote></div><br>