mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Revert "cmd/compile: move hiter, hmap, and scase definitions into builtin.go"
This reverts commit f28bbb776a.
Change-Id: I82fb81dcff3ddcaefef72949f1ef3a41bcd22301
Reviewed-on: https://go-review.googlesource.com/19849
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
676550d040
commit
9877900c8c
14 changed files with 163 additions and 94 deletions
|
|
@ -102,7 +102,6 @@ const (
|
|||
)
|
||||
|
||||
// A header for a Go map.
|
||||
// Changes here must also be made in src/cmd/compile/internal/gc/builtin/runtime.go.
|
||||
type hmap struct {
|
||||
// Note: the format of the Hmap is encoded in ../../cmd/internal/gc/reflect.go and
|
||||
// ../reflect/type.go. Don't change this structure without also changing that code!
|
||||
|
|
@ -138,10 +137,11 @@ type bmap struct {
|
|||
}
|
||||
|
||||
// A hash iteration structure.
|
||||
// Changes here must also be made in src/cmd/compile/internal/gc/builtin/runtime.go.
|
||||
// If you modify hiter, also change cmd/internal/gc/reflect.go to indicate
|
||||
// the layout of this structure.
|
||||
type hiter struct {
|
||||
key unsafe.Pointer // Write nil to indicate iteration end (see cmd/compile/internal/gc/range.go).
|
||||
value unsafe.Pointer
|
||||
key unsafe.Pointer // Must be in first position. Write nil to indicate iteration end (see cmd/internal/gc/range.go).
|
||||
value unsafe.Pointer // Must be in second position (see cmd/internal/gc/range.go).
|
||||
t *maptype
|
||||
h *hmap
|
||||
buckets unsafe.Pointer // bucket ptr at hash_iter initialization time
|
||||
|
|
@ -188,10 +188,11 @@ func (h *hmap) createOverflow() {
|
|||
// If h != nil, the map can be created directly in h.
|
||||
// If bucket != nil, bucket can be used as the first bucket.
|
||||
func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer) *hmap {
|
||||
if sz := unsafe.Sizeof(hmap{}); sz > 48 {
|
||||
println("runtime: sizeof(hmap) =", sz)
|
||||
if sz := unsafe.Sizeof(hmap{}); sz > 48 || sz != uintptr(t.hmap.size) {
|
||||
println("runtime: sizeof(hmap) =", sz, ", t.hmap.size =", t.hmap.size)
|
||||
throw("bad hmap size")
|
||||
}
|
||||
|
||||
if hint < 0 || int64(int32(hint)) != hint {
|
||||
panic("makemap: size out of range")
|
||||
// TODO: make hint an int, then none of this nonsense
|
||||
|
|
@ -253,7 +254,7 @@ func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer) *hmap {
|
|||
|
||||
// initialize Hmap
|
||||
if h == nil {
|
||||
h = &hmap{}
|
||||
h = (*hmap)(newobject(t.hmap))
|
||||
}
|
||||
h.count = 0
|
||||
h.B = B
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue