From 2da5022bcf578545207ecc0ed0a8c7669e7f708f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 20 May 2009 14:57:55 -0700 Subject: 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 --- src/runtime/runtime.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/runtime/runtime.c') 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 }, }; -- cgit v1.3-5-g9baa