aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-05-20 14:57:55 -0700
committerRuss Cox <rsc@golang.org>2009-05-20 14:57:55 -0700
commit2da5022bcf578545207ecc0ed0a8c7669e7f708f (patch)
tree262689682751a1adebce9c4281e1ab77eb480cb4 /src/runtime/runtime.c
parent47e5152790e6dab326237259e4898da22917342a (diff)
downloadgo-2da5022bcf578545207ecc0ed0a8c7669e7f708f.tar.xz
change representation of interface values.
this is not a user-visible change. before, all interface values were struct Itype { Sigt *type; Sigi *inter; void *method[n]; } struct Iface { void *addr; Itype *itype; } the itype is basically a vtable, but it's unnecessary if the static type is interface{ }. for interface values with static type empty, the new representation is struct Eface { void *addr; Sigt *type; } this complicates the code somewhat, but it reduces the number of Itypes that have to be computed and cached, it opens up opportunities to avoid function calls in a few common cases, and it will make it possible to lay out interface{} values at compile time, which i think i'll need for the new reflection. R=ken OCL=28701 CL=29121
Diffstat (limited to 'src/runtime/runtime.c')
-rw-r--r--src/runtime/runtime.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c
index afb9cce172..57e2570905 100644
--- a/src/runtime/runtime.c
+++ b/src/runtime/runtime.c
@@ -363,7 +363,7 @@ static void
interprint(uint32 s, Iface *a)
{
USED(s);
- sys·printinter(*a);
+ sys·printiface(*a);
}
static uint32
@@ -373,6 +373,27 @@ interequal(uint32 s, Iface *a, Iface *b)
return ifaceeq(*a, *b);
}
+static uint64
+nilinterhash(uint32 s, Eface *a)
+{
+ USED(s);
+ return efacehash(*a);
+}
+
+static void
+nilinterprint(uint32 s, Eface *a)
+{
+ USED(s);
+ sys·printeface(*a);
+}
+
+static uint32
+nilinterequal(uint32 s, Eface *a, Eface *b)
+{
+ USED(s);
+ return efaceeq(*a, *b);
+}
+
uint64
nohash(uint32 s, void *a)
{
@@ -416,6 +437,7 @@ algarray[] =
[ANOEQ] { nohash, noequal, memprint, memcopy },
[ASTRING] { strhash, strequal, strprint, memcopy },
[AINTER] { interhash, interequal, interprint, memcopy },
+[ANILINTER] { nilinterhash, nilinterequal, nilinterprint, memcopy },
[AFAKE] { nohash, noequal, noprint, nocopy },
};