4 ms·
What GC is used in goscript? The upstream one, a Rust GC<> one, maybe the mini one from TinyGo, or something else custom?
by mappu 5y ago
What GC is used in goscript? The upstream one, a Rust GC<> one, maybe the mini one from TinyGo, or something else custom?
- zackoverflow 5y agoI poked around earlier and found this file: https://github.com/oxfeeefeee/goscript/blob/master/vm/src/gc.rs https://github.com/oxfeeefeee/goscript/blob/master/vm/src/gc... Perhaps someone can shed more light on how exactly it works
- lelandbatey 5y agoFrom looking at it for like 20 seconds (I ain't no serious rustacean, so forgive if I'm wrong) I think they're using just a growable pool (as vectors) of each fundamental type in the Go language, then having each instance of each fundamental type be boxed in a Rc (reference counted) type so that they can count all references to each instance of each fundamental type.I believe that this can be used to get simple reference counting "for free" via the borrow checker of Rust. Probably many downsides, and apparently they don't yet implement GC of channels, but it seems like a nice straightforward way to get a script-ing/purely interpreted implementation of a language off the ground. The Rc module with the impl - https://doc.rust-lang.org/alloc/rc/ https://doc.rust-lang.org/alloc/rc/ Further docs on Rc- https://doc.rust-lang.org/book/ch15-04-rc.html https://doc.rust-lang.org/book/ch15-04-rc.html