[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Fengari: Why we rewrote Lua in JS
- From: Daurnimator <quae@...>
- Date: Thu, 27 Jul 2017 14:45:19 +1000
On 27 July 2017 at 14:39, Soni L. <fakedme@gmail.com> wrote:
> What stops Lua/Fengari from having its own GC? Just make it so pushing a JS
> object/lightuserdata finds or creates a lookup table entry for mapping
> between JS and the GC? And don't expose Lua GC objects? This gives you the
> exact Lua/C behaviour without screwing up the JS GC. (Heavy userdata may be
> trickier, tho. Maybe require use of typed arrays or something?)
>
> I don't see why you'd need synced GCs. (I do see why one would want them,
> because it simplifies implementation. But it's not portable - e.g. for weak
> tables. Even if you could do a synced GC with JS, would you still be able to
> do Lua 5.2+ ephemeral tables?)
Because you need to be able to do a full sweep, otherwise cycles
cannot be detected.
JS (and the DOM) expose no way to do a full sweep: so we can't write
our own GC and still be able to call arbitrary JS functions.
The only solution was to structure our code so that the JS GC also
behaved as the lua GC.