Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(16)

Issue 112570044: code review 112570044: cmd/gc, runtime: treat slices and strings like pointers... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 9 months ago by rsc
Modified:
9 years, 7 months ago
Reviewers:
gobot, khr, josharian
CC:
josharian, khr, dvyukov, golang-codereviews
Visibility:
Public.

Description

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 issue 8404.

Patch Set 1 #

Patch Set 2 : diff -r e5fa01e2f333 https://code.google.com/p/go/ #

Patch Set 3 : diff -r e5fa01e2f333 https://code.google.com/p/go/ #

Patch Set 4 : diff -r ef2344f636e4 https://code.google.com/p/go/ #

Patch Set 5 : diff -r 2fa7b95cf34c https://code.google.com/p/go/ #

Total comments: 2

Patch Set 6 : diff -r e5f21706c4caff5f274a47e5d471689d0d0dd683 https://code.google.com/p/go/ #

Patch Set 7 : diff -r 203e5e3455a0cc7ea42c537eb7c9f60d1dc44c32 https://code.google.com/p/go/ #

Patch Set 8 : diff -r 6d5c17d94e9ddcd8ca450ac62f84cf9ddb436b65 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+249 lines, -163 lines) Patch
M src/cmd/5g/cgen.c View 1 2 3 1 chunk +0 lines, -1 line 0 comments Download
M src/cmd/5g/gsubr.c View 1 2 3 4 1 chunk +0 lines, -1 line 0 comments Download
M src/cmd/6g/cgen.c View 1 2 3 1 chunk +0 lines, -1 line 0 comments Download
M src/cmd/6g/gsubr.c View 1 2 3 4 5 1 chunk +0 lines, -2 lines 0 comments Download
M src/cmd/8g/cgen.c View 1 2 3 4 1 chunk +0 lines, -1 line 0 comments Download
M src/cmd/8g/gsubr.c View 1 2 3 4 1 chunk +0 lines, -1 line 0 comments Download
M src/cmd/gc/fmt.c View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/gc/gen.c View 1 2 3 3 chunks +40 lines, -15 lines 0 comments Download
M src/cmd/gc/go.h View 1 2 3 4 5 1 chunk +0 lines, -1 line 0 comments Download
M src/cmd/gc/plive.c View 1 2 3 4 5 2 chunks +2 lines, -5 lines 0 comments Download
M src/cmd/gc/reflect.c View 1 2 3 4 5 2 chunks +4 lines, -4 lines 0 comments Download
M src/cmd/gc/subr.c View 1 2 3 4 5 1 chunk +6 lines, -2 lines 0 comments Download
M src/cmd/gc/typecheck.c View 1 2 3 1 chunk +0 lines, -13 lines 0 comments Download
M src/cmd/gc/walk.c View 1 2 3 4 5 1 chunk +7 lines, -7 lines 0 comments Download
M src/pkg/reflect/all_test.go View 1 2 3 2 chunks +18 lines, -0 lines 0 comments Download
M src/pkg/reflect/value.go View 1 2 3 4 5 2 chunks +12 lines, -2 lines 0 comments Download
M src/pkg/runtime/gcinfo_test.go View 1 2 3 4 5 9 chunks +27 lines, -23 lines 0 comments Download
M src/pkg/runtime/heapdump.c View 1 2 3 4 5 6 3 chunks +6 lines, -16 lines 0 comments Download
M src/pkg/runtime/malloc.h View 1 2 3 4 5 2 chunks +3 lines, -1 line 0 comments Download
M src/pkg/runtime/mgc0.h View 1 2 3 4 5 1 chunk +2 lines, -2 lines 0 comments Download
M src/pkg/runtime/mgc0.c View 1 2 3 4 5 11 chunks +18 lines, -42 lines 0 comments Download
M src/pkg/runtime/runtime.h View 1 2 3 4 5 1 chunk +0 lines, -2 lines 0 comments Download
M src/pkg/runtime/stack.c View 1 2 3 4 5 1 chunk +2 lines, -13 lines 0 comments Download
M test/slice3.go View 1 5 chunks +11 lines, -7 lines 0 comments Download
A test/slicecap.go View 1 2 1 chunk +90 lines, -0 lines 0 comments Download

Messages

Total messages: 23
rsc
Hello josharian@gmail.com, khr (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
9 years, 9 months ago (2014-07-22 04:08:52 UTC) #1
rsc
I don't know why ADDPTR was used in one case but not the other here. ...
9 years, 9 months ago (2014-07-22 04:15:48 UTC) #2
josharian
> I don't know why ADDPTR was used in one case but not the other ...
9 years, 9 months ago (2014-07-22 17:05:50 UTC) #3
josharian
> The plan is to disallow slice representations in which the base pointer points outside ...
9 years, 9 months ago (2014-07-22 18:04:05 UTC) #4
rsc
On Tue, Jul 22, 2014 at 2:04 PM, <josharian@gmail.com> wrote: > The plan is to ...
9 years, 9 months ago (2014-07-22 18:31:11 UTC) #5
josharian
Here's before and after generated code (6g) for func f() { a := make([]byte, 10) ...
9 years, 9 months ago (2014-07-22 19:05:51 UTC) #6
josharian
On 2014/07/22 18:31:11, rsc wrote: > On Tue, Jul 22, 2014 at 2:04 PM, <mailto:josharian@gmail.com> ...
9 years, 9 months ago (2014-07-23 01:45:43 UTC) #7
rsc
Hello josharian@gmail.com, khr@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
9 years, 9 months ago (2014-07-23 02:50:49 UTC) #8
josharian
I remain concerned that introducing a JMP as part of every slice will end up ...
9 years, 9 months ago (2014-07-23 18:37:13 UTC) #9
khr
LGTM, with josharian's comments fixed.
9 years, 9 months ago (2014-07-23 22:53:21 UTC) #10
josharian
If you want to get this in today before you go, I'll look at tweaking ...
9 years, 9 months ago (2014-07-24 16:51:25 UTC) #11
josharian
> If you want to get this in today before you go, I'll look at ...
9 years, 9 months ago (2014-07-30 19:28:31 UTC) #12
rsc
I refreshed this CL and will submit it shortly. I had to reapply some of ...
9 years, 8 months ago (2014-08-25 18:10:33 UTC) #13
rsc
Can someone tell me the difference between BitsScalar and BitsDead? I don't believe the liveness ...
9 years, 8 months ago (2014-08-25 18:11:28 UTC) #14
dvyukov
BitsScalar and BitsDead are used in stacks. If the word contains at least one live ...
9 years, 8 months ago (2014-08-25 18:31:35 UTC) #15
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=caab29a25f68 *** cmd/gc, runtime: treat slices and strings like pointers in garbage ...
9 years, 8 months ago (2014-08-25 18:38:23 UTC) #16
rsc
I chatted with Dmitriy a bit about BitsScalar and BitsDead. The liveness analysis ignores stack ...
9 years, 8 months ago (2014-08-25 18:44:00 UTC) #17
dvyukov
On Mon, Aug 25, 2014 at 10:43 PM, Russ Cox <rsc@golang.org> wrote: > I chatted ...
9 years, 8 months ago (2014-08-25 18:59:05 UTC) #18
rsc
I think the debug mode is still there. case BitsDead: if(runtime·debug.gcdead) scanp[i] = (byte*)PoisonStack; break;
9 years, 8 months ago (2014-08-25 19:11:11 UTC) #19
dvyukov
ah, it's already copy-pasted from mgc0.c :) On Mon, Aug 25, 2014 at 11:11 PM, ...
9 years, 8 months ago (2014-08-25 19:20:31 UTC) #20
gobot
This CL appears to have broken the darwin-386 builder. See http://build.golang.org/log/a6467e911eebd309380add098e6d63ba831c9cf1
9 years, 8 months ago (2014-08-25 21:46:12 UTC) #21
dvyukov
there is something wrong with this change, it increases GC pause by 10-20% http://build.golang.org/perfdetail?commit=caab29a25f686946a383ec31d2ea6408265aa466&commit0=6d5c17d94e9ddcd8ca450ac62f84cf9ddb436b65&builder=windows-amd64-perf&benchmark=http On ...
9 years, 7 months ago (2014-09-01 08:27:19 UTC) #22
rsc
9 years, 7 months ago (2014-09-01 13:48:14 UTC) #23
On Mon, Sep 1, 2014 at 4:26 AM, Dmitry Vyukov <dvyukov@google.com> wrote:

> there is something wrong with this change, it increases GC pause by 10-20%
>
>
http://build.golang.org/perfdetail?commit=caab29a25f686946a383ec31d2ea6408265...


Thanks for noticing. Please file an issue.

Russ
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b