aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-07-04 02:20:37 +0000
committerIan Lance Taylor <iant@golang.org>2019-07-04 02:20:37 +0000
commitcfa3d85bcb9b605ba9f4cae91daf54908bf75b0a (patch)
treeb01088e287d6565278c17bc004de616ba1a0891f /libgo
parent8456fafdb46128c057682e221db94489c025555b (diff)
compiler: optimize 0,1,2-case select statement
For a select statement with zero-, one-, or two-case with a default case, we can generate simpler code instead of calling the generic selectgo. A zero-case select is just blocking the execution. A one-case select is mostly just executing the case. A two-case select with a default case is a non-blocking send or receive. We add these special cases for lowering a select statement. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/184998 git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@273034 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/runtime/chan.go3
-rw-r--r--libgo/go/runtime/select.go1
2 files changed, 4 insertions, 0 deletions
diff --git a/libgo/go/runtime/chan.go b/libgo/go/runtime/chan.go
index 6dfe2f3fc3e..6c8d6f70ebd 100644
--- a/libgo/go/runtime/chan.go
+++ b/libgo/go/runtime/chan.go
@@ -32,6 +32,9 @@ import (
//go:linkname chanrecv1 runtime.chanrecv1
//go:linkname chanrecv2 runtime.chanrecv2
//go:linkname closechan runtime.closechan
+//go:linkname selectnbsend runtime.selectnbsend
+//go:linkname selectnbrecv runtime.selectnbrecv
+//go:linkname selectnbrecv2 runtime.selectnbrecv2
const (
maxAlign = 8
diff --git a/libgo/go/runtime/select.go b/libgo/go/runtime/select.go
index d658a349ed2..16de9b88f6c 100644
--- a/libgo/go/runtime/select.go
+++ b/libgo/go/runtime/select.go
@@ -14,6 +14,7 @@ import (
// themselves, so that the compiler will export them.
//
//go:linkname selectgo runtime.selectgo
+//go:linkname block runtime.block
const debugSelect = false