mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd: move experiment flags into objabi.Experiment
This moves all remaining GOEXPERIMENT flags into the objabi.Experiment struct, drops the "_enabled" from their name, and makes them all bool typed. We also drop DebugFlags.Fieldtrack because the previous CL shifted the one test that used it to use GOEXPERIMENT instead. Change-Id: I3406fe62b1c300bb4caeaffa6ca5ce56a70497fe Reviewed-on: https://go-review.googlesource.com/c/go/+/302389 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
d3ab6b5049
commit
0c93b16d01
13 changed files with 29 additions and 34 deletions
|
|
@ -13,14 +13,10 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"cmd/internal/objabi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Debug holds the parsed debugging configuration values.
|
// Debug holds the parsed debugging configuration values.
|
||||||
var Debug = DebugFlags{
|
var Debug DebugFlags
|
||||||
Fieldtrack: &objabi.Fieldtrack_enabled,
|
|
||||||
}
|
|
||||||
|
|
||||||
// DebugFlags defines the debugging configuration values (see var Debug).
|
// DebugFlags defines the debugging configuration values (see var Debug).
|
||||||
// Each struct field is a different value, named for the lower-case of the field name.
|
// Each struct field is a different value, named for the lower-case of the field name.
|
||||||
|
|
@ -38,7 +34,6 @@ type DebugFlags struct {
|
||||||
DumpPtrs int `help:"show Node pointers values in dump output"`
|
DumpPtrs int `help:"show Node pointers values in dump output"`
|
||||||
DwarfInl int `help:"print information about DWARF inlined function creation"`
|
DwarfInl int `help:"print information about DWARF inlined function creation"`
|
||||||
Export int `help:"print export data"`
|
Export int `help:"print export data"`
|
||||||
Fieldtrack *int `help:"enable field tracking"`
|
|
||||||
GCProg int `help:"print dump of GC programs"`
|
GCProg int `help:"print dump of GC programs"`
|
||||||
InlFuncsWithClosures int `help:"allow functions with closures to be inlined"`
|
InlFuncsWithClosures int `help:"allow functions with closures to be inlined"`
|
||||||
Libfuzzer int `help:"enable coverage instrumentation for libfuzzer"`
|
Libfuzzer int `help:"enable coverage instrumentation for libfuzzer"`
|
||||||
|
|
@ -86,8 +81,6 @@ func init() {
|
||||||
panic(fmt.Sprintf("base.Debug.%s has invalid type %v (must be int or string)", f.Name, f.Type))
|
panic(fmt.Sprintf("base.Debug.%s has invalid type %v (must be int or string)", f.Name, f.Type))
|
||||||
case *int, *string:
|
case *int, *string:
|
||||||
// ok
|
// ok
|
||||||
case **int:
|
|
||||||
ptr = *ptr.(**int) // record the *int itself
|
|
||||||
}
|
}
|
||||||
debugTab = append(debugTab, debugField{name, help, ptr})
|
debugTab = append(debugTab, debugField{name, help, ptr})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ func concurrentBackendAllowed() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// TODO: Test and delete this condition.
|
// TODO: Test and delete this condition.
|
||||||
if objabi.Fieldtrack_enabled != 0 {
|
if objabi.Experiment.FieldTrack {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// TODO: fix races and enable the following flags
|
// TODO: fix races and enable the following flags
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ func createSimpleVar(fnsym *obj.LSym, n *ir.Name) *dwarf.Var {
|
||||||
if base.Ctxt.FixedFrameSize() == 0 {
|
if base.Ctxt.FixedFrameSize() == 0 {
|
||||||
offs -= int64(types.PtrSize)
|
offs -= int64(types.PtrSize)
|
||||||
}
|
}
|
||||||
if objabi.Framepointer_enabled {
|
if objabi.FramePointerEnabled {
|
||||||
offs -= int64(types.PtrSize)
|
offs -= int64(types.PtrSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ func pragmaFlag(verb string) ir.PragmaFlag {
|
||||||
case "go:build":
|
case "go:build":
|
||||||
return ir.GoBuildPragma
|
return ir.GoBuildPragma
|
||||||
case "go:nointerface":
|
case "go:nointerface":
|
||||||
if objabi.Fieldtrack_enabled != 0 {
|
if objabi.Experiment.FieldTrack {
|
||||||
return ir.Nointerface
|
return ir.Nointerface
|
||||||
}
|
}
|
||||||
case "go:noescape":
|
case "go:noescape":
|
||||||
|
|
|
||||||
|
|
@ -454,7 +454,7 @@ var passes = [...]pass{
|
||||||
{name: "dse", fn: dse},
|
{name: "dse", fn: dse},
|
||||||
{name: "writebarrier", fn: writebarrier, required: true}, // expand write barrier ops
|
{name: "writebarrier", fn: writebarrier, required: true}, // expand write barrier ops
|
||||||
{name: "insert resched checks", fn: insertLoopReschedChecks,
|
{name: "insert resched checks", fn: insertLoopReschedChecks,
|
||||||
disabled: objabi.Preemptibleloops_enabled == 0}, // insert resched checks in loops.
|
disabled: !objabi.Experiment.PreemptibleLoops}, // insert resched checks in loops.
|
||||||
{name: "lower", fn: lower, required: true},
|
{name: "lower", fn: lower, required: true},
|
||||||
{name: "addressing modes", fn: addressingModes, required: false},
|
{name: "addressing modes", fn: addressingModes, required: false},
|
||||||
{name: "lowered deadcode for cse", fn: deadcode}, // deadcode immediately before CSE avoids CSE making dead values live again
|
{name: "lowered deadcode for cse", fn: deadcode}, // deadcode immediately before CSE avoids CSE making dead values live again
|
||||||
|
|
|
||||||
|
|
@ -594,7 +594,7 @@ func (s *regAllocState) init(f *Func) {
|
||||||
if s.f.Config.hasGReg {
|
if s.f.Config.hasGReg {
|
||||||
s.allocatable &^= 1 << s.GReg
|
s.allocatable &^= 1 << s.GReg
|
||||||
}
|
}
|
||||||
if objabi.Framepointer_enabled && s.f.Config.FPReg >= 0 {
|
if objabi.FramePointerEnabled && s.f.Config.FPReg >= 0 {
|
||||||
s.allocatable &^= 1 << uint(s.f.Config.FPReg)
|
s.allocatable &^= 1 << uint(s.f.Config.FPReg)
|
||||||
}
|
}
|
||||||
if s.f.Config.LinkReg != -1 {
|
if s.f.Config.LinkReg != -1 {
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ func StackOffset(slot ssa.LocalSlot) int32 {
|
||||||
if base.Ctxt.FixedFrameSize() == 0 {
|
if base.Ctxt.FixedFrameSize() == 0 {
|
||||||
off -= int64(types.PtrSize)
|
off -= int64(types.PtrSize)
|
||||||
}
|
}
|
||||||
if objabi.Framepointer_enabled {
|
if objabi.FramePointerEnabled {
|
||||||
off -= int64(types.PtrSize)
|
off -= int64(types.PtrSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -215,7 +215,7 @@ func fieldtrack(fnsym *obj.LSym, tracked map[*obj.LSym]struct{}) {
|
||||||
if fnsym == nil {
|
if fnsym == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if objabi.Fieldtrack_enabled == 0 || len(tracked) == 0 {
|
if !objabi.Experiment.FieldTrack || len(tracked) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -931,7 +931,7 @@ func usemethod(n *ir.CallExpr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func usefield(n *ir.SelectorExpr) {
|
func usefield(n *ir.SelectorExpr) {
|
||||||
if objabi.Fieldtrack_enabled == 0 {
|
if !objabi.Experiment.FieldTrack {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ CheckFlags:
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Test and delete these conditions.
|
// TODO: Test and delete these conditions.
|
||||||
if objabi.Fieldtrack_enabled != 0 || objabi.Preemptibleloops_enabled != 0 {
|
if objabi.Experiment.FieldTrack || objabi.Experiment.PreemptibleLoops {
|
||||||
canDashC = false
|
canDashC = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,8 +174,14 @@ func init() {
|
||||||
GOEXPERIMENT = expList()
|
GOEXPERIMENT = expList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FramePointerEnabled enables the use of platform conventions for
|
||||||
|
// saving frame pointers.
|
||||||
|
//
|
||||||
|
// This used to be an experiment, but now it's always enabled on
|
||||||
|
// platforms that support it.
|
||||||
|
//
|
||||||
// Note: must agree with runtime.framepointer_enabled.
|
// Note: must agree with runtime.framepointer_enabled.
|
||||||
var Framepointer_enabled = GOARCH == "amd64" || GOARCH == "arm64"
|
var FramePointerEnabled = GOARCH == "amd64" || GOARCH == "arm64"
|
||||||
|
|
||||||
func addexp(s string) {
|
func addexp(s string) {
|
||||||
// Could do general integer parsing here, but the runtime.haveexperiment doesn't yet.
|
// Could do general integer parsing here, but the runtime.haveexperiment doesn't yet.
|
||||||
|
|
@ -203,18 +209,14 @@ func addexp(s string) {
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
Fieldtrack_enabled int
|
|
||||||
Preemptibleloops_enabled int
|
|
||||||
Staticlockranking_enabled int
|
|
||||||
)
|
|
||||||
|
|
||||||
// Experiment contains flags for GOEXPERIMENTs.
|
// Experiment contains flags for GOEXPERIMENTs.
|
||||||
//
|
var Experiment = ExpFlags{}
|
||||||
// TODO(austin): Move the package-level experiment flags into this.
|
|
||||||
var Experiment ExpFlags
|
|
||||||
|
|
||||||
type ExpFlags struct {
|
type ExpFlags struct {
|
||||||
|
FieldTrack bool
|
||||||
|
PreemptibleLoops bool
|
||||||
|
StaticLockRanking bool
|
||||||
|
|
||||||
// regabi is split into several sub-experiments that can be
|
// regabi is split into several sub-experiments that can be
|
||||||
// enabled individually. GOEXPERIMENT=regabi implies the
|
// enabled individually. GOEXPERIMENT=regabi implies the
|
||||||
// subset that are currently "working". Not all combinations work.
|
// subset that are currently "working". Not all combinations work.
|
||||||
|
|
@ -250,9 +252,9 @@ var exper = []struct {
|
||||||
name string
|
name string
|
||||||
val interface{} // Must be *int or *bool
|
val interface{} // Must be *int or *bool
|
||||||
}{
|
}{
|
||||||
{"fieldtrack", &Fieldtrack_enabled},
|
{"fieldtrack", &Experiment.FieldTrack},
|
||||||
{"preemptibleloops", &Preemptibleloops_enabled},
|
{"preemptibleloops", &Experiment.PreemptibleLoops},
|
||||||
{"staticlockranking", &Staticlockranking_enabled},
|
{"staticlockranking", &Experiment.StaticLockRanking},
|
||||||
{"regabi", &Experiment.regabi},
|
{"regabi", &Experiment.regabi},
|
||||||
{"regabiwrappers", &Experiment.RegabiWrappers},
|
{"regabiwrappers", &Experiment.RegabiWrappers},
|
||||||
{"regabig", &Experiment.RegabiG},
|
{"regabig", &Experiment.RegabiG},
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ type deadcodePass struct {
|
||||||
func (d *deadcodePass) init() {
|
func (d *deadcodePass) init() {
|
||||||
d.ldr.InitReachable()
|
d.ldr.InitReachable()
|
||||||
d.ifaceMethod = make(map[methodsig]bool)
|
d.ifaceMethod = make(map[methodsig]bool)
|
||||||
if objabi.Fieldtrack_enabled != 0 {
|
if objabi.Experiment.FieldTrack {
|
||||||
d.ldr.Reachparent = make([]loader.Sym, d.ldr.NSym())
|
d.ldr.Reachparent = make([]loader.Sym, d.ldr.NSym())
|
||||||
}
|
}
|
||||||
d.dynlink = d.ctxt.DynlinkingGo()
|
d.dynlink = d.ctxt.DynlinkingGo()
|
||||||
|
|
@ -255,7 +255,7 @@ func (d *deadcodePass) mark(symIdx, parent loader.Sym) {
|
||||||
if symIdx != 0 && !d.ldr.AttrReachable(symIdx) {
|
if symIdx != 0 && !d.ldr.AttrReachable(symIdx) {
|
||||||
d.wq.push(symIdx)
|
d.wq.push(symIdx)
|
||||||
d.ldr.SetAttrReachable(symIdx, true)
|
d.ldr.SetAttrReachable(symIdx, true)
|
||||||
if objabi.Fieldtrack_enabled != 0 && d.ldr.Reachparent[symIdx] == 0 {
|
if objabi.Experiment.FieldTrack && d.ldr.Reachparent[symIdx] == 0 {
|
||||||
d.ldr.Reachparent[symIdx] = parent
|
d.ldr.Reachparent[symIdx] = parent
|
||||||
}
|
}
|
||||||
if *flagDumpDep {
|
if *flagDumpDep {
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ func Main(arch *sys.Arch, theArch Arch) {
|
||||||
|
|
||||||
bench.Start("dostrdata")
|
bench.Start("dostrdata")
|
||||||
ctxt.dostrdata()
|
ctxt.dostrdata()
|
||||||
if objabi.Fieldtrack_enabled != 0 {
|
if objabi.Experiment.FieldTrack {
|
||||||
bench.Start("fieldtrack")
|
bench.Start("fieldtrack")
|
||||||
fieldtrack(ctxt.Arch, ctxt.loader)
|
fieldtrack(ctxt.Arch, ctxt.loader)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1105,5 +1105,5 @@ var (
|
||||||
isarchive bool // -buildmode=c-archive
|
isarchive bool // -buildmode=c-archive
|
||||||
)
|
)
|
||||||
|
|
||||||
// Must agree with cmd/internal/objabi.Framepointer_enabled.
|
// Must agree with cmd/internal/objabi.Experiment.FramePointer.
|
||||||
const framepointer_enabled = GOARCH == "amd64" || GOARCH == "arm64"
|
const framepointer_enabled = GOARCH == "amd64" || GOARCH == "arm64"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue