]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: set unsayable "names" for regabi testing triggers
authorDavid Chase <drchase@google.com>
Wed, 10 Mar 2021 01:43:49 +0000 (20:43 -0500)
committerDavid Chase <drchase@google.com>
Thu, 6 May 2021 11:58:39 +0000 (11:58 +0000)
This disables the "testing names" for method names and
trailing input types passed to closure/interface/other calls.
The logic using the names remains, so that editing the change
to enable local testing is not too hard.

Also fixes broken build tag in reflect/abi_test.go

Updates #44816.

Change-Id: I3d222d2473c98d04ab6f1122ede9fea70c994af1
Reviewed-on: https://go-review.googlesource.com/c/go/+/300150
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssagen/ssa.go
src/reflect/abi_test.go
test/abi/fibish2.go [deleted file]
test/abi/fibish2.out [deleted file]
test/abi/methods.go [deleted file]
test/abi/methods.out [deleted file]

index c65e738188f5105db83d2139b1d57f32a2dd05ed..75973c46a62f2b15cf22b75cc25063708ff2fcb8 100644 (file)
@@ -223,9 +223,10 @@ func AbiForBodylessFuncStackMap(fn *ir.Func) *abi.ABIConfig {
        return ssaConfig.ABI0.Copy() // No idea what races will result, be safe
 }
 
-// TODO (NLT 2021-04-15) This must be changed to a name that cannot match; it may be helpful to other register ABI work to keep the trigger-logic
-const magicNameDotSuffix = ".MagicMethodNameForTestingRegisterABI"
-const magicLastTypeName = "MagicLastTypeNameForTestingRegisterABI"
+// These are disabled but remain ready for use in case they are needed for the next regabi port.
+// TODO if they are not needed for 1.18 / next register abi port, delete them.
+const magicNameDotSuffix = ".*disabled*MagicMethodNameForTestingRegisterABI"
+const magicLastTypeName = "*disabled*MagicLastTypeNameForTestingRegisterABI"
 
 // abiForFunc implements ABI policy for a function, but does not return a copy of the ABI.
 // Passing a nil function returns the default ABI based on experiment configuration.
index 224143c9bfcd8be1239603c06e75584f14098771..1a2a48b5ed92d876af7a657965a8c5d867a732f0 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build goexperiment.regabi
-//go:build goexperiment.regabi
+//go:build goexperiment.regabireflect
+// +build goexperiment.regabireflect
 
 package reflect_test
 
@@ -16,6 +16,9 @@ import (
        "testing/quick"
 )
 
+// As of early May 2021 this is no longer necessary for amd64,
+// but it remains in case this is needed for the next register abi port.
+// TODO (1.18) If enabling register ABI on additional architectures turns out not to need this, remove it.
 type MagicLastTypeNameForTestingRegisterABI struct{}
 
 func TestMethodValueCallABI(t *testing.T) {
diff --git a/test/abi/fibish2.go b/test/abi/fibish2.go
deleted file mode 100644 (file)
index 388aabc..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// run
-
-//go:build !wasm
-// +build !wasm
-
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import "fmt"
-
-// Test that register results are correctly returned (and passed)
-
-type MagicLastTypeNameForTestingRegisterABI func(int, MagicLastTypeNameForTestingRegisterABI) int
-
-//go:registerparams
-//go:noinline
-func minus(decrement int) MagicLastTypeNameForTestingRegisterABI {
-       return MagicLastTypeNameForTestingRegisterABI(func(x int, _ MagicLastTypeNameForTestingRegisterABI) int { return x - decrement })
-}
-
-//go:noinline
-func f(x int, sub1 MagicLastTypeNameForTestingRegisterABI) (int, int) {
-
-       if x < 3 {
-               return 0, x
-       }
-
-       a, b := f(sub1(sub1(x, sub1), sub1), sub1)
-       c, d := f(sub1(x, sub1), sub1)
-       return a + d, b + c
-}
-
-func main() {
-       x := 40
-       a, b := f(x, minus(1))
-       fmt.Printf("f(%d)=%d,%d\n", x, a, b)
-}
diff --git a/test/abi/fibish2.out b/test/abi/fibish2.out
deleted file mode 100644 (file)
index 9bd80c3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-f(40)=39088169,126491972
diff --git a/test/abi/methods.go b/test/abi/methods.go
deleted file mode 100644 (file)
index 3dcd3e3..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-// run
-
-//go:build !wasm
-// +build !wasm
-
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
-       "fmt"
-)
-
-type toobig struct {
-       a, b, c string
-}
-
-//go:registerparams
-//go:noinline
-func (x *toobig) MagicMethodNameForTestingRegisterABI(y toobig, z toobig) toobig {
-       return toobig{x.a, y.b, z.c}
-}
-
-type AnInterface interface {
-       MagicMethodNameForTestingRegisterABI(y toobig, z toobig) toobig
-}
-
-//go:registerparams
-//go:noinline
-func I(a, b, c string) toobig {
-       return toobig{a, b, c}
-}
-
-// AnIid prevents the compiler from figuring out what the interface really is.
-//go:noinline
-func AnIid(x AnInterface) AnInterface {
-       return x
-}
-
-var tmp toobig
-
-func main() {
-       x := I("Ahoy", "1,", "2")
-       y := I("3", "there,", "4")
-       z := I("5", "6,", "Matey")
-       tmp = x.MagicMethodNameForTestingRegisterABI(y, z)
-       fmt.Println(tmp.a, tmp.b, tmp.c)
-       tmp = AnIid(&x).MagicMethodNameForTestingRegisterABI(y, z)
-       fmt.Println(tmp.a, tmp.b, tmp.c)
-}
diff --git a/test/abi/methods.out b/test/abi/methods.out
deleted file mode 100644 (file)
index 5a72b0e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Ahoy there, Matey
-Ahoy there, Matey