pure-c / purec

C backend for PureScript
232 stars 8 forks source link

WIP: Implement reference counting #60

Closed felixSchl closed 3 years ago

felixSchl commented 5 years ago

Depends on #59

Introduce reference counting in order to avoid having to rely on a tracing GC.

Checklist, in order of priority:

Icon Meaning
:rotating_light: Difficult / possibly impossible. Priority
:construction_worker_man: In-progress
felixSchl commented 5 years ago

This was about as much time I could afford putting into this. It's pretty close and the TODO list above has been kept up-to-date. It would probably take another week or two to tow this across the line, not to mention updating libraries. If there's anyone who wants to take it up from here, I'd be happy to provide the necessary aid and assistance to familiarise you with the codebase and what needs to be done and so on. Otherwise expect slowing progress from here on out.

felixSchl commented 4 years ago

So I am updating the existing ported libraries for this PR and as was raised in #54 Control.Lazy does indeed cause a retain cycle and unreleased memory. I wonder what the best way to deal with this is. It seems the same problem also exists for non-TCO-ed recursive functions, e.g.:

go 10 = 10
go n = n + go (n + 1)

I wonder if we could drop in a tracing GC similar to what they do here https://github.com/brian-carroll/elm_c_wasm just for tracking these scenarios? This is the deep end of the pool for me though :)