1
0
mirror of https://github.com/golang/go synced 2024-11-26 05:07: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:
Matthew Dempsky 2021-08-26 16:57:06 -07:00
parent d7e2e2ec2b
commit d350a66532

View File

@ -722,14 +722,17 @@ func setup() {
types.NewField(nxp, fname("len"), ui),
types.NewField(nxp, fname("cap"), ui),
})
types.CalcStructSize(synthSlice)
synthString = types.NewStruct(types.NoPkg, []*types.Field{
types.NewField(nxp, fname("data"), unsp),
types.NewField(nxp, fname("len"), ui),
})
types.CalcStructSize(synthString)
synthIface = types.NewStruct(types.NoPkg, []*types.Field{
types.NewField(nxp, fname("f1"), unsp),
types.NewField(nxp, fname("f2"), unsp),
})
types.CalcStructSize(synthIface)
})
}