From 9e229ec708d7e1c812330cd2eb941b6c4f50bb9c Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 22 May 2012 16:57:35 +0000 Subject: [PATCH] runtime: Use getcontext, not setjmp, to save regs for GC. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@187778 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgo/runtime/proc.c | 8 +++----- libgo/runtime/runtime.h | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index 890b492d404..ade8b9e2db1 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -1239,9 +1239,7 @@ runtime_entersyscall(void) // Save the registers in the g structure so that any pointers // held in registers will be seen by the garbage collector. - // We could use getcontext here, but setjmp is more efficient - // because it doesn't need to save the signal mask. - setjmp(g->gcregs); + getcontext(&g->gcregs); g->status = Gsyscall; @@ -1299,7 +1297,7 @@ runtime_exitsyscall(void) gp->gcstack = nil; #endif gp->gcnext_sp = nil; - runtime_memclr(gp->gcregs, sizeof gp->gcregs); + runtime_memclr(&gp->gcregs, sizeof gp->gcregs); if(m->profilehz > 0) runtime_setprof(true); @@ -1328,7 +1326,7 @@ runtime_exitsyscall(void) gp->gcstack = nil; #endif gp->gcnext_sp = nil; - runtime_memclr(gp->gcregs, sizeof gp->gcregs); + runtime_memclr(&gp->gcregs, sizeof gp->gcregs); } // Allocate a new g, with a stack big enough for stacksize bytes. diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index 91044184b1f..67dabd26b14 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -7,7 +7,6 @@ #include "config.h" #include "go-assert.h" -#include #include #include #include @@ -128,7 +127,7 @@ struct G void* gcnext_segment; void* gcnext_sp; void* gcinitial_sp; - jmp_buf gcregs; + ucontext_t gcregs; byte* entry; // initial function G* alllink; // on allg void* param; // passed parameter on wakeup -- 2.11.0