mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
internal/goexperiment,cmd: consolidate GOEXPERIMENTs into a new package
Currently there's knowledge about the list of GOEXPERIMENTs in a few different places. This CL introduces a new package and consolidates the list into one place: the internal/goexperiment.Flags struct type. This package gives us a central place to document the experiments as well as the GOEXPERIMENT environment variable itself. It will also give us a place to put built-time constants derived from the enabled experiments. Now the objabi package constructs experiment names by reflecting over this struct type rather than having a separate list of these names (this is similar to how the compiler handles command-line flags and debug options). We also expose a better-typed API to the toolchain for propagating enabled experiments. Change-Id: I06e026712b59fe2bd7cd11a869aedb48ffe5a4b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/307817 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
0c4a08cb74
commit
6304b401e4
7 changed files with 215 additions and 203 deletions
|
|
@ -46,31 +46,18 @@ func NewInput(name string) *Input {
|
|||
func predefine(defines flags.MultiFlag) map[string]*Macro {
|
||||
macros := make(map[string]*Macro)
|
||||
|
||||
// Set macros for various GOEXPERIMENTs so we can easily
|
||||
// switch runtime assembly code based on them.
|
||||
// Set macros for GOEXPERIMENTs so we can easily switch
|
||||
// runtime assembly code based on them.
|
||||
if *flags.CompilingRuntime {
|
||||
set := func(name string) {
|
||||
for _, exp := range objabi.EnabledExperiments() {
|
||||
// Define macro.
|
||||
name := "GOEXPERIMENT_" + exp
|
||||
macros[name] = &Macro{
|
||||
name: name,
|
||||
args: nil,
|
||||
tokens: Tokenize("1"),
|
||||
}
|
||||
}
|
||||
if objabi.Experiment.RegabiWrappers {
|
||||
set("GOEXPERIMENT_regabiwrappers")
|
||||
}
|
||||
if objabi.Experiment.RegabiG {
|
||||
set("GOEXPERIMENT_regabig")
|
||||
}
|
||||
if objabi.Experiment.RegabiReflect {
|
||||
set("GOEXPERIMENT_regabireflect")
|
||||
}
|
||||
if objabi.Experiment.RegabiDefer {
|
||||
set("GOEXPERIMENT_regabidefer")
|
||||
}
|
||||
if objabi.Experiment.RegabiArgs {
|
||||
set("GOEXPERIMENT_regabiargs")
|
||||
}
|
||||
}
|
||||
|
||||
for _, name := range defines {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue