aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types/type.go
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2021-02-09 15:14:43 -0500
committerDavid Chase <drchase@google.com>2021-03-03 01:45:33 +0000
commit77973863c351b162d68723439fc56fb054e917b2 (patch)
tree690743127dd11a65f9487824a8e4dc8d72f658a5 /src/cmd/compile/internal/types/type.go
parentaea1259a7288d71736273b494e60bd424ea1946c (diff)
downloadgo-77973863c351b162d68723439fc56fb054e917b2.tar.gz
go-77973863c351b162d68723439fc56fb054e917b2.zip
cmd/compile: use abiutils for all rcvr/in/out frame offsets.
types thought it knew how to do this, but that's a lie, because types doesn't know what the ABI is. includes extra checking to help prevent things from accidentally working if they need to be changed but aren't. For #40724. Change-Id: I166cd948f262344b7bebde6a2c25e7a7f878bbfb Reviewed-on: https://go-review.googlesource.com/c/go/+/293393 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>
Diffstat (limited to 'src/cmd/compile/internal/types/type.go')
-rw-r--r--src/cmd/compile/internal/types/type.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go
index 9fb6d68994..b0516a8259 100644
--- a/src/cmd/compile/internal/types/type.go
+++ b/src/cmd/compile/internal/types/type.go
@@ -411,7 +411,8 @@ type Field struct {
Nname Object
// Offset in bytes of this field or method within its enclosing struct
- // or interface Type.
+ // or interface Type. Exception: if field is function receiver, arg or
+ // result, then this is BOGUS_FUNARG_OFFSET; types does not know the Abi.
Offset int64
}
@@ -1719,6 +1720,14 @@ func NewTypeParam(pkg *Pkg, constraint *Type) *Type {
return t
}
+const BOGUS_FUNARG_OFFSET = 1000000000
+
+func unzeroFieldOffsets(f []*Field) {
+ for i := range f {
+ f[i].Offset = BOGUS_FUNARG_OFFSET // This will cause an explosion if it is not corrected
+ }
+}
+
// NewSignature returns a new function type for the given receiver,
// parametes, results, and type parameters, any of which may be nil.
func NewSignature(pkg *Pkg, recv *Field, tparams, params, results []*Field) *Type {
@@ -1739,6 +1748,11 @@ func NewSignature(pkg *Pkg, recv *Field, tparams, params, results []*Field) *Typ
return s
}
+ if recv != nil {
+ recv.Offset = BOGUS_FUNARG_OFFSET
+ }
+ unzeroFieldOffsets(params)
+ unzeroFieldOffsets(results)
ft.Receiver = funargs(recvs, FunargRcvr)
ft.TParams = funargs(tparams, FunargTparams)
ft.Params = funargs(params, FunargParams)