3 ms·
> This is part of the code for the conservative garbage collector which is supposed to scan the stack for pointers. If you know a better way to do that, by all
by jey 15y ago
> This is part of the code for the conservative garbage collector which is supposed to scan the stack for pointers. If you know a better way to do that, by all means let's hear it.
Why does scanning the stack for pointers need to involve alloca(0)?
- FooBarWidget 15y agoalloca(0) is used as a way to get the end of the stack. There's a bunch of fallback #ifdefs in the code: on platforms that don't have alloca, it detects the end of the stack by calling a forced-non-inline function which returns the address of its sole local variable, but that assumes that the compiler supports the 'noinline' keyword. In any case, all of versions depend on highly platform-specific behavior. See: https://github.com/FooBarWidget/rubyenterpriseedition187-330/blob/mbari/gc.c#L567-570 https://github.com/FooBarWidget/rubyenterpriseedition187-330... https://github.com/FooBarWidget/rubyenterpriseedition187-330/blob/mbari/rubysig.h#L210-269 https://github.com/FooBarWidget/rubyenterpriseedition187-330...
- Someone 15y agoHe isn't claiming it is the only way, he is claiming it is the best way he knows of to do what he needs/thinks he needs. I guess he wants the cleanest way to obtain the stack pointer. alloca(1) would work, too, but that runs the risk of producing a stack overflow.