mirror of
https://github.com/golang/go
synced 2024-11-26 05:48:05 -07:00
cmd/compile: set unsayable "names" for regabi testing triggers
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>
This commit is contained in:
parent
1108cbe60b
commit
b4ca1cec69
@ -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.
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
}
|
@ -1 +0,0 @@
|
||||
f(40)=39088169,126491972
|
@ -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)
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
Ahoy there, Matey
|
||||
Ahoy there, Matey
|
Loading…
Reference in New Issue
Block a user