]> Cypherpunks.ru repositories - gostls13.git/commit
gc: implement == on structs and arrays
authorRuss Cox <rsc@golang.org>
Tue, 13 Dec 2011 03:22:09 +0000 (22:22 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 13 Dec 2011 03:22:09 +0000 (22:22 -0500)
commit196b6630759c6f4125c22445dd5b6cfec5faf34b
tree43ae44cf228030c8358410af212994bca7f74e7f
parent83f648c9625343045da1e6b4ecc3d207c84403b3
gc: implement == on structs and arrays

To allow these types as map keys, we must fill in
equal and hash functions in their algorithm tables.
Structs or arrays that are "just memory", like [2]int,
can and do continue to use the AMEM algorithm.
Structs or arrays that contain special values like
strings or interface values use generated functions
for both equal and hash.

The runtime helper func runtime.equal(t, x, y) bool handles
the general equality case for x == y and calls out to
the equal implementation in the algorithm table.

For short values (<= 4 struct fields or array elements),
the sequence of elementwise comparisons is inlined
instead of calling runtime.equal.

R=ken, mpimenov
CC=golang-dev
https://golang.org/cl/5451105
24 files changed:
src/cmd/5g/gg.h
src/cmd/5l/obj.c
src/cmd/6g/gg.h
src/cmd/6l/obj.c
src/cmd/8g/gg.h
src/cmd/8l/obj.c
src/cmd/gc/align.c
src/cmd/gc/builtin.c.boot
src/cmd/gc/go.h
src/cmd/gc/pgen.c
src/cmd/gc/reflect.c
src/cmd/gc/runtime.go
src/cmd/gc/subr.c
src/cmd/gc/typecheck.c
src/cmd/gc/walk.c
src/cmd/ld/dwarf.c
src/pkg/runtime/alg.c
src/pkg/runtime/hashmap.h
src/pkg/runtime/runtime.h
test/cmp.go
test/cmp6.go
test/interface/noeq.go
test/map1.go
test/recover2.go