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"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"cmd/internal/objabi"
|
||||
)
|
||||
|
||||
// Debug holds the parsed debugging configuration values.
|
||||
var Debug = DebugFlags{
|
||||
Fieldtrack: &objabi.Fieldtrack_enabled,
|
||||
}
|
||||
var Debug DebugFlags
|
||||
|
||||
// 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.
|
||||
|
|
@ -38,7 +34,6 @@ type DebugFlags struct {
|
|||
DumpPtrs int `help:"show Node pointers values in dump output"`
|
||||
DwarfInl int `help:"print information about DWARF inlined function creation"`
|
||||
Export int `help:"print export data"`
|
||||
Fieldtrack *int `help:"enable field tracking"`
|
||||
GCProg int `help:"print dump of GC programs"`
|
||||
InlFuncsWithClosures int `help:"allow functions with closures to be inlined"`
|
||||
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))
|
||||
case *int, *string:
|
||||
// ok
|
||||
case **int:
|
||||
ptr = *ptr.(**int) // record the *int itself
|
||||
}
|
||||
debugTab = append(debugTab, debugField{name, help, ptr})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ func concurrentBackendAllowed() bool {
|
|||
return false
|
||||
}
|
||||
// TODO: Test and delete this condition.
|
||||
if objabi.Fieldtrack_enabled != 0 {
|
||||
if objabi.Experiment.FieldTrack {
|
||||
return false
|
||||
}
|
||||
// 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 {
|
||||
offs -= int64(types.PtrSize)
|
||||
}
|
||||
if objabi.Framepointer_enabled {
|
||||
if objabi.FramePointerEnabled {
|
||||
offs -= int64(types.PtrSize)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func pragmaFlag(verb string) ir.PragmaFlag {
|
|||
case "go:build":
|
||||
return ir.GoBuildPragma
|
||||
case "go:nointerface":
|
||||
if objabi.Fieldtrack_enabled != 0 {
|
||||
if objabi.Experiment.FieldTrack {
|
||||
return ir.Nointerface
|
||||
}
|
||||
case "go:noescape":
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ var passes = [...]pass{
|
|||
{name: "dse", fn: dse},
|
||||
{name: "writebarrier", fn: writebarrier, required: true}, // expand write barrier ops
|
||||
{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: "addressing modes", fn: addressingModes, required: false},
|
||||
{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 {
|
||||
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)
|
||||
}
|
||||
if s.f.Config.LinkReg != -1 {
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ func StackOffset(slot ssa.LocalSlot) int32 {
|
|||
if base.Ctxt.FixedFrameSize() == 0 {
|
||||
off -= int64(types.PtrSize)
|
||||
}
|
||||
if objabi.Framepointer_enabled {
|
||||
if objabi.FramePointerEnabled {
|
||||
off -= int64(types.PtrSize)
|
||||
}
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ func fieldtrack(fnsym *obj.LSym, tracked map[*obj.LSym]struct{}) {
|
|||
if fnsym == nil {
|
||||
return
|
||||
}
|
||||
if objabi.Fieldtrack_enabled == 0 || len(tracked) == 0 {
|
||||
if !objabi.Experiment.FieldTrack || len(tracked) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -931,7 +931,7 @@ func usemethod(n *ir.CallExpr) {
|
|||
}
|
||||
|
||||
func usefield(n *ir.SelectorExpr) {
|
||||
if objabi.Fieldtrack_enabled == 0 {
|
||||
if !objabi.Experiment.FieldTrack {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ CheckFlags:
|
|||
}
|
||||
|
||||
// TODO: Test and delete these conditions.
|
||||
if objabi.Fieldtrack_enabled != 0 || objabi.Preemptibleloops_enabled != 0 {
|
||||
if objabi.Experiment.FieldTrack || objabi.Experiment.PreemptibleLoops {
|
||||
canDashC = false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -174,8 +174,14 @@ func init() {
|
|||
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.
|
||||
var Framepointer_enabled = GOARCH == "amd64" || GOARCH == "arm64"
|
||||
var FramePointerEnabled = GOARCH == "amd64" || GOARCH == "arm64"
|
||||
|
||||
func addexp(s string) {
|
||||
// Could do general integer parsing here, but the runtime.haveexperiment doesn't yet.
|
||||
|
|
@ -203,18 +209,14 @@ func addexp(s string) {
|
|||
os.Exit(2)
|
||||
}
|
||||
|
||||
var (
|
||||
Fieldtrack_enabled int
|
||||
Preemptibleloops_enabled int
|
||||
Staticlockranking_enabled int
|
||||
)
|
||||
|
||||
// Experiment contains flags for GOEXPERIMENTs.
|
||||
//
|
||||
// TODO(austin): Move the package-level experiment flags into this.
|
||||
var Experiment ExpFlags
|
||||
var Experiment = ExpFlags{}
|
||||
|
||||
type ExpFlags struct {
|
||||
FieldTrack bool
|
||||
PreemptibleLoops bool
|
||||
StaticLockRanking bool
|
||||
|
||||
// regabi is split into several sub-experiments that can be
|
||||
// enabled individually. GOEXPERIMENT=regabi implies the
|
||||
// subset that are currently "working". Not all combinations work.
|
||||
|
|
@ -250,9 +252,9 @@ var exper = []struct {
|
|||
name string
|
||||
val interface{} // Must be *int or *bool
|
||||
}{
|
||||
{"fieldtrack", &Fieldtrack_enabled},
|
||||
{"preemptibleloops", &Preemptibleloops_enabled},
|
||||
{"staticlockranking", &Staticlockranking_enabled},
|
||||
{"fieldtrack", &Experiment.FieldTrack},
|
||||
{"preemptibleloops", &Experiment.PreemptibleLoops},
|
||||
{"staticlockranking", &Experiment.StaticLockRanking},
|
||||
{"regabi", &Experiment.regabi},
|
||||
{"regabiwrappers", &Experiment.RegabiWrappers},
|
||||
{"regabig", &Experiment.RegabiG},
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ type deadcodePass struct {
|
|||
func (d *deadcodePass) init() {
|
||||
d.ldr.InitReachable()
|
||||
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.dynlink = d.ctxt.DynlinkingGo()
|
||||
|
|
@ -255,7 +255,7 @@ func (d *deadcodePass) mark(symIdx, parent loader.Sym) {
|
|||
if symIdx != 0 && !d.ldr.AttrReachable(symIdx) {
|
||||
d.wq.push(symIdx)
|
||||
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
|
||||
}
|
||||
if *flagDumpDep {
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ func Main(arch *sys.Arch, theArch Arch) {
|
|||
|
||||
bench.Start("dostrdata")
|
||||
ctxt.dostrdata()
|
||||
if objabi.Fieldtrack_enabled != 0 {
|
||||
if objabi.Experiment.FieldTrack {
|
||||
bench.Start("fieldtrack")
|
||||
fieldtrack(ctxt.Arch, ctxt.loader)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1105,5 +1105,5 @@ var (
|
|||
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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue