VoltLang / Volta

Compiler for the Volt Programming Language
151 stars 8 forks source link

gc: Reduce stack usage when collecting. #48

Closed bhelyer closed 6 years ago

bhelyer commented 6 years ago

While working on VLS I encountered an infinite loop situation fairly far down in the stack. While the infinite loop was a bug, it caused a crash in the GC due to a stack overflow, in particular pruneUsedSlabs was being called many many times. The function after this PR is still recursive, just less so.

Everything works over here (tm), but GC changes can be messy so I figured I would turn it into a PR rather than setting everything on fire as the last thing I did in my work week. So here we are.

bhelyer commented 6 years ago

GC PR

Wallbraker commented 6 years ago

Nice find!

The change looks good, when building with optimizations that call should be turned into a tailcall and not allocate anymore stack space. But for non-optimized builds it will not and as you noted go explody.