News for hackers. Stuff that matters.
Re:Write Your Own Virtual Machine by techno_modus on Friday December 14, 2018 @03:12AM (#18679287)
I like this tutorial but it should be mentioned that before implementing a virtual machine one should understand that there are many computing models and many alternative mechanisms within each of them. Implementing VM for sequential program execution is relatively easy. What is more (conceptually) difficult is concurrency, asynchronous processes etc.
Re:Write Your Own Virtual Machine by JustSomeNobody on Friday December 14, 2018 @05:15AM (#18679782)
> What is more (conceptually) difficult is concurrency, asynchronous processes etc.

Know any good resources for these?

Re:Write Your Own Virtual Machine by sifoobar on Friday December 14, 2018 @06:42AM (#18680151)
My own baby, Snigl [0], does always-on cooperative concurrency and asynchronous IO.

Just ask if you need help finding your way around.

https://gitlab.com/sifoo/snigl

Re:Write Your Own Virtual Machine by JustSomeNobody on Friday December 14, 2018 @11:16AM (#18681882)
Thank you. I’ll check it out over the holidays.
Re:Write Your Own Virtual Machine by justinmeiners on Friday December 14, 2018 @09:56AM (#18681201)
Author here. Definitely agree. The intent was to write the simplest possible to VM that could run real programs. VMs are obviously a deep field of research and there are plenty more projects to learn from.
Re:Write Your Own Virtual Machine by dana321 on Friday December 14, 2018 @05:43AM (#18679876)
Thats one of the main reasons i implemented my VM in go.

Its fairly rudimentary, a map for instructions to function pointers but.. I can quickly duplicate a subtree of code and execute it within a different goroutine, and wrap that section of code in an instruction that sets the output to a channel, and have another goroutine select the different channels from different goroutines.

At each node within the tree of code, i store the variables within a map instead of using a stack-based system; if the data is not in the current node, look down the tree until i find it.