aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2020-01-02 21:55:32 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2020-01-02 21:55:32 +0000
commit10172a64cedd95b302a9709429a4832a879667da (patch)
tree736b88eb69baa715a8ac1dbfb4b059eece8a049f /libgo/runtime
parent9279b5ba4538da8041f074db3f5fcd9e8ecff93e (diff)
downloadgcc-10172a64cedd95b302a9709429a4832a879667da.zip
gcc-10172a64cedd95b302a9709429a4832a879667da.tar.gz
gcc-10172a64cedd95b302a9709429a4832a879667da.tar.bz2
compiler, runtime, reflect: generate hash functions only for map keys
Right now we generate hash functions for all types, just in case they are used as map keys. That's a lot of wasted effort and binary size for types which will never be used as a map key. Instead, generate hash functions only for types that we know are map keys. Just doing that is a bit too simple, since maps with an interface type as a key might have to hash any concrete key type that implements that interface. So for that case, implement hashing of such types at runtime (instead of with generated code). It will be slower, but only for maps with interface types as keys, and maybe only a bit slower as the aeshash time probably dominates the dispatch time. Reorg where we keep the equals and hash functions. Move the hash function from the key type to the map type, saving a field in every non-map type. That leaves only one function in the alg structure, so get rid of that and just keep the equal function in the type descriptor itself. While we're here, reorganize the rtype struct to more closely match the gc version. This is the gofrontend version of https://golang.org/cl/191198. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/212843 From-SVN: r279848
Diffstat (limited to 'libgo/runtime')
-rw-r--r--libgo/runtime/go-unsafe-pointer.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/libgo/runtime/go-unsafe-pointer.c b/libgo/runtime/go-unsafe-pointer.c
index d987aca..364878e 100644
--- a/libgo/runtime/go-unsafe-pointer.c
+++ b/libgo/runtime/go-unsafe-pointer.c
@@ -36,8 +36,6 @@ static const String reflection_string =
const byte unsafe_Pointer_gc[] = { 1 };
-extern const FuncVal runtime_pointerhash_descriptor
- __asm__ (GOSYM_PREFIX "runtime.pointerhash..f");
extern const FuncVal runtime_pointerequal_descriptor
__asm__ (GOSYM_PREFIX "runtime.pointerequal..f");
@@ -49,17 +47,15 @@ const struct _type unsafe_Pointer =
sizeof (void *),
/* hash */
78501163U,
- /* kind */
- kindUnsafePointer | kindDirectIface,
+ /* tflag */
+ tflagRegularMemory,
/* align */
__alignof (void *),
/* fieldAlign */
offsetof (struct field_align, p) - 1,
- /* _ */
- 0,
- /* hashfn */
- &runtime_pointerhash_descriptor,
- /* equalfn */
+ /* kind */
+ kindUnsafePointer | kindDirectIface,
+ /* equal */
&runtime_pointerequal_descriptor,
/* gcdata */
unsafe_Pointer_gc,
@@ -101,16 +97,14 @@ const struct ptrtype pointer_unsafe_Pointer =
sizeof (void *),
/* hash */
1256018616U,
- /* kind */
- kindPtr | kindDirectIface,
+ /* tflag */
+ tflagRegularMemory,
/* align */
__alignof (void *),
/* fieldAlign */
offsetof (struct field_align, p) - 1,
- /* _ */
- 0,
- /*_hashfn */
- &runtime_pointerhash_descriptor,
+ /* kind */
+ kindPtr | kindDirectIface,
/* equalfn */
&runtime_pointerequal_descriptor,
/* gcdata */