You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now the Titan compiler pessimistically stores in the Lua stack any GC-able reference (references to strings and arrays) that it has stored in a native variable so the Lua garbage collector is assured to find them, but we can defer this store while we are sure no GC will occur, in the hope that by the time a GC can occur some of these references have gone out of scope and do not have to be stored to the Lua stack anymore.
To implement this store sinking, we need:
To track visibility of variables and temporaries in the code generator (no need for a full blown symbol table, a simple stack of visible sets will do
To track variables and temporaries that are dirty, i.e., its current value (the GC reference) changed but the new value has not been stored in the Lua stack
More aggressively put temporaries out of scope with more pushd/popd pairs in the code
Change all places in the code generator where we store the current value of a GC-ed variable or temporary in the Lua stack to mark it as dirty instead
Implement a checkpoint function that generates stores for all variables in the intersection of the dirty and visible sets, and call this function on the places where GC might occur: allocating a new string or table, calling a function...
Profit! 😄
The text was updated successfully, but these errors were encountered:
Right now the Titan compiler pessimistically stores in the Lua stack any GC-able reference (references to strings and arrays) that it has stored in a native variable so the Lua garbage collector is assured to find them, but we can defer this store while we are sure no GC will occur, in the hope that by the time a GC can occur some of these references have gone out of scope and do not have to be stored to the Lua stack anymore.
To implement this store sinking, we need:
To track visibility of variables and temporaries in the code generator (no need for a full blown symbol table, a simple stack of
visible
sets will doTo track variables and temporaries that are
dirty
, i.e., its current value (the GC reference) changed but the new value has not been stored in the Lua stackMore aggressively put temporaries out of scope with more
pushd/popd
pairs in the codeChange all places in the code generator where we store the current value of a GC-ed variable or temporary in the Lua stack to mark it as dirty instead
Implement a
checkpoint
function that generates stores for all variables in the intersection of thedirty
andvisible
sets, and call this function on the places where GC might occur: allocating a new string or table, calling a function...Profit! 😄
The text was updated successfully, but these errors were encountered: