Low level bit fiddling with Squeak

Lex Spoon lex at cc.gatech.edu
Tue Jan 12 15:02:54 UTC 1999


"Jonathan A. Smith" <jsmith at cognitivearts.com> wrote:
> 
> I am seriously considering a project that will require high performance
> handling of large, sparse, bit maps.  It seems to me that the best way to
> implement that kind of processing within Squeak is to use the Smalltalk-to-C
> translator to add a few new primitives.  I have not yet jumped in to reading
> the VM code, but I have a few questions.
> 
> 1.  What is the best programming platform for this kind of work.  I can work
> under Lynux, PC, or Mac.  I am more familiar with the Unix and Mac
> environments.  What tools would I need?
> 

A C compiler is pretty much it.  Otherwise all of these are fine.


> 2.  What is the best way to get started?  Is it reasonably easy to add a new
> primitive?

If you are comfortable with C development, it's not bad.  I used Stephen Travis Pope's writeup to figure it all out:

	http://www.create.ucsb.edu/squeak/DIYSqPrims.html

> 
> 3.  Once I have completed my changes (well, somewhere down the road) what
> would be the best way to make sure they are portable?  How can I make sure
> that the changes can be integrated into future Squeak versions?
> 

You mean, how do you know a future version of Squeak won't break your changes?  You don't.  The mechanism for changing primitives doesn't change to often (it hasn't yet), so that will most likely be fine (though who knows?).  However, the actual contents of the image are being messed with all the time.

Your odds will be improved, though, the less you rely on system details.  Stream and Set are unlikely to go away.  The protocols in Morph, however, are still undergoing change.  So be careful what you rely on.



> 4.  Is there some kind of hook to allow external DLLs? Is there some other
> way to make the new primitives available to other Squeak users?

Yes.  It works the same way as with regular primitives, except:

	1) Instead of compiling them into the Squeak code and adding them to the primitive table, you compile them into a DLL

	2) You call them by name instead of by primitive number; the syntax is something like this:

		<primitive: 'myPrimitive'  module: 'foo'>


Incidentally, it would be nice of you to distribute source code as well as DLL's, if your changes make sense on non-Windows systems.  But it will work if you just distribute the DLL's.



Lex





More information about the Squeak-dev mailing list