Skip to content

Garbage collector 🫣#21

Merged
bialger merged 60 commits intomasterfrom
garbage_collector
Jan 10, 2026
Merged

Garbage collector 🫣#21
bialger merged 60 commits intomasterfrom
garbage_collector

Conversation

@cloalenka
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements a garbage collection system for the VM, replacing manual memory management with an automated mark-and-sweep garbage collector. The changes introduce a MemoryManager class that handles object allocation, deallocation, and garbage collection, along with reference scanning infrastructure to track object relationships.

Key changes:

  • Added mark-and-sweep garbage collector with reference scanning support
  • Replaced direct allocator usage with centralized MemoryManager throughout the codebase
  • Introduced reference scanner abstractions for different object types (empty, default, and array scanners)

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
lib/runtime/gc/IGarbageCollector.hpp Defines garbage collector interface with Collect method
lib/runtime/gc/MarkAndSweepGC.hpp Declares mark-and-sweep GC implementation
lib/runtime/gc/MarkAndSweepGC.cpp Implements mark-and-sweep algorithm with mark/sweep phases and root scanning
lib/runtime/gc/reference_scanners/IReferenceScanner.hpp Defines interface for scanning object references
lib/runtime/gc/reference_scanners/EmptyReferenceScanner.hpp Scanner for objects without references
lib/runtime/gc/reference_scanners/DefaultReferenceScanner.hpp Scanner for regular objects with fields
lib/runtime/gc/reference_scanners/ArrayReferenceScanner.hpp Template scanner for array objects
lib/runtime/MemoryManager.hpp Declares central memory management class
lib/runtime/MemoryManager.cpp Implements allocation, deallocation, GC triggering, and cleanup
lib/runtime/VirtualTable.hpp Adds reference scanning methods to VirtualTable
lib/runtime/VirtualTable.cpp Implements reference scanning and field inspection methods
lib/runtime/VirtualTableRepository.cpp Removes unused variable declaration
lib/runtime/ObjectDescriptor.hpp Adds repo_index field for tracking objects in repository
lib/runtime/IVariableAccessor.hpp Adds IsReferenceType method to interface
lib/runtime/VariableAccessor.hpp Implements IsReferenceType to identify pointer types
lib/runtime/CMakeLists.txt Adds new GC and MemoryManager source files to build
lib/runtime/ByteArray.cpp Formatting improvements (whitespace)
lib/runtime/StackFrame.hpp Formatting improvement (whitespace)
lib/execution_tree/PassedExecutionData.hpp Replaces allocator with memory_manager reference
lib/execution_tree/BytecodeCommands.cpp Updates allocation calls to use memory_manager and removes unused includes
lib/executor/builtin_factory.cpp Assigns appropriate reference scanners to builtin types
lib/executor/Executor.cpp Updates object allocation to use memory_manager
lib/executor/BuiltinFunctions.cpp Updates object allocation to use memory_manager
lib/vm_ui/vm_ui_functions.cpp Simplifies cleanup by delegating to memory_manager.Clear()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bialger bialger requested a review from Copilot January 7, 2026 16:10
@bialger
Copy link
Contributor

bialger commented Jan 7, 2026

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a95b9b902c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 14 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cloalenka and others added 27 commits January 8, 2026 23:37
…clean up unused includes in BuiltinFunctions.hpp
… ArrayReferenceScanner and DefaultReferenceScanner for improved memory management
…nner and enhancing DefaultReferenceScanner and ArrayReferenceScanner for better OOP
… BuiltinFactory and optimizing VirtualTableRepository's name lookup
Copy link
Contributor

@bialger bialger left a comment

Choose a reason for hiding this comment

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

Thank you for your amazing work!

@bialger bialger merged commit c15c5da into master Jan 10, 2026
6 checks passed
@cloalenka cloalenka linked an issue Jan 10, 2026 that may be closed by this pull request
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.

Implement GC

3 participants