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

Implement garbage collection #42

Open
alexdovzhanyn opened this issue Oct 2, 2024 · 0 comments
Open

Implement garbage collection #42

alexdovzhanyn opened this issue Oct 2, 2024 · 0 comments
Assignees
Labels
CodeGen Impacts code generation enhancement New feature or request

Comments

@alexdovzhanyn
Copy link
Collaborator

To enable the creation of more complex data structures in ThetaLang while maintaining a high-level programming model, we need to implement an efficient garbage collection (GC) system. This will help automate memory management, allowing developers to focus on writing clean, efficient code without worrying about manual memory allocation and deallocation.

Proposed Solution:
To avoid the complexity of hand-writing a garbage collector directly in WebAssembly, we propose leveraging existing tools like Emscripten. Emscripten would allow us to write the garbage collector in C++, which could then be compiled into WebAssembly. This approach enables better performance and reduces potential errors in memory management.

Required Updates:

  • Garbage Collector Implementation:
    Implement a garbage collection system in C++ and compile it to WASM using Emscripten. This will manage heap-allocated objects and automatically clean up unused data structures.

  • Code Generation Adjustments:
    Modify the ThetaLang code generation process to ensure that generated code makes proper calls to the memory allocator. This is necessary for handling memory allocation, particularly for closures and heap-allocated data.

Benefits:

  • Automated memory management for users.
  • Cleaner, more efficient high-level code.
  • Support for complex data structures without requiring manual memory handling.
@alexdovzhanyn alexdovzhanyn added enhancement New feature or request CodeGen Impacts code generation labels Oct 2, 2024
@alexdovzhanyn alexdovzhanyn self-assigned this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CodeGen Impacts code generation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant