3 ms·
Indeed you are right, this is definitely a bug and could cause errors. I guess the solution would be to add an explicit API to create a GC root, invoked by nat
by andreabergia 3y ago
Indeed you are right, this is definitely a bug and could cause errors.
I guess the solution would be to add an explicit API to create a GC root, invoked by native methods (which is a bit complicated by the fact that I use a moving collector).
Many years ago I was using SpiderMonkey in a c++ project and I seem to remember there were some APIs for native callbacks to invoke that rooted values. Same problem and similar solution. :-)
- munificent 3y ago> I guess the solution would be to add an explicit API to create a GC root, invoked by native methods (which is a bit complicated by the fact that I use a moving collector). This is why I do in the Wren VM. Any time a native C function has the only reference to a GC-managed object and it's possible for a collection to occur, it calls a function to temporarily add the object to a list of known roots.