]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: move evacuateX evacuateY relation check from makemap to evacuate
authorMartin Möhrmann <moehrmann@google.com>
Fri, 8 Sep 2017 21:05:19 +0000 (23:05 +0200)
committerMartin Möhrmann <moehrmann@google.com>
Wed, 13 Sep 2017 06:13:27 +0000 (06:13 +0000)
Move the check near the code in evacuate that relies on
the relation evacuateX+1 == evacuateY.

If the relation is fullfilled the check is known to be true
at compile time and removed by the compiler.

Change-Id: I711b75e09047bf347819ccaeec41d244a5883867
Reviewed-on: https://go-review.googlesource.com/62410
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/hashmap.go

index 1e76fc590c1096edea40e8859bbb85979ba36b9c..4f47838cd420d6abb60801df243f4cda0469e589 100644 (file)
@@ -296,11 +296,6 @@ func makemap(t *maptype, hint int, h *hmap) *hmap {
                hint = 0
        }
 
-       if evacuatedX+1 != evacuatedY {
-               // evacuate relies on this relationship
-               throw("bad evacuatedN")
-       }
-
        // initialize Hmap
        if h == nil {
                h = (*hmap)(newobject(t.hmap))
@@ -1061,7 +1056,11 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) {
                                        }
                                }
 
-                               b.tophash[i] = evacuatedX + useY // evacuatedX + 1 == evacuatedY, enforced in makemap
+                               if evacuatedX+1 != evacuatedY {
+                                       throw("bad evacuatedN")
+                               }
+
+                               b.tophash[i] = evacuatedX + useY // evacuatedX + 1 == evacuatedY
                                dst := &xy[useY]                 // evacuation destination
 
                                if dst.i == bucketCnt {