Scientific Computing

Dan Ingalls DanI at wdi.disney.com
Wed Sep 2 17:41:46 UTC 1998


Kyle -

>I had the impression that the Smalltalk-to-C translator in Squeak is limited
>in terms of the breadth of possible Smalltalk functions that it can
>translate.  That is, it does a great job of translating the essential Squeak
>VM into C, but was never intended for much more than that.  I thought I
>would have to write extensions in C in order to get that kind of performance
>improvement in any kind of app-specific code.  Can anyone identify what the
>practical limits are to this translation facility?  (I posted the same
>question awhile back, but got no responses).

You're right that the translator was designed with the sole intent of translating the ST VM.

However a better way of characterizing its limitation is that it can (or can usually be extended to) translate most patterns that have a straigtforward implementation in native code.  This is actually a fairly useful space.  I just imagine that I am writing a method in machine code, but using Squeak as my language.  Arithmetic, simple control and array accesses get translated to C, and then compiled into native code.

The translator has been used successfully for music synthesis, bitmap compression, fast string comparisons.  Examples in the image include...

	Smalltalk browseAllSelect: [:m | (m primitive between: 176 and: 237)
			and: [(m primitive between: 185 and: 233) not]]

General message sends (ie dynamic and/or polymorphic lookup) are not supported.  The best way of thinking of it right now is it's a way to write native code for inner loops.  For many applications, this is just what you need, but if you have a big ball of general Smalltalk with no inner loops, then it won't help.

It's my hope that we will soon move forward with our VM technology (Ian is working on Jitter II) so that everything will speed up significantly.  But right now we're still going flat out with other priorities such as network integration, graphics, and sound.  Moore's law continues to fill in for the mild inefficiencies of Squeak's current VM, but if you have a simple inner loop, the translator can probably give you a factor of 20-30x.

	- Dan

P.S.  For various reasons that have been discussed on this list before (notably sound and image processing), it is likely that we will soon add some Float array operations to Squeak.  It may be that we will do this by using a general API, but we have not yet sorted out all the portability vs VM size issues.





More information about the Squeak-dev mailing list