mirror of
https://github.com/golang/go
synced 2024-11-26 07:27:59 -07:00
cmd/compile: eagerly CalcStructSize for synthetic ABI types
The next CL is going to replace Type.Width with Type.Size(), but Type.Size() isn't safe to call concurrently. So this CL calls CalcStructSize, which *is* allowed to be used concurrently, but then it's the caller's responsibility to ensure it's called right after NewStruct. Change-Id: If9cd81650ccb3a867b4449af757375fa56227901 Reviewed-on: https://go-review.googlesource.com/c/go/+/345483 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
d7e2e2ec2b
commit
d350a66532
@ -722,14 +722,17 @@ func setup() {
|
|||||||
types.NewField(nxp, fname("len"), ui),
|
types.NewField(nxp, fname("len"), ui),
|
||||||
types.NewField(nxp, fname("cap"), ui),
|
types.NewField(nxp, fname("cap"), ui),
|
||||||
})
|
})
|
||||||
|
types.CalcStructSize(synthSlice)
|
||||||
synthString = types.NewStruct(types.NoPkg, []*types.Field{
|
synthString = types.NewStruct(types.NoPkg, []*types.Field{
|
||||||
types.NewField(nxp, fname("data"), unsp),
|
types.NewField(nxp, fname("data"), unsp),
|
||||||
types.NewField(nxp, fname("len"), ui),
|
types.NewField(nxp, fname("len"), ui),
|
||||||
})
|
})
|
||||||
|
types.CalcStructSize(synthString)
|
||||||
synthIface = types.NewStruct(types.NoPkg, []*types.Field{
|
synthIface = types.NewStruct(types.NoPkg, []*types.Field{
|
||||||
types.NewField(nxp, fname("f1"), unsp),
|
types.NewField(nxp, fname("f1"), unsp),
|
||||||
types.NewField(nxp, fname("f2"), unsp),
|
types.NewField(nxp, fname("f2"), unsp),
|
||||||
})
|
})
|
||||||
|
types.CalcStructSize(synthIface)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user