mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
[dev.typeparams] cmd/compile, runtime: always enable defer/go wrapping
Hardwire regabidefers to true. Remove it from GOEXPERIMENTs. Fallback paths are not cleaned up in this CL. That will be done in later CLs. Change-Id: Iec1112a1e55d5f6ef70232a5ff6e702f649071c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/325913 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
e58bddde70
commit
a9de78ac88
|
@ -4696,7 +4696,7 @@ func (s *state) openDeferRecord(n *ir.CallExpr) {
|
|||
var args []*ssa.Value
|
||||
var argNodes []*ir.Name
|
||||
|
||||
if buildcfg.Experiment.RegabiDefer && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) {
|
||||
if len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0 {
|
||||
s.Fatalf("defer call with arguments or results: %v", n)
|
||||
}
|
||||
|
||||
|
@ -4951,7 +4951,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
|
|||
}
|
||||
}
|
||||
|
||||
if buildcfg.Experiment.RegabiDefer && k != callNormal && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) {
|
||||
if k != callNormal && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) {
|
||||
s.Fatalf("go/defer call with arguments: %v", n)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ package walk
|
|||
import (
|
||||
"fmt"
|
||||
"go/constant"
|
||||
"internal/buildcfg"
|
||||
|
||||
"cmd/compile/internal/base"
|
||||
"cmd/compile/internal/escape"
|
||||
|
@ -790,9 +789,7 @@ func (o *orderState) stmt(n ir.Node) {
|
|||
n.Call = walkRecover(n.Call.(*ir.CallExpr), &init)
|
||||
o.stmtList(init)
|
||||
}
|
||||
if buildcfg.Experiment.RegabiDefer {
|
||||
o.wrapGoDefer(n)
|
||||
}
|
||||
o.wrapGoDefer(n)
|
||||
o.out = append(o.out, n)
|
||||
o.cleanTemp(t)
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ var experimentBaseline = goexperiment.Flags{
|
|||
RegabiWrappers: regabiSupported,
|
||||
RegabiG: regabiSupported,
|
||||
RegabiReflect: regabiSupported,
|
||||
RegabiDefer: true,
|
||||
RegabiArgs: regabiSupported,
|
||||
}
|
||||
|
||||
|
@ -70,7 +69,6 @@ func parseExperiments() goexperiment.Flags {
|
|||
flags.RegabiWrappers = v
|
||||
flags.RegabiG = v
|
||||
flags.RegabiReflect = v
|
||||
flags.RegabiDefer = v
|
||||
flags.RegabiArgs = v
|
||||
}
|
||||
|
||||
|
@ -110,8 +108,8 @@ func parseExperiments() goexperiment.Flags {
|
|||
if flags.RegabiG && !flags.RegabiWrappers {
|
||||
Error = fmt.Errorf("GOEXPERIMENT regabig requires regabiwrappers")
|
||||
}
|
||||
if flags.RegabiArgs && !(flags.RegabiWrappers && flags.RegabiG && flags.RegabiReflect && flags.RegabiDefer) {
|
||||
Error = fmt.Errorf("GOEXPERIMENT regabiargs requires regabiwrappers,regabig,regabireflect,regabidefer")
|
||||
if flags.RegabiArgs && !(flags.RegabiWrappers && flags.RegabiG && flags.RegabiReflect) {
|
||||
Error = fmt.Errorf("GOEXPERIMENT regabiargs requires regabiwrappers,regabig,regabireflect")
|
||||
}
|
||||
return flags
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
// Code generated by mkconsts.go. DO NOT EDIT.
|
||||
|
||||
//go:build !goexperiment.regabidefer
|
||||
// +build !goexperiment.regabidefer
|
||||
|
||||
package goexperiment
|
||||
|
||||
const RegabiDefer = false
|
||||
const RegabiDeferInt = 0
|
|
@ -1,9 +0,0 @@
|
|||
// Code generated by mkconsts.go. DO NOT EDIT.
|
||||
|
||||
//go:build goexperiment.regabidefer
|
||||
// +build goexperiment.regabidefer
|
||||
|
||||
package goexperiment
|
||||
|
||||
const RegabiDefer = true
|
||||
const RegabiDeferInt = 1
|
|
@ -78,9 +78,6 @@ type Flags struct {
|
|||
// reflect and runtime (which are disabled by default) so it
|
||||
// can be used in targeted tests.
|
||||
RegabiReflect bool
|
||||
// RegabiDefer enables desugaring defer and go calls
|
||||
// into argument-less closures.
|
||||
RegabiDefer bool
|
||||
// RegabiArgs enables register arguments/results in all
|
||||
// compiled Go functions.
|
||||
//
|
||||
|
|
|
@ -6,7 +6,6 @@ package runtime
|
|||
|
||||
import (
|
||||
"internal/abi"
|
||||
"internal/goexperiment"
|
||||
"runtime/internal/atomic"
|
||||
"runtime/internal/sys"
|
||||
"unsafe"
|
||||
|
@ -236,7 +235,7 @@ func deferproc(siz int32, fn *funcval) { // arguments of fn follow fn
|
|||
throw("defer on system stack")
|
||||
}
|
||||
|
||||
if goexperiment.RegabiDefer && siz != 0 {
|
||||
if true && siz != 0 {
|
||||
// TODO: Make deferproc just take a func().
|
||||
throw("defer with non-empty frame")
|
||||
}
|
||||
|
@ -293,7 +292,7 @@ func deferprocStack(d *_defer) {
|
|||
// go code on the system stack can't defer
|
||||
throw("defer on system stack")
|
||||
}
|
||||
if goexperiment.RegabiDefer && d.siz != 0 {
|
||||
if true && d.siz != 0 {
|
||||
throw("defer with non-empty frame")
|
||||
}
|
||||
// siz and fn are already set.
|
||||
|
@ -395,7 +394,7 @@ func deferArgs(d *_defer) unsafe.Pointer {
|
|||
// that experiment, we should change the type of d.fn.
|
||||
//go:nosplit
|
||||
func deferFunc(d *_defer) func() {
|
||||
if !goexperiment.RegabiDefer {
|
||||
if false {
|
||||
throw("requires GOEXPERIMENT=regabidefer")
|
||||
}
|
||||
var fn func()
|
||||
|
@ -655,7 +654,7 @@ func Goexit() {
|
|||
addOneOpenDeferFrame(gp, 0, nil)
|
||||
}
|
||||
} else {
|
||||
if goexperiment.RegabiDefer {
|
||||
if true {
|
||||
// Save the pc/sp in deferCallSave(), so we can "recover" back to this
|
||||
// loop if necessary.
|
||||
deferCallSave(&p, deferFunc(d))
|
||||
|
@ -857,7 +856,7 @@ func runOpenDeferFrame(gp *g, d *_defer) bool {
|
|||
argWidth, fd = readvarintUnsafe(fd)
|
||||
closureOffset, fd = readvarintUnsafe(fd)
|
||||
nArgs, fd = readvarintUnsafe(fd)
|
||||
if goexperiment.RegabiDefer && argWidth != 0 {
|
||||
if true && argWidth != 0 {
|
||||
throw("defer with non-empty frame")
|
||||
}
|
||||
if deferBits&(1<<i) == 0 {
|
||||
|
@ -885,7 +884,7 @@ func runOpenDeferFrame(gp *g, d *_defer) bool {
|
|||
deferBits = deferBits &^ (1 << i)
|
||||
*(*uint8)(unsafe.Pointer(d.varp - uintptr(deferBitsOffset))) = deferBits
|
||||
p := d._panic
|
||||
if goexperiment.RegabiDefer {
|
||||
if true {
|
||||
deferCallSave(p, deferFunc(d))
|
||||
} else {
|
||||
reflectcallSave(p, unsafe.Pointer(closure), deferArgs, argWidth)
|
||||
|
@ -913,7 +912,7 @@ func runOpenDeferFrame(gp *g, d *_defer) bool {
|
|||
// This is marked as a wrapper by the compiler so it doesn't appear in
|
||||
// tracebacks.
|
||||
func reflectcallSave(p *_panic, fn, arg unsafe.Pointer, argsize uint32) {
|
||||
if goexperiment.RegabiDefer {
|
||||
if true {
|
||||
throw("not allowed with GOEXPERIMENT=regabidefer")
|
||||
}
|
||||
if p != nil {
|
||||
|
@ -939,7 +938,7 @@ func reflectcallSave(p *_panic, fn, arg unsafe.Pointer, argsize uint32) {
|
|||
// This is marked as a wrapper by the compiler so it doesn't appear in
|
||||
// tracebacks.
|
||||
func deferCallSave(p *_panic, fn func()) {
|
||||
if !goexperiment.RegabiDefer {
|
||||
if false {
|
||||
throw("only allowed with GOEXPERIMENT=regabidefer")
|
||||
}
|
||||
if p != nil {
|
||||
|
@ -1042,7 +1041,7 @@ func gopanic(e interface{}) {
|
|||
} else {
|
||||
p.argp = unsafe.Pointer(getargp())
|
||||
|
||||
if goexperiment.RegabiDefer {
|
||||
if true {
|
||||
fn := deferFunc(d)
|
||||
fn()
|
||||
} else {
|
||||
|
|
|
@ -7,7 +7,6 @@ package runtime
|
|||
import (
|
||||
"internal/abi"
|
||||
"internal/cpu"
|
||||
"internal/goexperiment"
|
||||
"runtime/internal/atomic"
|
||||
"runtime/internal/sys"
|
||||
"unsafe"
|
||||
|
@ -4259,7 +4258,7 @@ func newproc(siz int32, fn *funcval) {
|
|||
//
|
||||
//go:systemstack
|
||||
func newproc1(fn *funcval, argp unsafe.Pointer, narg int32, callergp *g, callerpc uintptr) *g {
|
||||
if goexperiment.RegabiDefer && narg != 0 {
|
||||
if true && narg != 0 {
|
||||
// TODO: When we commit to GOEXPERIMENT=regabidefer,
|
||||
// rewrite the comments for newproc and newproc1.
|
||||
// newproc will no longer have a funny stack layout or
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// errorcheckwithauto -0 -l -live -wb=0 -d=ssa/insert_resched_checks/off
|
||||
// +build !ppc64,!ppc64le,goexperiment.regabidefer,!goexperiment.regabiargs
|
||||
// +build !ppc64,!ppc64le,!goexperiment.regabiargs
|
||||
|
||||
// ppc64 needs a better tighten pass to make f18 pass
|
||||
// rescheduling checks need to be turned off because there are some live variables across the inserted check call
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// errorcheckwithauto -0 -l -live -wb=0 -d=ssa/insert_resched_checks/off
|
||||
// +build amd64,goexperiment.regabidefer,goexperiment.regabiargs
|
||||
// +build amd64,goexperiment.regabiargs
|
||||
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
|
|
Loading…
Reference in a new issue