mirror of
https://github.com/golang/go
synced 2024-11-18 12:04:57 -07:00
cmd/compile: fix type of static closure pointer
var x *X = ... defer x.foo() As part of the defer, we need to calculate &(*X).foo·f. This expression is the address of the static closure that will call (*X).foo when a pointer to that closure is used in a call/defer/go. This pointer is not currently properly typed in SSA. It is a pointer type, but the base type is nil, not a proper type. This turns out not to be a problem currently because we never use the type of these SSA values. But I'm trying to change that (to be able to spill them) in CL 28391. To fix, use uint8 as the fake type of the closure. Change-Id: Ieee388089c9af398ed772ee8c815122c347cb633 Reviewed-on: https://go-review.googlesource.com/29444 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
d586aae1f4
commit
88d2f9112a
@ -2788,9 +2788,15 @@ func (s *state) call(n *Node, k callKind) *ssa.Value {
|
||||
sym = fn.Sym
|
||||
break
|
||||
}
|
||||
// Make a name n2 for the function.
|
||||
// fn.Sym might be sync.(*Mutex).Unlock.
|
||||
// Make a PFUNC node out of that, then evaluate it.
|
||||
// We get back an SSA value representing &sync.(*Mutex).Unlock·f.
|
||||
// We can then pass that to defer or go.
|
||||
n2 := newname(fn.Sym)
|
||||
n2.Class = PFUNC
|
||||
n2.Lineno = fn.Lineno
|
||||
n2.Type = Types[TUINT8] // dummy type for a static closure. Could use runtime.funcval if we had it.
|
||||
closure = s.expr(n2)
|
||||
// Note: receiver is already assigned in n.List, so we don't
|
||||
// want to set it here.
|
||||
|
@ -1141,6 +1141,9 @@ func ptrto(t *Type) *Type {
|
||||
if Tptr == 0 {
|
||||
Fatalf("ptrto: no tptr")
|
||||
}
|
||||
if t == nil {
|
||||
Fatalf("ptrto: nil ptr")
|
||||
}
|
||||
// Reduce allocations by pre-creating common cases.
|
||||
if !initPtrtoDone {
|
||||
initPtrto()
|
||||
|
Loading…
Reference in New Issue
Block a user