diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-01-10 05:26:29 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-01-10 05:26:29 +0000 |
commit | 692aefcd5618a00e622a1c96957d943723040b4c (patch) | |
tree | ae7606fee60c2a35f1f871e4356eb9e02c1b4078 /libgo | |
parent | e4876be5f5c5524ea742527100e36c5095181b28 (diff) | |
download | gcc-692aefcd5618a00e622a1c96957d943723040b4c.zip gcc-692aefcd5618a00e622a1c96957d943723040b4c.tar.gz gcc-692aefcd5618a00e622a1c96957d943723040b4c.tar.bz2 |
runtime: work around escaping closure in export_test.go
When compiling runtime, it is not allowed for local variables
and closures to be heap allocated. In one test, there is a go
statement with a closure. In the gc compiler, it distinguishes
capturing variable by value vs. by address, and rewrites it to
passing the captured values as arguments. Currently we don't
have this, and the escape analysis decides to heap allocate the
closure and also the captured variables, which is not allowed.
Work around it by passing the variables explicitly.
This is in preparation of turning on escape analysis for the
runtime.
Reviewed-on: https://go-review.googlesource.com/86245
From-SVN: r256419
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/runtime/export_test.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libgo/go/runtime/export_test.go b/libgo/go/runtime/export_test.go index e385f14..5e798e3 100644 --- a/libgo/go/runtime/export_test.go +++ b/libgo/go/runtime/export_test.go @@ -123,15 +123,15 @@ func RunSchedLocalQueueEmptyTest(iters int) { // can lead to underutilization (both runnable Gs and idle Ps coexist // for arbitrary long time). done := make(chan bool, 1) - p := new(p) + _p_ := new(p) gs := make([]g, 2) ready := new(uint32) for i := 0; i < iters; i++ { *ready = 0 next0 := (i & 1) == 0 next1 := (i & 2) == 0 - runqput(p, &gs[0], next0) - go func() { + runqput(_p_, &gs[0], next0) + go func(done chan bool, p *p, ready *uint32, next0, next1 bool) { for atomic.Xadd(ready, 1); atomic.Load(ready) != 2; { } if runqempty(p) { @@ -139,13 +139,13 @@ func RunSchedLocalQueueEmptyTest(iters int) { throw("queue is empty") } done <- true - }() + }(done, _p_, ready, next0, next1) for atomic.Xadd(ready, 1); atomic.Load(ready) != 2; { } - runqput(p, &gs[1], next1) - runqget(p) + runqput(_p_, &gs[1], next1) + runqget(_p_) <-done - runqget(p) + runqget(_p_) } } |