aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/hashmap.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2015-11-02 10:46:58 -0800
committerMatthew Dempsky <mdempsky@google.com>2016-02-22 07:42:37 +0000
commitf28bbb776a050cc3edca2bbe1241d81217a7a251 (patch)
treed2dc7187d70b576b72753042a5b62e88597e3148 /src/runtime/hashmap.go
parentd0c11577b9c6d584959aceddf97266b9cbc336d0 (diff)
downloadgo-f28bbb776a050cc3edca2bbe1241d81217a7a251.tar.xz
cmd/compile: move hiter, hmap, and scase definitions into builtin.go
Also eliminates per-maptype hiter and hmap types, since they're not really needed anyway. Update packages reflect and runtime accordingly. Reduces golang.org/x/tools/cmd/godoc's text segment by ~170kB: text data bss dec hex filename 13085702 140640 151520 13377862 cc2146 godoc.before 12915382 140640 151520 13207542 c987f6 godoc.after Updates #6853. Change-Id: I948b2bc1f22d477c1756204996b4e3e1fb568d81 Reviewed-on: https://go-review.googlesource.com/16610 Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/hashmap.go')
-rw-r--r--src/runtime/hashmap.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go
index 892a79a914..fcfcd4b607 100644
--- a/src/runtime/hashmap.go
+++ b/src/runtime/hashmap.go
@@ -102,6 +102,7 @@ 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!
@@ -137,11 +138,10 @@ type bmap struct {
}
// A hash iteration structure.
-// If you modify hiter, also change cmd/internal/gc/reflect.go to indicate
-// the layout of this structure.
+// Changes here must also be made in src/cmd/compile/internal/gc/builtin/runtime.go.
type hiter struct {
- 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).
+ key unsafe.Pointer // Write nil to indicate iteration end (see cmd/compile/internal/gc/range.go).
+ value unsafe.Pointer
t *maptype
h *hmap
buckets unsafe.Pointer // bucket ptr at hash_iter initialization time
@@ -188,11 +188,10 @@ 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 || sz != uintptr(t.hmap.size) {
- println("runtime: sizeof(hmap) =", sz, ", t.hmap.size =", t.hmap.size)
+ if sz := unsafe.Sizeof(hmap{}); sz > 48 {
+ println("runtime: sizeof(hmap) =", sz)
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
@@ -254,7 +253,7 @@ func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer) *hmap {
// initialize Hmap
if h == nil {
- h = (*hmap)(newobject(t.hmap))
+ h = &hmap{}
}
h.count = 0
h.B = B