aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/chan.c
diff options
context:
space:
mode:
authorJan Ziak <0xe2.0x9a.0x9b@gmail.com>2013-02-25 15:58:23 -0500
committerRuss Cox <rsc@golang.org>2013-02-25 15:58:23 -0500
commita656f82071c1631ed0aae5c403cf948fc06b52ce (patch)
tree02659c81c4c519260fb6a22b65be44429d36f3e5 /src/pkg/runtime/chan.c
parent707ab1347f114934d65b713e22fdd62b4a83ca36 (diff)
downloadgo-a656f82071c1631ed0aae5c403cf948fc06b52ce.tar.xz
runtime: precise garbage collection of channels
This changeset adds a mostly-precise garbage collection of channels. The garbage collection support code in the linker isn't recognizing channel types yet. Fixes issue http://stackoverflow.com/questions/14712586/memory-consumption-skyrocket R=dvyukov, rsc, bradfitz CC=dave, golang-dev, minux.ma, remyoudompheng https://golang.org/cl/7307086
Diffstat (limited to 'src/pkg/runtime/chan.c')
-rw-r--r--src/pkg/runtime/chan.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/pkg/runtime/chan.c b/src/pkg/runtime/chan.c
index a15b5d0d1a..32995c6ddd 100644
--- a/src/pkg/runtime/chan.c
+++ b/src/pkg/runtime/chan.c
@@ -33,6 +33,8 @@ struct WaitQ
SudoG* last;
};
+// The garbage collector is assuming that Hchan can only contain pointers into the stack
+// and cannot contain pointers into the heap.
struct Hchan
{
uintgo qcount; // total data in the q
@@ -48,6 +50,8 @@ struct Hchan
Lock;
};
+uint32 runtime·Hchansize = sizeof(Hchan);
+
// Buffer follows Hchan immediately in memory.
// chanbuf(c, i) is pointer to the i'th slot in the buffer.
#define chanbuf(c, i) ((byte*)((c)+1)+(uintptr)(c)->elemsize*(i))
@@ -112,6 +116,7 @@ runtime·makechan_c(ChanType *t, int64 hint)
c->elemalg = elem->alg;
c->elemalign = elem->align;
c->dataqsiz = hint;
+ runtime·settype(c, (uintptr)t | TypeInfo_Chan);
if(debug)
runtime·printf("makechan: chan=%p; elemsize=%D; elemalg=%p; elemalign=%d; dataqsiz=%D\n",