Re: [Gc] Creating stack-like memory containing GC roots

Shiro Kawai <[email protected]> Wed, 23 Sep 2015 11:13:24 -1000
Newsgroups gmane.comp.programming.garbage-collection.boehmgc
Message-ID <CALN0JNFvhbT_KNjufu4D=v79t5C80HTGaodYK4TOKsM=wi6vRg@mail.gmail.com>
I once used bdwgc's "kind" mechanism for the similar purpose.  The "kind" is
conceptually a custom allocator with your own mark procedure.  So, you
allocate
your stack by the new kind so that GC knows about it, but you make the
attached
marker scan only the active region of your stack.

I suppose the kind mechanism is more for generic purpose (e.g. "atomic" or
"stubborn"
allocators are realized by kinds), so using it for just custom stack region
may be
an overkill.  The source suggests that the kind isn't for casual use.   I'd
like bgwgc
experts here to suggest better advices.

If you're interested, check Gauche's vm.c.
Look at the code inside #ifdef USE_CUSTOM_STACK_MARKER.

https://github.com/shirok/Gauche/blob/master/src/vm.c








On Wed, Sep 23, 2015 at 9:52 AM, Christian Schafmeister <
[email protected]> wrote:

>
> I’ve written a Common Lisp compiler that uses LLVM as the backend and that
> interoperates with C++.
>
> 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.
>
> Best,
>
> Christian Schafmeister
> Professor,
> Chemistry Department
> Temple University
> _______________________________________________
> bdwgc mailing list
> [email protected]
> https://lists.opendylan.org/mailman/listinfo/bdwgc

_______________________________________________
bdwgc mailing list
[email protected]
https://lists.opendylan.org/mailman/listinfo/bdwgc