SqueakJS a Lively Squeak VM by Vanessa Freudenberg
Press "Execute" to step through bytecodes, "Return" to run until returning from the current method.
(work in progress - please visit the SqueakJS project homepage)
This VM is inspired by Dan Ingalls' "JSqueak/Potato" VM for Java.
Instance variables and indexable fields are held in a single array named "pointers". Word and byte binary objects store their data in arrays named "bytes" or "words". CompiledMethod instances have both "pointers" and "bytes". Float instances are not stored as words as in Squeak, but have a single "float" property that stores the actual number (and the words are generated on-the-fly when needed). Spur's "immediate" characters are regular objects made unique using a character table.
This scheme also trivially supports object enumeration (Squeak's nextObject/nextInstance primitives): If the object is old, the next object is just the next link in the list. Otherwise, if there are new objects (newSpaceCount > 0) a GC is performed, which creates the next object link. But if newSpaceCount is 0, then this was the last object, and we're done. To avoid having to do a full GC (which needs to scan all objects) we now have a partial GC which only scans new space: instead of starting the mark phase from the system roots we start from "dirty" old objects. Every store operation marks an object "dirty", and only those objects can possibly point to newly created objects. This optimization speeds up new object discovery considerably (5x-10x).
The UI for now copies the Squeak display bitmap pixel-by-pixel to a typed array and shows it on the HTML 2D canvas using putImageData(). Clipboard copying injects a synthetic CMD-C keyboard event into the VM, then runs the interpreter until it has executed the clipboard primitive in response, then answers that string. This is because the web browser only allows clipboard access inside the copy/paste event handlers.
You can drag files from your disk into this page (including Squeak image files). Files are stored in indexedDB and directory entries in localStorage. Use the "Save File ..." button to get files out.
Contributing: The VM source code is on GitHub. Pull requests are very welcome, or send patches to email@example.com
Please choose 'Load image: xmsmall.image' to run the Squeak examples.
SqueakJS is largely the work of Vanessa Freudenberg. It has done more to preserve Smalltalk in the world than anything else. I especially thank her for the extra work she has put into making the various examples from my HOPL paper work reasonably here. We are still working on this; if something fails, please be patient and feel free to let either of us know.
- Dan Ingalls
This version of the page uses the latest SqueakJS bundle,