summaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-09-05 14:59:31 -0700
committerKeith Randall <khr@golang.org>2014-09-05 14:59:31 -0700
commit8c0cc43f561971dd89bd03426d78c39a98a49c2d (patch)
tree694550ed659c1845f4573157e74af46027d72e85 /src/pkg
parentaa8c80b5100f4b25d53db3cf911f6669f8b906ad (diff)
downloadgo-8c0cc43f561971dd89bd03426d78c39a98a49c2d.tar.gz
runtime: run getgcmask on the M stack.
LGTM=rsc R=rsc, khr CC=golang-codereviews https://codereview.appspot.com/132660043
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/runtime/export_test.go13
-rw-r--r--src/pkg/runtime/mgc0.c4
-rw-r--r--src/pkg/runtime/stubs.goc7
3 files changed, 14 insertions, 10 deletions
diff --git a/src/pkg/runtime/export_test.go b/src/pkg/runtime/export_test.go
index 35a4130ee..fd7fd182f 100644
--- a/src/pkg/runtime/export_test.go
+++ b/src/pkg/runtime/export_test.go
@@ -111,8 +111,19 @@ func ParForIters(desc *ParFor, tid uint32) (uint32, uint32) {
return begin, end
}
+// in mgc0.c
//go:noescape
-func GCMask(x interface{}) []byte
+func getgcmask(data unsafe.Pointer, typ *_type, array **byte, len *uint)
+
+func GCMask(x interface{}) (ret []byte) {
+ e := (*eface)(unsafe.Pointer(&x))
+ s := (*slice)(unsafe.Pointer(&ret))
+ onM(func() {
+ getgcmask(e.data, e._type, &s.array, &s.len)
+ s.cap = s.len
+ })
+ return
+}
func testSchedLocalQueue()
func testSchedLocalQueueSteal()
diff --git a/src/pkg/runtime/mgc0.c b/src/pkg/runtime/mgc0.c
index 55c38a7e5..d4c414736 100644
--- a/src/pkg/runtime/mgc0.c
+++ b/src/pkg/runtime/mgc0.c
@@ -1805,7 +1805,7 @@ getgcmaskcb(Stkframe *frame, void *ctxt)
Stkframe *frame0;
frame0 = ctxt;
- if(frame0->sp >= frame->varp - frame->sp && frame0->sp < frame->varp) {
+ if(frame->sp <= frame0->sp && frame0->sp < frame->varp) {
*frame0 = *frame;
return false;
}
@@ -1865,7 +1865,7 @@ runtime·getgcmask(byte *p, Type *t, byte **mask, uintptr *len)
frame.fn = nil;
frame.sp = (uintptr)p;
cb = getgcmaskcb;
- runtime·gentraceback((uintptr)runtime·getcallerpc(&p), (uintptr)runtime·getcallersp(&p), 0, g, 0, nil, 1000, &cb, &frame, false);
+ runtime·gentraceback(g->m->curg->sched.pc, g->m->curg->sched.sp, 0, g->m->curg, 0, nil, 1000, &cb, &frame, false);
if(frame.fn != nil) {
Func *f;
StackMap *stackmap;
diff --git a/src/pkg/runtime/stubs.goc b/src/pkg/runtime/stubs.goc
index f6bc14f2c..34cd1b3bb 100644
--- a/src/pkg/runtime/stubs.goc
+++ b/src/pkg/runtime/stubs.goc
@@ -54,13 +54,6 @@ func runtime·gomcache() (ret *MCache) {
ret = g->m->mcache;
}
-// For testing.
-// TODO: find a better place for this.
-func GCMask(x Eface) (mask Slice) {
- runtime·getgcmask(x.data, x.type, &mask.array, &mask.len);
- mask.cap = mask.len;
-}
-
#pragma textflag NOSPLIT
func reflect·typelinks() (ret Slice) {
extern Type *runtime·typelink[], *runtime·etypelink[];