[M3devel] getting all registers in gc?
Jay K
jay.krell at cornell.edu
Mon Jun 27 10:37:12 CEST 2016
I just noticed this in the Boehm GC documentation:
- Changed the alpha port to use the generic register scanning code instead
of alpha_mach_dep.s. Alpha_mach_dep.s doesn't look for pointers in fp
registers, but gcc sometimes spills pointers there. (Thanks to Manuel
Serrano for helping me debug this by email.) Changed the IA64 code to
do something similar for similar reasons.
This would seem like a hazard for us too.
And not convincingly Alpha/IA64-specific.
We basically assume setjmp stores a context, or at least all live pointers.
In hindsight I see two problems:
- one alluded to -- jmpbuf might not have floating point registers,
and floating point registers might have pointers.
- Same thing but more general: jmpbuf might not even have all integer
registers?
So that leaves the question "What is generic register scanning code"?
I don't know yet but..thinking...
Maybe we should instead use Posix-deprecated getcontext and Win32 RtlCaptureContext?
I'm actually looking for how Boehm gc gets the "second half" of the IA64 stack,
as I think that is a lingering thing we need to handle to finish our portability.
Ignoring IA64 for now, maybe here:
void
__cdecl
ThreadPThread__sigsuspend(void)
{
struct {
sigjmp_buf jb;
} s;
ZERO_MEMORY(s);
if (sigsetjmp(s.jb, 0) == 0) /* save registers to stack */
#ifdef M3_REGISTER_WINDOWS
siglongjmp(s.jb, 1); /* flush register windows */
else
#endif
sigsuspend(&mask);
}
and here:
void
__cdecl
ThreadPThread__ProcessLive(char *bottom, void (*p)(void *start, void *limit))
{
struct {
sigjmp_buf jb;
} s;
ZERO_MEMORY(s);
if (sigsetjmp(s.jb, 0) == 0) /* save registers to stack */
we should use getcontext/RtlCaptureContext/GetThreadContext?
I'll look more at the Boehm code.
- Jay
More information about the M3devel
mailing list