This page is part of the web mail archives of SRFI 50 from before July 7th, 2015. The new archives for SRFI 50 contain all messages, not just those from before July 7th, 2015.
felix <felix@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> writes: > Chicken for example uses the C-stack as the first generation of > a generational GC scheme (as described in Henry Baker's Cheney-on- > the-MTA paper). Calling C from Scheme is no problem, if the code > returns properly, but a callback/GC would possibly invalidate the portion > of the stack below the currently pending C stack-frame, and uncontrolled > shrinking of the nursery would quickly result in problems. To prevent > this, the nursery (1st gen. / C-stack) has to be resized, by pulling > out live data (and cleaning up the nursery) before calling the C > code, and then setting the "watermark" that marks the lower end of the > stack. One method would be to simply disallow callbacks (as Baker > proposes in his paper), but we don't want that, of course... > Another issue is threads: the blocking behaviour mentioned in SRFI-50 > on returning from callbacks would not have to be checked, if it is > known that the invocation of C from Scheme has no chance of calling > back into Scheme. Okay, I think I see. When using Cheney-on-the-MTA, collection entails popping off the entire portion of the C stack you're using for your nursery, after scavenging all the live objects out of it. Any active C frame is a live object, but you don't have enough information to scavenge those, so your nursery must always be free of active C frames. (Otherwise you'd have to put off collecting the portion below the youngest active C frame until it exits, and you have no idea how long they'll stick around...) So your C stack is divided into two portions: - at the older end, you have active C frames, and - at the younger end, you have your nursery. The "watermark" that you mentioned indicates the boundary between these two portions. So, to invoke a C function that might perform callbacks, you must collect and pop your nursery, to allow you to place that call's frame at the (now exposed) younger end of the C frame area. In contrast, to call a C function that you know will not perform callbacks, none of that is necessary; you just make the call on top of whatever nursery you've got. It seems to me that the called function also must not allocate any heap objects. Or do you simply allocate them directly in the next older generation, bypassing the nursery altogether?