Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sink stores to Lua stack to GC checkpoints #36

Open
mascarenhas opened this issue Oct 22, 2017 · 0 comments
Open

Sink stores to Lua stack to GC checkpoints #36

mascarenhas opened this issue Oct 22, 2017 · 0 comments

Comments

@mascarenhas
Copy link
Member

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:

  1. 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

  2. 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

  3. More aggressively put temporaries out of scope with more pushd/popd pairs in the code

  4. 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

  5. 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...

  6. Profit! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant