Towards Threaded FFI

17 January, 2016


Eliot Miranda writes:

.. I expect this is the year [the threaded FFI] will be [production ready].  Spur provides pinning, so the VM infrastructure is there.  The Pharo community plus some commercial relationships that have developed are providing funding.  Esteban Lorenzano and I want to collaborate on this and I hope to get help from some other people, such as Ronie Salgado.  And Mariano is working on an important part of the problem.  So I feel there’s sufficient momentum for us to realize the threaded FFI this year.

.. and when Craig Latta tried to use it late last year it worked up to a point.  The thing that didn’t work was callbacks from foreign threads.  So it looks like the core threading code is not too far away from working.

Another really important part, bigger than threading, is marshaling.  Being able to handle the full x86_64 abi requires a better approach than interpreting tops signatures.  Igor’s NativeBoost gave an example of how to generate marshaling machine code, but alas only for x86.  But Sista includes an extensible bytecode set for arbitrary instructions.  Sista is close to production, and we know the bytecode set works.  So the plan is to use these bytecodes to do the marshaling.  That neatly solves the problems of a) associating marshaling machine code with a method and b) marshaling in an interpreted stack VM, since the bytecode set works in any Cog VM.  So the plan is to write an ABI compiler from C signatures to marshaling code to replace the interpreted FFI plugin.

So this year I hope we will have an excellent high-performance FFI.

Aliens coming to Squeak

8 December, 2008

Aliens approaching Squeak

John McIntosh has ported Newspeak‘s Aliens FFI implementation to Squeak. John notes that the port is in its early days, and more work and support will be needed to implement Aliens support across the full range of Squeak platforms.

As a result of this interest in Aliens, Gilad Bracha has written a post giving an overview of Aliens, the thinking that went into it, and how it works. FFI allows a programming language to make use of services written in another language, and Gilad suggests that the lack of a standard, fully-featured FFI has been an ongoing problem for Smalltalk developers. In particular, John writes that “Squeak VM’S existing FFI has been found to be buggy bloated and slow” (though see Andreas’ comments on this below).

John’s code, under the Apache licence, is available at, and more information on his implementation can be found at the Alien swiki page.