2024-08-19 15:46:35 -04:00
|
|
|
# marCsweep
|
|
|
|
|
|
|
|
A mark-and-sweep garbage collector with a simple virtual machine to perform
|
|
|
|
allocations.
|
|
|
|
|
|
|
|
## Building
|
|
|
|
|
|
|
|
Compiling the project should be relatively easy, even if you aren't familiar
|
|
|
|
with `make`.
|
|
|
|
|
2024-08-20 13:28:23 -04:00
|
|
|
Dependences: `git`, `make`, and `gcc`. Compiling with `clang` is also possible,
|
|
|
|
simply replace "gcc" with "clang" in the first line of the Makefile.
|
2024-08-19 15:54:19 -04:00
|
|
|
|
2024-08-19 15:46:35 -04:00
|
|
|
```
|
|
|
|
git clone https://codeberg.org/andyscott/marCsweep.git
|
|
|
|
|
|
|
|
cd marCsweep
|
|
|
|
|
|
|
|
make release
|
|
|
|
```
|
|
|
|
|
|
|
|
That's it! The Makefile will automatically create the build directory and place
|
|
|
|
the compiled executable there.
|
|
|
|
|
2024-08-21 13:46:37 -04:00
|
|
|
## Running
|
|
|
|
|
|
|
|
Once compiled, the program can be run with the following:
|
|
|
|
|
|
|
|
```
|
|
|
|
cd build # or debug
|
|
|
|
|
|
|
|
./gc
|
|
|
|
```
|
|
|
|
|
|
|
|
By default the program will output the results of the test cases:
|
|
|
|
|
|
|
|
> test_int_alloc: PASS
|
|
|
|
> test_pair_alloc: PASS
|
|
|
|
> test_obj_count: PASS
|
|
|
|
> test_pair_alloc: PASS
|
|
|
|
> test_unreachable: PASS
|
|
|
|
> test_auto_gc: PASS
|
|
|
|
|
|
|
|
If all six tests pass, then the library compiles correctly on your system and
|
|
|
|
should be ready for experimentation!
|
|
|
|
|
2024-08-19 15:46:35 -04:00
|
|
|
## Notes
|
|
|
|
|
|
|
|
This is a personal project that I am writing in my free time to learn more about
|
2024-08-20 20:20:04 -04:00
|
|
|
garbage collection. Thank you to [Robert
|
|
|
|
Nystrom](https://journal.stuffwithstuff.com/2013/12/08/babys-first-garbage-collector/)
|
|
|
|
for the idea.
|