News for hackers. Stuff that matters.
Re:Building a Minimalistic Virtual Machine by maxime_cb on Saturday February 25, 2023 @01:31PM (#34939145)
I go into some of the design decisions I made to make JIT optimizations easier here: https://github.com/maximecb/uvm/blob/main/doc/design.md
Re:Building a Minimalistic Virtual Machine by samsquire on Saturday February 25, 2023 @03:59PM (#34940406)
You mention parallel computation and being open for discussion.

My favourite area of computing is parallel computing and multithreading.

My toy multithreaded interpreter in Java can communicate integers between threads with message passing. I never got around to communicating complicated objects because I'm not sure how to solve the garbage collection problem with compound data structures/object graphs AND sending objects between threads. I'm currently relying on Java garbage collection at this time but I have played with a garbage collector written by Matthew Plant (http://maplant.com/gc.html), so if I were to implement my language in C I could also be inspired by Pony's reference capabilities.

Since my interpreter is a simple imaginary assembly interpreter I have instructions for "sendcode" "receivecode" which tell a thread to do a remote jump. There is also a "send" and "receive" instruction for sending data between threads in a thread safe manner. This uses actor style mailboxes behind the scenes.

Re:Building a Minimalistic Virtual Machine by maxime_cb on Saturday February 25, 2023 @06:54PM (#34941687)
I was thinking something like actors, or independent processes sending messages would be nice. Just because it's very safe and predictable. Less error-prone than threads.

The thing that kind of gets me is it seems difficult to have safe shared memory with actors? You ideally want to be able to share memory if you want things to be efficient, but if you have shared memory, then you get into issues with atomic writes and things being observed in different orders, etc.

Re:Building a Minimalistic Virtual Machine by samsquire on Sunday February 26, 2023 @02:48AM (#34943841)
I assume you would be communicating pointers with actor mailboxes, so the only copy is a pointer. I believe Erlang copies data itself into other actor's heaps, that simplifies garbage collection since GC can be done per process and there is only one owning reference to a processes' data.

You might find Pony's ORCA interesting which is how they implement garbage collection between actors.

https://www.imperial.ac.uk/media/imperial-college/faculty-of...