summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/cgocall.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-07-23 18:40:02 -0400
committerRuss Cox <rsc@golang.org>2013-07-23 18:40:02 -0400
commit147197ceb8b15e57d2d688256440a4459538beea (patch)
treedcbc88763846262c1bc24c8c69d4f7d7f55a442d /src/pkg/runtime/cgocall.c
parent029c7a27b432a3924c8918d4ab546b9136cb129b (diff)
downloadgo-147197ceb8b15e57d2d688256440a4459538beea.tar.gz
runtime: reduce frame size for runtime.cgocallback_gofunc
Tying preemption to stack splits means that we have to able to complete the call to exitsyscall (inside cgocallbackg at least for now) without any stack split checks, meaning that the whole sequence has to work within 128 bytes of stack, unless we increase the size of the red zone. This CL frees up 24 bytes along that critical path on amd64. (The 32-bit systems have plenty of space because all their words are smaller.) R=dvyukov CC=golang-dev https://codereview.appspot.com/11676043
Diffstat (limited to 'src/pkg/runtime/cgocall.c')
-rw-r--r--src/pkg/runtime/cgocall.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/pkg/runtime/cgocall.c b/src/pkg/runtime/cgocall.c
index 16bc76554..a624509cf 100644
--- a/src/pkg/runtime/cgocall.c
+++ b/src/pkg/runtime/cgocall.c
@@ -228,13 +228,25 @@ runtime·cfree(void *p)
static FuncVal unwindmf = {unwindm};
+typedef struct CallbackArgs CallbackArgs;
+struct CallbackArgs
+{
+ FuncVal *fn;
+ void *arg;
+ uintptr argsize;
+};
+
+#define CBARGS (CallbackArgs*)((byte*)m->g0->sched.sp+(3+(thechar=='5'))*sizeof(void*))
+
void
-runtime·cgocallbackg(FuncVal *fn, void *arg, uintptr argsize)
+runtime·cgocallbackg(void)
{
Defer d;
+ CallbackArgs *cb;
if(m->racecall) {
- reflect·call(fn, arg, argsize);
+ cb = CBARGS;
+ reflect·call(cb->fn, cb->arg, cb->argsize);
return;
}
@@ -261,7 +273,8 @@ runtime·cgocallbackg(FuncVal *fn, void *arg, uintptr argsize)
runtime·raceacquire(&cgosync);
// Invoke callback.
- reflect·call(fn, arg, argsize);
+ cb = CBARGS;
+ reflect·call(cb->fn, cb->arg, cb->argsize);
if(raceenabled)
runtime·racereleasemerge(&cgosync);
@@ -286,9 +299,11 @@ unwindm(void)
runtime·throw("runtime: unwindm not implemented");
case '8':
case '6':
- case '5':
m->g0->sched.sp = *(uintptr*)m->g0->sched.sp;
break;
+ case '5':
+ m->g0->sched.sp = *(uintptr*)((byte*)m->g0->sched.sp + 4);
+ break;
}
}