Smalltalk Interpreter Description

January 2, 2011

Silver Smalltalk is implemented as a bytecode interpreter which is normally named

These are the versions of STVM:

Name Host Language Target Environment
stvm32.exe C# (WinForm) Win32 on Windows XP, Vista, Win 7
stvm.exe C# (WPF) WPF on Windows Vista, Win 7
stvm.xap C# (Silverlight) Silverlight browser plugins / Win 7 Phone
stvm.jar Java Java JVM / Android Dalvik VM
stvm.js JavaScript Any browser / HTML5
stvm.swf (in progress) ActionScript 3 Flash / Adobe AIR

STVM implements the entire Squeak Smalltalk set of bytecodes

STVM uses a Smalltalk scanner/parser written in the host language (C#, Java, AS3)

STVM’s compiler is written in the host language; it produces “CompiledMethod” objects containing bytecodes and runtime data

Object System
STVM implements an internal representation of Smalltalk classes and objects; this representation is the same across all versions including JavaScript
— all Smalltalk accessible objects derive from native type VOop
— VParser, VCompiler, VProcess, VObject, etc derive all from VOop
— all Smalltalk createable objects are derived from VObject
— there are several built-in Smalltalk classes implemented in the host language: VBehavior, VClass, VMetaClass, VDouble, VInteger, etc
— there is a special class (VMappedObject) which can wrap any native object to make it appear as a Smalltalk object
— Smalltalk classes can be declared to “map” a native class

— most access to native functionality is done through reflection; there are cache tables to improve runtime efficiency
— reflection can be used dynamically on any native object
— “primitive” methods wrap host code functions during compilation (more efficient than dyamic references)

— VProcess is the core of the interpreter
— each VProcess object has its own stack and runtime pointers
— several VProcess objects may be running concurrently
— VProcess objects are scheduled (round-robin) by a VProcessor object which itself runs on a single host thread
— for host systems which support multi-threading, multiple VProcessors may be active on separate threads

— all serialization uses JSON format
— JsonObjects which contain an “xtype” key can serialize extended Smalltalk objects
— JSON format is compatible with server JSON implementations in PHP, Python, Groovy, and Clojure

Network Remote Messaging
— internal Smalltalk messaging is identical to Squeak
— network messaging uses JSON dictionaries (with “xtype” : “message”) to send Smalltalk messages to other STVM instances across the network; semantics are the same as internal messages

graphics, communications, IO, and garbage collection are all handled by the host environment. STVM accesses host resources through reflection

The key concepts are:
1) STVM is implemented in multiple host environments
2) all STVM instances can read the same source code
3) all STVM instances can interchange serialized Smalltalk objects in JSON format
4) STVM instances can send messages using Smalltalk semantics to objects in other STVM’s

I will add more detail in future posts.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: