Improving the aesthetics and usability of Squeak

Stephen Pair spair at acm.org
Wed Jul 10 01:05:50 UTC 2002


I actually did start to do this a while ago but dropped it...it's just
too much work for little payout (for me anyway)...it would be a nice
thing to have though.  The StrongTalk approach does sound efficient...I
think when dealing in this area, it's best to give Smalltalk access to
the lowest levels.  This may mean that you have to have abstractions
that deal with different hardware architectures, but it gives you the
opportunity to hook in at the lower levels if you need the speed.  Of
course, you could argue that if you need the speed, do it as a plugin.
When I started an FFI like thing, I actually abstracted the different
calling conventions and CPU architectures for the call outs.  I hand
coded two chunks of machine code (cdecl and apicall) for Intel and stuck
them in ByteArrays.  Then I had a primitive with a jump instruction
right into the ByteArray!  Later I thought it might be cool to have a
whole development environment in Squeak for doing assembly coding (but
of course we'd jump into the ByteArrays using another process).

Speaking of neat uses for callbacks...I did a neat thing in the
BerkeleyDB plugin using a callback.  BDB allows you to specify a
callback for the memory allocation function used when fetching bytes
from the database.  I used that opportunity to go ahead and allocate a
ByteArray.  BDB happily writes the data directly into the ByteArray
(note: this is safe because BDB only uses the allocated memory
immediately after the callback...which brings up another issue for VM
people, see (*) below).  This saves the overhead of allowing BDB to
allocate and return the pointer, then the plugin allocating a ByteArray,
and then do the memcpy (so it saves 1 allocation and 1 memcpy).

(*) A nice feature to add to the VM would be the ability to allocate an
object without the risk of invoking GC (if there's no room, the
operation just fails).

- Stephen

> -----Original Message-----
> From: squeak-dev-admin at lists.squeakfoundation.org 
> [mailto:squeak-dev-admin at lists.squeakfoundation.org] On 
> Behalf Of Andreas Raab
> Sent: Tuesday, July 09, 2002 7:55 PM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: RE: Improving the aesthetics and usability of Squeak
> 
> 
> > No thanks...I don't want it that bad.  ;)
> 
> Ah, c'mon. You are one of the few people who could actually 
> pull it off. BTW, I noticed something cute in StrongTalk - 
> for callbacks they pass a pointer to stack back into the 
> handler which you then use to access the arguments. I found 
> this a pretty elegant solution because it prevents excessive 
> type coercions from the callback instances. Using this trick 
> it seems pretty possible just to have a "fixed number" of 
> callback instances (say, 128 or so since they'd be tiny) and 
> handle everything without any native code generation. Nifty stuff.
> 
> Cheers,
>   - Andreas
> 
> 
> 




More information about the Squeak-dev mailing list