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
Start of the GC implementation. #80
base: master
Are you sure you want to change the base?
Conversation
The biggest problem I see is that creating an What you probably want is to write a Ideally, we would also use tag bits in the object headers to store which objects were visited (mark bits), but you can use an Some other remarks:
|
I was going to implement the visitor soon. The array was just an easy way in order to first understand what to do. I'm not sure what the tags file is, I'll get rid of it in the next commit. Oh yes, the static method is very good suggestion! Thanks :) |
7f1b61e
to
7bffbb0
Compare
c403c07
to
c84b702
Compare
Comments:
You're missing something here: Even if Also, I would rename the VM class to GC, since that is memory allocation is really all it is handling. |
The most obvious flaw I see is that the Linking you again to the implementation I made for Higgs, which implements all the list management in the assignment operator: The assignment operator and copy constructor are needed, because otherwise the |
Progressing very well :) |
@Maaarcocr @krypt-n Made this fix following our discussion. This might fix the bug you were running into (hopefully): a7e9430 |
That should fix the first of the issues that valgrind showed, |
@krypt-n Ok noted, will take a look at that too 👍 |
Implemented a function to mark the values on the stack. Implemented allocated, a value in the vm object that keeps track of the memory used. Implemented a linked list of all the Values which are pointers.
Rebasing my latest changes onto master make all the tests pass! 😄 Thanks @krypt-n and @maximecb for the help. I still need to do some more work to better tests that everything is actually fine and also I still need to make the GC understand that when it sweeps something it has to decrease |
@Maaarcocr it passes? Awesome. Regarding testing, I put a bunch of GC torture tests I had written for Higgs in: They're written in JavaScript, so we would need to change some things. They also rely on some higgs-specific primitives to force garbage collections to happen more often. We could add similar things to Zeta, or add command-line arguments to make the heap size artificially small. We need to do a really thorough job with testing, because GC bugs can easily remain hidden for a long time. |
Oh, one thing we might want to do is, when compiled with assertions, write non-zero bytes over memory before calling free. That will basically force things to crash/fail if an object that has been freed is still in use. |
@Maaarcocr do you need help porting the GC tests to Plush? If you want, I can start working on that. |
@maximecb that would be lovely 😄 in the meanwhile I'll make sure that the variable holding the amount of memory allocated get reduced on sweep. |
@Maaarcocr I added a |
Ok. Ported a second test, and added another function: |
@maximecb we are not actually passing the tests. I did run the tests with free commented out. I'm so so sorry for this. I will implement the functions that you are adding 👍 |
@Maaarcocr don't panic. I believe in you :D |
Implemented a function to get the values from the stack.
Implemented allocated, a value in the vm object that keeps track of the memory used.
Implemented a linked list of all the Values which are pointers.