I'm currently developing a pure interpreter. Later I may consider either dynamic compilation or compilation direct to native instructions. For now, however, the easiest way to start is with a pure bytecode interpreter. I'm using the same bytecode set as VisualWorks. This is mostly for convenience. It means that I can use the VisualWorks compiler to create the bytecodes for the new Smalltalk.
I don't yet have garbage collection but I have everything setup to allow me to implement garbage collection. I'll have generation scavenging for new and survivor spaces and mark and sweep for old space.
I'm developing the system using three different languages. Java is used as a shell (for now) to start the system. I'll also be using it to perform various primitive operations. The core of the interpreter itself is written in C under the Android NDK. It can call back to Java using JNI when needed. It's the C code that loads the image from an asset and runs the Smalltalk bytecodes.
So far, I can do simple arithmetic, pushing and popping of the stack, message sends and super calls. Any looping or branching that compiles to bytecodes also works. I was able to write a non-recursive factorial method that worked well.
The image for the new Smalltalk is generated by VisualWorks and sent to the Android as an asset in the APK file. When Smalltalk launches, it loads the image then sets up a socket listener and waits for a connection. At that point, a bytecode debugger I wrote in VisualWorks connects to the image. This debugger can provide information about the memory spaces, dump the stack, inspect objects (in a fashion), and single step through the bytecodes.
Here's what the debugger looks like so far:
This is a stack trace in the process of evaluating 3 + 4. It's pushed the 3 and 4 onto the stack and is about to run the + method. Remember, this is a temporary debugger for me to use at a very low level to make sure all the infrastructure is working. Ultimately, I intend to tap into the VisualWorks debugger and direct its operations to run on the Android device.
Even though I have 95% of the VisualWorks bytecodes implemented, I'm still far away from getting the system as functional as I would like. I need to properly implement blocks, add a lot of primitives, and develop a base class library for the new Smalltalk. It's a lot of work but very exciting.
My current intention is to use this new Smalltalk to develop my own apps for commercial sale. If, however, other people are interested in developing mobile apps in Smalltalk I can look into ways of licensing the application for others to use. If this work interests you, drop me a line or leave me a comment. I'd love to hear your thoughts. You can also listen to the Independent Misinterpretations podcast episode 164 where I discuss the project with James.