[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

[S8] Jumping - How to add a new native language support

S8 Smalltalk can run in most of modern dynamic languages.
It is required that the language supports:
S8 do NOT require a Virtual Machine abstraction, and can run on top of multiple virtual machines.
The system can generate image/snapshot file to load the system later in time or in another environment.
The Compiler framework is configurable to produce methods that run in a target platform/VM.
Methods are dependent on execution engine, but S8 smalltalk code was written to run in any/future execution supports; so, the system can generate an image/snapshot encoded to run on top of other execution environment.
To generate the system image ready to run in another execution environment, the full system is compiled with a S8Encoder for the runtime environment.

S8Encoder framework

The S8Encoder framework is specialized/refined for each execution engine.
Concrete subclasses of S8Encoder implements code generation for other runtime engines/VMs.

Implementing a new language support

The major goal of implementing a new runtime for S8 systems is to produce a snapshot (and image) in the language required by the execution engine.
The image is produced from an existing system using an Exporter to dump a snapshot (and image) file using an Encoder implemented for the new language.

The following steps are required to build an image/snapshot for a new target language
  1. Implement basics of the boot section
  2. Implement the Encoder for new language
    1. Implement inlines for new language
  3. Build an image/snapshot capable to be loaded and run in the new language
    1. Load the boot&image in console mode (or minimal execution runtime)
    2. check basic objects are reachable on runtime e.g.
      • smalltalk
      • nil
      • true false and Number instances
      • Classes like smalltalk.Object, smalltalk.Point, smalltalk.String, etc.
    3. evaluate simple expressions to check system integrity
      • shape of Classes
      • Metaclass structure
      • Instantiation of objects e.g. native expressiones equivalent to "Object new", "Point new", "Array new", "1 @ 3"
      • message lookup and evaluation for Classes and Metaclasses
      • Smalltalk classes (an Array)
    4. Iterate checking core tests until no Failure
      • See page test[s8] index for tests that must run OK on new system
      • There are TestSets in build folders of new platforms, that can be injected while building the image and be evaluated on console with expressions like smalltalk.testAll(), smalltalk.testFrom(1), etc -that can be implemented in boot for debugging
  4. Customize access to special Kernel classes
  5. Implement wrappers to core libraries in the new language
  6. Generate a Snapshot and image files from new language runtime (leaving dependence with origin)