compiler, runtime: remove hmap field from maptypes
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 29 Aug 2018 00:20:25 +0000 (00:20 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 29 Aug 2018 00:20:25 +0000 (00:20 +0000)
    This is the gofrontend version of https://golang.org/cl/91796.

    This is part of that CL, just the compiler change and required runtime
    changes, in preparation for updating libgo to 1.11.

    Relevant part of original CL description:

        The hmap field in the maptype is only used by the runtime to check the sizes of
        the hmap structure created by the compiler and runtime agree.

        Comments are already present about the hmap structure definitions in the
        compiler and runtime needing to be in sync.

    Reviewed-on: https://go-review.googlesource.com/130976

From-SVN: r263941

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/types.cc
libgo/go/reflect/type.go
libgo/go/runtime/hashmap.go
libgo/go/runtime/type.go

index 8fc3878e3a2c03f72f47c9a6e78144cd671615dd..9495882b5da262c3b48c7f953ff0e22ac0c9b00f 100644 (file)
@@ -1,4 +1,4 @@
-8deaafd14414bb5cbbdf3e2673f61b6d836d7d2a
+da249ffd264154cc992e76ff03f91f700d3bf53e
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 2fb67064471ecb70ea84c0c93eb3f957680c3f7f..00098dabef81ae9ae786f89b35f0d61b9b582dac 100644 (file)
@@ -7975,12 +7975,11 @@ Map_type::make_map_type_descriptor_type()
       Type* bool_type = Type::lookup_bool_type();
 
       Struct_type* sf =
-       Type::make_builtin_struct_type(12,
+       Type::make_builtin_struct_type(11,
                                       "", tdt,
                                       "key", ptdt,
                                       "elem", ptdt,
                                       "bucket", ptdt,
-                                      "hmap", ptdt,
                                       "keysize", uint8_type,
                                       "indirectkey", bool_type,
                                       "valuesize", uint8_type,
@@ -8064,11 +8063,6 @@ Map_type::do_type_descriptor(Gogo* gogo, Named_type* name)
   go_assert(p->is_field_name("bucket"));
   vals->push_back(Expression::make_type_descriptor(bucket_type, bloc));
 
-  ++p;
-  go_assert(p->is_field_name("hmap"));
-  Type* hmap_type = this->hmap_type(bucket_type);
-  vals->push_back(Expression::make_type_descriptor(hmap_type, bloc));
-
   ++p;
   go_assert(p->is_field_name("keysize"));
   if (keysize > Map_type::max_key_size)
index 07fe4d001c0e5a1a32c0ab083927fbb1a53eb567..bbbef9107c2b25971ccd6078d45e0da983c8e52d 100644 (file)
@@ -351,7 +351,6 @@ type mapType struct {
        key           *rtype // map key type
        elem          *rtype // map element (value) type
        bucket        *rtype // internal bucket structure
-       hmap          *rtype // internal map header
        keysize       uint8  // size of key slot
        indirectkey   uint8  // store ptr to key instead of key itself
        valuesize     uint8  // size of value slot
index aba9abd7aab7d1983710ab07e0b44b692f382e2c..53b05b1ef7705d3623e65ee2f2fd0195ade329a6 100644 (file)
@@ -311,20 +311,13 @@ func makemap_small() *hmap {
 // If h != nil, the map can be created directly in h.
 // If h.buckets != nil, bucket pointed to can be used as the first bucket.
 func makemap(t *maptype, hint int, h *hmap) *hmap {
-       // The size of hmap should be 48 bytes on 64 bit
-       // and 28 bytes on 32 bit platforms.
-       if sz := unsafe.Sizeof(hmap{}); sz != 8+5*sys.PtrSize {
-               println("runtime: sizeof(hmap) =", sz, ", t.hmap.size =", t.hmap.size)
-               throw("bad hmap size")
-       }
-
        if hint < 0 || hint > int(maxSliceCap(t.bucket.size)) {
                hint = 0
        }
 
        // initialize Hmap
        if h == nil {
-               h = (*hmap)(newobject(t.hmap))
+               h = new(hmap)
        }
        h.hash0 = fastrand()
 
@@ -1210,11 +1203,6 @@ func ismapkey(t *_type) bool {
 
 //go:linkname reflect_makemap reflect.makemap
 func reflect_makemap(t *maptype, cap int) *hmap {
-       // Check invariants and reflects math.
-       if sz := unsafe.Sizeof(hmap{}); sz != t.hmap.size {
-               println("runtime: sizeof(hmap) =", sz, ", t.hmap.size =", t.hmap.size)
-               throw("bad hmap size")
-       }
        if !ismapkey(t.key) {
                throw("runtime.reflect_makemap: unsupported map key type")
        }
index 0ec0da411797189c443ec6f10afd47f97df06aeb..3c08f7e1b9db4a4b9a694ff50ce30ca6aed667b0 100644 (file)
@@ -72,7 +72,6 @@ type maptype struct {
        key           *_type
        elem          *_type
        bucket        *_type // internal type representing a hash bucket
-       hmap          *_type // internal type representing a hmap
        keysize       uint8  // size of key slot
        indirectkey   bool   // store ptr to key instead of key itself
        valuesize     uint8  // size of value slot