1
0
mirror of https://github.com/golang/go synced 2024-09-30 08:28:34 -06:00
go/test
Keith Randall e410a527b2 runtime: simplify chan ops, take 2
This change is the same as CL #9345 which was reverted,
except for a small bug fix.

The only change is to the body of sendDirect and its callsite.
Also added a test.

The problem was during a channel send operation.  The target
of the send was a sleeping goroutine waiting to receive.  We
basically do:
1) Read the destination pointer out of the sudog structure
2) Copy the value we're sending to that destination pointer
Unfortunately, the previous change had a goroutine suspend
point between 1 & 2 (the call to sendDirect).  At that point
the destination goroutine's stack could be copied (shrunk).
The pointer we read in step 1 is no longer valid for step 2.

Fixed by not allowing any suspension points between 1 & 2.
I suspect the old code worked correctly basically by accident.

Fixes #13169

The original 9345:

This change removes the retry mechanism we use for buffered channels.
Instead, any sender waking up a receiver or vice versa completes the
full protocol with its counterpart.  This means the counterpart does
not need to relock the channel when it wakes up.  (Currently
buffered channels need to relock on wakeup.)

For sends on a channel with waiting receivers, this change replaces
two copies (sender->queue, queue->receiver) with one (sender->receiver).
For receives on channels with a waiting sender, two copies are still required.

This change unifies to a large degree the algorithm for buffered
and unbuffered channels, simplifying the overall implementation.

Fixes #11506

Change-Id: I57dfa3fc219cffa4d48301ee15fe5479299efa09
Reviewed-on: https://go-review.googlesource.com/16740
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-08 23:20:25 +00:00
..
bench test/bench/shootout: fix build 2015-07-31 17:37:58 +00:00
bugs
chan
ddd2.dir
dwarf
fixedbugs runtime: simplify chan ops, take 2 2015-11-08 23:20:25 +00:00
import2.dir
import4.dir test: adjust gccgo expected import errors 2015-10-07 14:37:44 +00:00
interface
ken
method4.dir
safe
stress
syntax
64bit.go
235.go
alias1.go
alias.go
append.go
args.go
assign1.go
assign.go
bigalg.go
bigmap.go
blank1.go
blank.go
bom.go
bombad.go
bounds.go
chancap.go
chanlinear.go
char_lit1.go
char_lit.go
clearfat.go
closedchan.go
closure1.go
closure2.go
closure.go
cmp6.go
cmp.go
cmplx.go
cmplxdivide1.go
cmplxdivide.c
cmplxdivide.go
complit1.go
complit.go
compos.go
const1.go
const2.go
const3.go
const4.go
const5.go
const6.go
const.go cmd/compile: allow huge rsh in constants arithmetic 2015-08-21 20:27:22 +00:00
convert1.go
convert3.go
convert.go
convlit1.go
convlit.go
convT2X.go
copy.go
crlf.go
ddd1.go
ddd2.go
ddd.go
decl.go
declbad.go
defer.go
deferfin.go
deferprint.go
deferprint.out
divide.go
divmod.go
empty.go
env.go
eof1.go
eof.go
errchk
escape2.go cmd/compile: escape analysis, don't always escape variadic args 2015-10-04 20:45:35 +00:00
escape2n.go cmd/compile: escape analysis, don't always escape variadic args 2015-10-04 20:45:35 +00:00
escape3.go
escape4.go
escape5.go
escape_array.go
escape_calls.go
escape_closure.go
escape_field.go
escape_iface.go cmd/compile: add case for ODOTTYPE to escwalk 2015-07-30 17:39:44 +00:00
escape_indir.go
escape_level.go
escape_map.go
escape_param.go
escape_slice.go
escape_struct_param1.go
escape_struct_param2.go
escape_struct_return.go
escape.go
fibo.go
finprofiled.go runtime: fix finalization and profiling of tiny allocations 2015-11-03 18:57:18 +00:00
float_lit2.go
float_lit3.go
float_lit.go
floatcmp.go
for.go
func1.go
func2.go
func3.go
func4.go
func5.go
func6.go
func7.go
func8.go test: use go:noinline consistently 2015-11-03 02:01:34 +00:00
func.go
funcdup2.go
funcdup.go
gc1.go
gc2.go
gc.go
gcstring.go
goprint.go
goprint.out
goto.go
heapsampling.go test: disable flaky heapsampling test for now 2015-10-30 20:48:03 +00:00
helloworld.go
helloworld.out
if.go
import1.go
import2.go
import4.go
import5.go
import.go
index0.go
index1.go
index2.go
index.go
indirect1.go
indirect.go
init1.go
init.go
initcomma.go
initialize.go
initializerr.go
initloop.go cmd/compile: use []*Node instead of NodeList in sinit 2015-09-05 02:25:01 +00:00
inline.go cmd/compile: add support for a go:noinline directive 2015-10-29 23:16:27 +00:00
int_lit.go
intcvt.go
iota.go
label1.go
label.go
linkx_run.go
linkx.go
literal.go
live1.go
live2.go
live.go
mallocfin.go
map1.go
map.go
maplinear.go
method1.go
method2.go
method3.go
method4.go
method5.go
method.go
named1.go
named.go
nil.go
nilcheck.go
nilptr2.go
nilptr3.go
nilptr4.go
nilptr.go
nosplit.go cmd/internal/obj/arm64: reject misaligned stack frames, except empty frames 2015-07-29 21:37:12 +00:00
nul1.go
parentype.go
peano.go
print.go
print.out
printbig.go
printbig.out
range.go
recover1.go
recover2.go
recover3.go
recover4.go test: move allocation before munmap in recover4 2015-09-16 08:51:48 +00:00
recover.go
rename1.go
rename.go
reorder2.go test: use go:noinline consistently 2015-11-03 02:01:34 +00:00
reorder.go
return.go
rotate0.go
rotate1.go
rotate2.go
rotate3.go
rotate.go
run.go
rune.go
runtime.go
shift1.go
shift2.go
sieve.go
sigchld.go
sigchld.out
simassign.go
sinit_run.go
sinit.go
sizeof.go
slice3.go
slice3err.go
slicecap.go
sliceopt.go
solitaire.go
stack.go
string_lit.go
stringrange.go
struct0.go
switch3.go
switch4.go
switch.go
tinyfin.go runtime: fix finalization and profiling of tiny allocations 2015-11-03 18:57:18 +00:00
torture.go
turing.go
typecheck.go
typecheckloop.go cmd/compile: convert typecheck_stack to []*Node 2015-09-06 23:50:51 +00:00
typeswitch1.go
typeswitch2.go
typeswitch3.go
typeswitch.go
undef.go
utf.go
varerr.go
varinit.go
writebarrier.go
zerodivide.go