We haven't touched MufiZ's memory operations until now, and this comes with a sweeping change! We have transitioned from a mark-sweep algorithm to an incremental GC algorithm, which should help improve memory operations in the language.
To look at how it operates, consider the following visuals:
+-------------------+
| START |
+-------------------+
|
v
+-------------------+
| GC_IDLE |<-----------------+
+-------------------+ |
| |
v |
+-------------------+ |
| GC_MARK_ROOTS | |
| | |
| +---------------+ | |
| | Mark Stack | | |
| +---------------+ | |
| | | |
| v | |
| +---------------+ | |
| | Mark Frames | | |
| | Mark Globals | | |
| | Mark Strings | | |
| | Mark Upvalues | | |
| +---------------+ | |
+-------------------+ |
| |
v |
+-------------------+ |
| GC_TRACING | |
| | |
| +---------------+ | |
| | Gray Stack | | |
| | +-+ +-+ | | |
| | |o| |o| | | |
| | +-+ +-+ | | |
| +---------------+ | |
| | | |
| v | |
| +---------------+ | |
| | Blacken Objs | | |
| +---------------+ | |
+-------------------+ |
| |
v |
+-------------------+ |
| GC_SWEEPING | |
| | |
| +---------------+ | |
| | Object List | | |
| | [o]->[o]->[o] | | |
| +---------------+ | |
| | | |
| v | |
| +---------------+ | |
| | Free/Unmark | | |
| +---------------+ | |
+-------------------+ |
| |
v |
+-------------------+ |
| Update GC | |
| Threshold |------------------+
+-------------------+
|
v
+-------------------+
| END |
+-------------------+
As you can see, we can pause and resume at any state to allow program execution, which should allow for more performance and better latency. Our goal is to find an actual number of these to see how else we can further optimize our structures within our language.