runtime: remove scase.releasetime field

This is the gofrontend version of https://golang.org/cl/245122.
Original CL description:

    selectgo will report at most one block event, so there's no need to
    keep a releasetime for every select case. It suffices to simply track
    the releasetime of the case responsible for the wakeup.

    Updates golang/go#40410.

This is being brought over to gofrontend as a step toward upgrading to
Go1.16beta1.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/279732
This commit is contained in:
Ian Lance Taylor 2020-12-21 14:58:14 -08:00
parent ffd454b92b
commit 1fa5fc7408
3 changed files with 12 additions and 16 deletions

View File

@ -1,4 +1,4 @@
f9e44c6e510df9f047dbe28eb5fa19642e350f8f c8456995b0118a92820c6c1d8f996d4b1adf55c2
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.

View File

@ -8908,11 +8908,10 @@ Channel_type::select_case_type()
Type* uint16_type = Type::lookup_integer_type("uint16"); Type* uint16_type = Type::lookup_integer_type("uint16");
Type* int64_type = Type::lookup_integer_type("int64"); Type* int64_type = Type::lookup_integer_type("int64");
scase_type = scase_type =
Type::make_builtin_struct_type(4, Type::make_builtin_struct_type(3,
"c", unsafe_pointer_type, "c", unsafe_pointer_type,
"elem", unsafe_pointer_type, "elem", unsafe_pointer_type,
"kind", uint16_type, "kind", uint16_type);
"releasetime", int64_type);
scase_type->set_is_struct_incomparable(); scase_type->set_is_struct_incomparable();
} }
return scase_type; return scase_type;

View File

@ -32,10 +32,9 @@ const (
// Known to compiler. // Known to compiler.
// Changes here must also be made in src/cmd/internal/gc/select.go's scasetype. // Changes here must also be made in src/cmd/internal/gc/select.go's scasetype.
type scase struct { type scase struct {
c *hchan // chan c *hchan // chan
elem unsafe.Pointer // data element elem unsafe.Pointer // data element
kind uint16 kind uint16
releasetime int64
} }
func sellock(scases []scase, lockorder []uint16) { func sellock(scases []scase, lockorder []uint16) {
@ -151,9 +150,6 @@ func selectgo(cas0 *scase, order0 *uint16, ncases int) (int, bool) {
var t0 int64 var t0 int64
if blockprofilerate > 0 { if blockprofilerate > 0 {
t0 = cputicks() t0 = cputicks()
for i := 0; i < ncases; i++ {
scases[i].releasetime = -1
}
} }
// The compiler rewrites selects that statically have // The compiler rewrites selects that statically have
@ -241,6 +237,7 @@ loop:
var dfl *scase var dfl *scase
var casi int var casi int
var cas *scase var cas *scase
var caseReleaseTime int64 = -1
var recvOK bool var recvOK bool
for i := 0; i < ncases; i++ { for i := 0; i < ncases; i++ {
casi = int(pollorder[i]) casi = int(pollorder[i])
@ -361,13 +358,13 @@ loop:
if k.kind == caseNil { if k.kind == caseNil {
continue continue
} }
if sglist.releasetime > 0 {
k.releasetime = sglist.releasetime
}
if sg == sglist { if sg == sglist {
// sg has already been dequeued by the G that woke us up. // sg has already been dequeued by the G that woke us up.
casi = int(casei) casi = int(casei)
cas = k cas = k
if sglist.releasetime > 0 {
caseReleaseTime = sglist.releasetime
}
} else { } else {
c = k.c c = k.c
if k.kind == caseSend { if k.kind == caseSend {
@ -465,8 +462,8 @@ send:
goto retc goto retc
retc: retc:
if cas.releasetime > 0 { if caseReleaseTime > 0 {
blockevent(cas.releasetime-t0, 1) blockevent(caseReleaseTime-t0, 1)
} }
// Check preemption, since unlike gc we don't check on every call. // Check preemption, since unlike gc we don't check on every call.