Reset ◼
Load image
Step ▹
Run ▶

Return ⬆
Send ⬇︎

Over ▷
this
Export File...

no image loaded
Breakpoint:
Class>>method

Break on do-it:
Import:
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. It represents regular Squeak objects as Javascript objects with direct object references. SmallIntegers are represented as Javascript numbers, there is no need for tagging. 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. For garbage collection, I came up with a hybrid scheme: the bulk of the work is delegated to the Javascript garbage collector. Only in relatively rare circumstances is a "manual" garbage collection needed. This hybrid GC is a generational GC with an old space and a new space. Old space is a linked list of objects, but newly allocated objects are not added to the list, yet. Therefore, unreferenced new objects will be automatically garbage-collected by Javascript. This is like Squeak's incremental GC, which only looks at objects in new space. The full GC is a regular mark-and-sweep: it's marking all reachable objects (old and new), then unmarked old objects get removed (a very cheap operation in a linked list), and new objects (identified by their missing link) are added to the old-space list. One nice feature of this scheme is that its implementation does not need weak references, which Javascript currently does not support. 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). Besides the regular bytecode interpreter there is a simple, fast, non-optimizing JIT compiler. It inlines all bytecodes for a method, but sends are not accelerated at all. For major speed gains it would have to avoid a full context activation for each send. Other speed gains come from primitive functions. Several plugins are translated from the original Squeak VM code to JavaScript (see plugins directory), others are hand-coded. 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 vanessa@codefrau.net
SystemBrowser
X
+
M
N
GitControl
X
M
+
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
depth: 1
reset
This version of the page uses the latest SqueakJS bundle,
as opposed to the Lively modules version.
That means the VM can not be live-edited.
It is also safe from accidental modifications.
-- Vanessa
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
JavaScript Workspace
X

Menu