munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"

Home Page:http://www.craftinginterpreters.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GC might miss marking some functions

tiendo1011 opened this issue · comments

commented

In chapter 26, In the implementation of markCompilerRoots, the GC only mark the functions outward from the current function, what about function next to it (its sibling)?

For example:

fun a() {}
fun b() {}

When compiling b, let's say it triggers a garbage collection, markCompilerRoots will not mark a to avoid it from being collected. Isn't it supposed to do so?

commented

It seems that a will be marked because it's in the enclosing function constants list, since the enclosing function will be marked, its constants will be marked too.