2015-09-23 19:52:11 UTC
I’m using the Boehm garbage collector and I need to create a stack alongside the regular C++ stack that holds GC roots.
Is there any way using the Boehm garbage collector to identify a region of memory that will contain this stack and continuously update the top of the stack so that Boehm only examines the region that can contain pointers?
I need to push a frame containing GC roots onto the stack and then later pop the frame. Ideally I would just need to provide Boehm a pointer that points to the end of the current frame and everything from that address up to and including the first frame would be scanned for roots.
I have seen the GC_add_roots function but that lets me define a region once. I need some way to continuously update the end of the stack.
Currently I’m using GC_malloc and GC_free to allocate and free frames - but I feel that for something like a stack this has more overhead than I need.
I’ve tried doing this all on the main C++ stack - but I have to use non-standard features like __builtin_alloca or variable length arrays and they have caused me a lot of grief.