return ssaConfig.ABI0.Copy() // No idea what races will result, be safe
}
-// 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.
func abiForFunc(fn *ir.Func, abi0, abi1 *abi.ABIConfig) *abi.ABIConfig {
a := abi0
if fn != nil {
- name := ir.FuncName(fn)
- magicName := strings.HasSuffix(name, magicNameDotSuffix)
if fn.Pragma&ir.RegisterParams != 0 { // TODO(register args) remove after register abi is working
- if strings.Contains(name, ".") {
- if !magicName {
- base.ErrorfAt(fn.Pos(), "Calls to //go:registerparams method %s won't work, remove the pragma from the declaration.", name)
- }
- }
- a = abi1
- } else if magicName {
- if base.FmtPos(fn.Pos()) == "<autogenerated>:1" {
- // no way to put a pragma here, and it will error out in the real source code if they did not do it there.
- a = abi1
- } else {
- base.ErrorfAt(fn.Pos(), "Methods with magic name %s (method %s) must also specify //go:registerparams", magicNameDotSuffix[1:], name)
- }
- }
- if regAbiForFuncType(fn.Type().FuncType()) {
- // fmt.Printf("Saw magic last type name for function %s\n", name)
a = abi1
}
}
return a
}
-func regAbiForFuncType(ft *types.Func) bool {
- np := ft.Params.NumFields()
- return np > 0 && strings.Contains(ft.Params.FieldType(np-1).String(), magicLastTypeName)
-}
-
// dvarint writes a varint v to the funcdata in symbol x and returns the new offset
func dvarint(x *obj.LSym, off int, v int64) int {
if v < 0 || v > 1e9 {
callABI := s.f.ABIDefault
- if !buildcfg.Experiment.RegabiArgs {
- var magicFnNameSym *types.Sym
- if fn.Name() != nil {
- magicFnNameSym = fn.Name().Sym()
- ss := magicFnNameSym.Name
- if strings.HasSuffix(ss, magicNameDotSuffix) {
- callABI = s.f.ABI1
- }
- }
- if magicFnNameSym == nil && n.Op() == ir.OCALLINTER {
- magicFnNameSym = fn.(*ir.SelectorExpr).Sym()
- ss := magicFnNameSym.Name
- if strings.HasSuffix(ss, magicNameDotSuffix[1:]) {
- callABI = s.f.ABI1
- }
- }
- }
-
if k != callNormal && k != callTail && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) {
s.Fatalf("go/defer call with arguments: %v", n)
}
}
}
- if !buildcfg.Experiment.RegabiArgs {
- if regAbiForFuncType(n.X.Type().FuncType()) {
- // Magic last type in input args to call
- callABI = s.f.ABI1
- }
- }
-
params := callABI.ABIAnalyze(n.X.Type(), false /* Do not set (register) nNames from caller side -- can cause races. */)
types.CalcSize(fn.Type())
stksize := params.ArgWidth() // includes receiver, args, and results