Callbacks from C into Squeak

John M McIntosh johnmci at
Thu Dec 14 17:51:07 UTC 2006

Well you can't callback from C to Squeak, once you are in a primitive  
call the interpeter is suspended, triggering a GC event requires
special care to ensure object pointers you many have will still be  
valid (remapped) after the GC completes.  You can of course do a  
limited set of VM calls to manipulate or make new object, but that  
does not include running byte codes.  Likely this can be overcome by  
$ (euros preferred).

Other options include running a VM (or VMs) as a sub process and  
talking to it via pipes or shared memory areas for it to do  
computational work.  Technially this is done by mac carbon and unix  
VM when they run headless to provide support as a browser plugin.

On Dec 14, 2006, at 6:17 AM, daniel poon wrote:

> Callbacks from C into Smalltalk
> We currently use VSE (Visual Smalltalk Enterprise). If you have a C
> callback into VSE, while the callback is running, it is very difficult
> to debug. If the callback halts, or there is an error, you can't debug
> and resume in the normal way that you can in Smalltalk. Apparently  
> this
> is something to do with VSE using the machine stack as the Smalltalk
> stack.
> However, one of the nice things about VSE is: if I put a halt in the
> callback, will I see the entire stack, including the methods before  
> the
> initial entry into C. Also if I throw an exception in the call back
> that is not caught in the callback, will it be caught further down the
> stack by code running before the initial entry into C. If it a
> resumable exception, I can resume as per normal.
> Now, we do a lot of numerical computing, re-using all the C and  
> Fortran
> libraries that are already out there. It is common in a numerical
> library to use callbacks. Say you want to integrate f(x). The
> integrator is written in Fortran, and f(x) is written in Smalltalk.  
> You
> need a way for the integrator to call f(x), and you do that with a
> callback. So to leverage these libraries we need an easy way to do
> callbacks, and once you have a callback you need a way of debugging
> these callbacks that a mathematician (rather than a comuputer
> scientist) will feel comfortable with.
> So my questioin is: when you callback into Squeak from C/Fortran,
> can you throw and catch exceptions, halt, debug and resume execution
> of the callback in the normal Smalltalk way. Or does the fact that
> you are in a callback compromise Smalltalk's usual execution?
> Cheers
> Daniel

John M. McIntosh <johnmci at>
Corporate Smalltalk Consulting Ltd.

More information about the Squeak-dev mailing list