]> Cypherpunks repositories - gostls13.git/commit
runtime: use type-based write barrier for remote stack write during chansend
authorRuss Cox <rsc@golang.org>
Mon, 8 Jun 2015 02:47:59 +0000 (22:47 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 15 Jun 2015 16:50:30 +0000 (16:50 +0000)
commit80ec7117551f009edba6eb16b34b85cfe6ba2f4f
tree013497bb6528bcca74e51b3584f84d016224efb9
parentd14e9e63238deb10236672427d58c0da3d5b82a0
runtime: use type-based write barrier for remote stack write during chansend

A send on an unbuffered channel to a blocked receiver is the only
case in the runtime where one goroutine writes directly to the stack
of another. The garbage collector assumes that if a goroutine is
blocked, its stack contains no new pointers since the last time it ran.
The send on an unbuffered channel violates this, so it needs an
explicit write barrier. It has an explicit write barrier, but not one that
can handle a write to another stack. Use one that can (based on type bitmap
instead of heap bitmap).

To make this work, raise the limit for type bitmaps so that they are
used for all types up to 64 kB in size (256 bytes of bitmap).
(The runtime already imposes a limit of 64 kB for a channel element size.)

I have been unable to reproduce this problem in a simple test program.

Could help #11035.

Change-Id: I06ad994032d8cff3438c9b3eaa8d853915128af5
Reviewed-on: https://go-review.googlesource.com/10815
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/compile/internal/gc/reflect.go
src/reflect/all_test.go
src/reflect/type.go
src/runtime/chan.go
src/runtime/mbitmap.go