]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/gc, runtime: treat slices and strings like pointers in garbage collection
authorRuss Cox <rsc@golang.org>
Mon, 25 Aug 2014 18:38:19 +0000 (14:38 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 25 Aug 2014 18:38:19 +0000 (14:38 -0400)
commit613383c7651d490aae045eb70cd515b151735766
treec77f23bff111b953d23cb7a3bf288116dcca137f
parentc6f7c176a3a46ff87d72c4b744bbadf02df1890e
cmd/gc, runtime: treat slices and strings like pointers in garbage collection

Before, a slice with cap=0 or a string with len=0 might have its
base pointer pointing beyond the actual slice/string data into
the next block. The collector had to ignore slices and strings with
cap=0 in order to avoid misinterpreting the base pointer.

Now, a slice with cap=0 or a string with len=0 still has a base
pointer pointing into the actual slice/string data, no matter what.
The collector can now always scan the pointer, which means
strings and slices are no longer special.

Fixes #8404.

LGTM=khr, josharian
R=josharian, khr, dvyukov
CC=golang-codereviews
https://golang.org/cl/112570044
25 files changed:
src/cmd/5g/cgen.c
src/cmd/5g/gsubr.c
src/cmd/6g/cgen.c
src/cmd/6g/gsubr.c
src/cmd/8g/cgen.c
src/cmd/8g/gsubr.c
src/cmd/gc/fmt.c
src/cmd/gc/gen.c
src/cmd/gc/go.h
src/cmd/gc/plive.c
src/cmd/gc/reflect.c
src/cmd/gc/subr.c
src/cmd/gc/typecheck.c
src/cmd/gc/walk.c
src/pkg/reflect/all_test.go
src/pkg/reflect/value.go
src/pkg/runtime/gcinfo_test.go
src/pkg/runtime/heapdump.c
src/pkg/runtime/malloc.h
src/pkg/runtime/mgc0.c
src/pkg/runtime/mgc0.h
src/pkg/runtime/runtime.h
src/pkg/runtime/stack.c
test/slice3.go
test/slicecap.go [new file with mode: 0644]