bone-lisp icon indicating copy to clipboard operation
bone-lisp copied to clipboard

What lessons did you learn about mem mgmt model?

Open xphung opened this issue 5 years ago • 1 comments

Hi, the semi-manual memory management used in Bone Lisp is of interest to me.

I'm looking at extending the S-expression syntax of WebAssembly into a full blown Lisp-like programming language. (Macros can then be used to the transform syntax of other languages into WebAssembly, effectively becoming a compiler platform).

WebAssembly doesn't have garbage collection (so the Bone Lisp model will fits in well). Can I ask what were the main lessons you learned in your experimentation with the Bone Lisp, and what would you do differently if you were designing a similar mem mgmt model today?

xphung avatar May 02 '20 12:05 xphung

You should definitely come up with a good solution to global state if you want to go full region-based. That might get a bit tricky if you want to be both fast and memory-safe.

Also, in Bone Lisp the regions are made of small blocks, which is unfortunate if you want to have e.g. large arrays. Today I would rather use two large sections of memory used for allocating (by simply bumping a pointer forward). Starting a new region would always switch to the other section.

Why we need two? Because we want to copy back the return value to the end of the previous region when we're leaving a region.

wolfgangj avatar May 09 '20 13:05 wolfgangj