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

Issue 100480043: code review 100480043: cmd/gc: fix two select temporary bugs (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years ago by rsc
Modified:
10 years ago
Reviewers:
iant
CC:
golang-codereviews, iant
Visibility:
Public.

Description

cmd/gc: fix two select temporary bugs The introduction of temporaries in order.c was not quite right for two corner cases: 1) The rewrite that pushed new variables on the lhs of a receive into the body of the case was dropping the declaration of the variables. If the variables escape, the declaration is what allocates them. Caught by escape analysis sanity check. In fact the declarations should move into the body always, so that we only allocate if the corresponding case is selected. Do that. (This is an optimization that was already present in Go 1.2. The new order code just made it stop working.) Fixes issue 7997. 2) The optimization to turn a single-recv select into an ordinary receive assumed it could take the address of the destination; not so if the destination is _. Fixes issue 7998.

Patch Set 1 #

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

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

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+116 lines, -1 line) Patch
M src/cmd/gc/order.c View 1 2 4 chunks +36 lines, -0 lines 0 comments Download
M src/cmd/gc/walk.c View 1 1 chunk +4 lines, -1 line 0 comments Download
A test/fixedbugs/issue7997.go View 1 2 1 chunk +53 lines, -0 lines 0 comments Download
A test/fixedbugs/issue7998.go View 1 1 chunk +23 lines, -0 lines 0 comments Download

Messages

Total messages: 3
rsc
Hello golang-codereviews@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
10 years ago (2014-05-15 03:10:19 UTC) #1
iant
LGTM
10 years ago (2014-05-15 23:12:19 UTC) #2
rsc
10 years ago (2014-05-15 23:16:25 UTC) #3
*** Submitted as https://code.google.com/p/go/source/detail?r=d085f281ce88 ***

cmd/gc: fix two select temporary bugs

The introduction of temporaries in order.c was not
quite right for two corner cases:

1) The rewrite that pushed new variables on the lhs of
a receive into the body of the case was dropping the
declaration of the variables. If the variables escape,
the declaration is what allocates them.
Caught by escape analysis sanity check.
In fact the declarations should move into the body
always, so that we only allocate if the corresponding
case is selected. Do that. (This is an optimization that
was already present in Go 1.2. The new order code just
made it stop working.)

Fixes issue 7997.

2) The optimization to turn a single-recv select into
an ordinary receive assumed it could take the address
of the destination; not so if the destination is _.

Fixes issue 7998.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://codereview.appspot.com/100480043
Sign in to reply to this message.

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