tekknolagi / stackx

MIT License
2 stars 0 forks source link

Spec out or pick a target VM #6

Open tekknolagi opened 7 years ago

tekknolagi commented 7 years ago

Register VM: https://github.com/tekknolagi/stackx/issues/8

Stack VM: https://github.com/tekknolagi/stackx/issues/9

akkartik commented 7 years ago

I want my own server in the cloud running zero code touched by the conventional C toolchain. That's it! But it has to be within a factor of 2 of C's performance.

The JVM shows that you're not going to get that by targeting a stack VM. Not without tons of JIT effort. To me that disqualifies stack VMs as any sort of intermediate disk format.

If our non-stack VM turns out to be too slow we'll need to translate it to native. Unless we planned ahead and it was already mostly like native.

tekknolagi commented 7 years ago

Okay, I see what you mean. Sounds reasonable, then. But I think we should have some polyfills -- and this is a good time to figure out what they are.

akkartik commented 7 years ago

My approach would be to start building simple programs ASAP, and then start adding polyfills as we feel the need. That said, here's Mu's list:

Various terminal helpers:

File-system/network client helpers:

akkartik commented 7 years ago

Oh yes, allocation:

new -- takes a type and an optional number for allocating an array.

(Mu has no delete. When an allocation's refcount drops to zero it gets reclaimed. To trigger reclamation you clear addresses.)

local-scope -- allocate a stack frame on the heap that will be reclaimed when you exit, clearing any addresses in it.

To allocate stack frames that you don't want reclaimed, just use new directly rather than local-scope.

tekknolagi commented 7 years ago

@akkartik what do you think about generalizing both file modes and combining files and sockets into the same data type?

Also do we really want a refcount in the VM...?

akkartik commented 7 years ago

No, we don't want a refcount. That's one of the big causes of slowdown in Mu.

We can play lots of games with the OS side of things, but if you're thinking of them as polyfills that will eventually be replaced -- it doesn't seem like a priority to innovate there. Just get something working and move on. And we don't really need them yet anyway.

tekknolagi commented 7 years ago

I think also the idea of building sample programs is a good idea. Anything from factorial to cat to wc or something of the sort.

tekknolagi commented 7 years ago

I don't know if they are slotted to be eventually replaced in my mind.