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