12

I'd like to use a virtual machine like NekoVM into a small device but to build it, it requires Boehm GC, however there is no port of that GC to that small device so I was wondering if there is any alternative to it, something that could be done exclusively with C code?

Paulo Lopes
  • 5,845
  • 22
  • 31
  • My advice is to write an accurate GC for Neko if one does not already exist. I wouldn't touch Boehm's GC with a barge pole... – J D Sep 25 '10 at 18:19

3 Answers3

4

I'd say your best option would be to port the GC to your platform, for which there are instructions (libgc porting instructions).

Additionally, it should be possible to swap out the GC implementation (NekoVM FAQ), see vm/alloc.c file.

EDIT:

Hopefully useful additional links: (untested)

Hasturkun
  • 35,395
  • 6
  • 71
  • 104
3

I could suggest TinyGC (tinygc.sf.net) - an independent lightweight implementation of the BoehmGC targeting small devices. It is fully API-compatible (even more, binary compatible) with BoehmGC v7+ but only a small subset of the API is implemented (but sufficient for Java/GCJ-like memory management) and there is no automatic threads and static data roots registration. The latter, however, may require some efforts to make NekoVM work with it (i.e., call GC_register_my_thread() and GC_add_roots()).

ivmai
  • 61
  • 1
3

Perhaps you'd be better off with Lua, which has a very small but powerful virtual machine, has its own garbage collector built in, and runs on any platform that supports ANSI Standard C. With just a little effort you can even build Lua on a machine that lacks standard input and standard output. I have seen Lua running on an embedded device that was a small LCD touch screen with an embedded CPU stuck on the back. Neko is good work, but I think you'll find Lua every bit as satisfying.

Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
  • I am aware that Lua has its own garbage collector, but if you look into NekoVM they use libgc and do not a GC like Lua because it is not as good as libgc. I'm looking for a general purpose GC like libgc that i could replace on nekoVM – Paulo Lopes Jan 08 '09 at 20:44
  • Hans has literally spent more than 20 years improving libgc. It is not realistic to expect to find a drop-in replacement for a high-performance collector. It is also not sensible to expect high-performance GC on a small device. Your question asked for 'a VM like NekoVM'. Lua qualifies. – Norman Ramsey Jan 08 '09 at 21:26
  • 3
    Hans may have spent more than 20 years improving libgc but its performance is awful compared to most accurate garbage collectors. – J D Sep 25 '10 at 11:48
  • 2
    If you do the wrong design for 20 years it's not helping at all. libgc works well for small data amounts. And it got worse in 2013. – Lothar Nov 23 '14 at 17:57