runtime: move constants from map header to map type
A good cleanup anyway, and it makes some room for an additional
field needed for issue 8412.
Update issue 8412
On Fri, Aug 1, 2014 at 6:50 AM, <iant@golang.org> wrote: > > https://codereview.appspot.com/112700043/diff/60001/src/cmd/gc/reflect.c > File ...
10 years, 9 months ago
(2014-08-01 20:39:24 UTC)
#3
On Fri, Aug 1, 2014 at 6:50 AM, <iant@golang.org> wrote:
>
> https://codereview.appspot.com/112700043/diff/60001/src/cmd/gc/reflect.c
> File src/cmd/gc/reflect.c (right):
>
> https://codereview.appspot.com/112700043/diff/60001/src/
> cmd/gc/reflect.c#newcode1116
> src/cmd/gc/reflect.c:1116: ot = duint16(s, ot, mapbucket(t)->width);
> Why bother with this field? It's already available via the bucket type
> field.
>
>
It's one less indirection to get to it. Due to the magic of alignment it
doesn't use any space (at least on 64-bit platforms).
> https://codereview.appspot.com/112700043/diff/60001/src/
> pkg/reflect/type.go
> File src/pkg/reflect/type.go (right):
>
> https://codereview.appspot.com/112700043/diff/60001/src/
> pkg/reflect/type.go#newcode332
> src/pkg/reflect/type.go:332: indirectkey uint8 // store ptr to key
> instead of key itself
> Seems to me that indirectkey and indirectvalue should be type bool.
>
>
In an ideal world, yes. Unfortunately, these fields are defined in C where
bool is just a typedef of uint8 so the C->Go struct converter can't tell
the difference. So right now the Go generated structure (in
zruntime_defs_*.go) uses uint8s. I wanted the reflect type to match that
type. Although I guess it's not strictly necessary.
I hope to one day soon start having the truth about runtime structures
defined in Go and autotranslated back to C. At that point we can fix this.
> https://codereview.appspot.com/112700043/
>
Issue 112700043: code review 112700043: runtime: move constants from map header to map type
(Closed)
Created 10 years, 9 months ago by khr
Modified 10 years, 9 months ago
Reviewers: gobot
Base URL:
Comments: 2