Skip to content

Conversation

@wxiaoyun
Copy link
Member

@wxiaoyun wxiaoyun commented Apr 16, 2024

Description

  • Refactor all references to environments by thread, closures and runtime_stack to weak references
  • Centralize ownership of environment to runtime
  • Mark and sweep environment
    • For 1 second (or other user defined time), there is going to be a round of mark and sweep:
    • Mark: Recursively mark all environments reachable from all non-zombie threads
    • Sweep: De-allocate any unmarked environments
    • Since only the runtime has ownership of the environments, we can de-allocate any environments that are unreachable by dropping them in the Runtime struct
  • Add support to anonymous functions

Bug fixes

  • Previously, extend_environment extends the current current at all times. This is not correct as for function calls, we want to extend the environment of the function. This PR corrects this behavior.

Resolves #47

@wxiaoyun wxiaoyun self-assigned this Apr 16, 2024
@wxiaoyun wxiaoyun marked this pull request as draft April 16, 2024 14:11
@wxiaoyun wxiaoyun requested a review from leonidas1712 April 17, 2024 05:16
@wxiaoyun wxiaoyun marked this pull request as ready for review April 17, 2024 05:16
Copy link
Contributor

@leonidas1712 leonidas1712 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks!

@wxiaoyun wxiaoyun merged commit 999b5e2 into crabscript:master Apr 17, 2024
@wxiaoyun wxiaoyun deleted the simple-gc branch April 17, 2024 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: basic mark and sweep garbage collector for cyclic environments

2 participants