KenDickey / BeeYourself

Experiments in porting Powerlang/Bee-DMR to Cuis
7 stars 0 forks source link

BeeYourself

Experiments in porting Powerlang/Bee-DMR bootstrap to Cuis

Nota Bene: very pre-Alpha [Broken, but package now loads with: "Feature require: 'Powerlang'"]

Background:

Bee Yourself

Scattered Thoughts

We explain the world through stories.

Where does this lead us?

Thread as VCPU (Virtual CPU), when running is assigned to real CPU (core). VCPU object follows Bee pattern: OOP points just past header to register/CPU-state save area, followed by Thread Local Storage (e.g. per-thread dynamic context).

When a Debug Thread is running, the debugged thread is not, so VCPU registers are directly inspectable as VCPU instance variables.

The natural model is to think of the runtime like a RTOS (Real Time OS) Kernel. Starting an image is spawning a Primordial/Home/Mother thread which spawns worker threads (including UI, debugger(s), ?timer?, ?gc?). HW interrupt reflected through Mother Thread to events. Mother thread spawns and cares for workers.

Smalltalk is the mediator between raw HW and its SW presentation.

Smalltalk is a system that knows itself.**

The stories written in Smalltalk explain the computational world view.

Machine <<==Smalltalk==>> Presentation

Stack <<=========>> Linked Contexts

Regs+Mem <<=====>> Objects+ivars/slots

Instructions <<=====>> Operations/[Macro]Opcodes

Possible Register Usage

Bee      Aarch64     RISCV  Notes
---      -------     -----  =====
IP        -           -     Program Counter [access by instruction]
SP        SP*        X2     Stack Pointer
FP        R29        X8     Frame Pointer
R         R0/R1      X10/X11    Receiver=Self / Return Value
M         R19        X19    Method Address
S         R20        X20    Selector
E         R21        X21    Environment [Escaping Variables]
A         R2-7       X12-17 Arguments [1..6] (spill to stack}
T         R9-12      X28-31 Temporaries/Volitile (non-object values)
V         R22        X22    Temp Object Value (???)
G         R23        X23    Smalltalk Globals (Vector of Objects)
nil       R24        X24    (needed? -> StackLimit)
true      R25        X25    (needed? -> NextAlloc)
false     R26        X26    (needed? -> AllocLimit)

Visualize & Explain Runtime Structures & Strategies

Find Still/Save Points

Learn Smalltalk = Learn all of Computer Science

Look, Ma, no compiler

Should be able to port by cross-compiling nativizer for new platform and cross/pre-nativise the loader. Let loader nativise methods during load. Simple port w/o running a compiler.

Playtime:

Feature require: 'Powerlang'.

SCompiler compile:  'foo [true ifTrue: [^self]]' in: UndefinedObject.
(SCompiler forClass: UndefinedObject) smalltalkCompiler  compileMethod:   'foo [true ifTrue: [^self]]' .

Browsing Tonel Source Files

cd Cuis-Smalltalk
git clone https://github.com/KenDickey/Cuis-Smalltalk-Tonel-Browser

Then

Feature require: 'ExchangeFormat-Tonel-Lite'.

You should be able to open a File List, select a Tonel file, and click on the code button to view in a Code Browser.

Licences

** "What is a System? Simply a set of things that are interconnected in ways that produce distinct patterns of behavior." Doughnut Economics, Kate Raworth.