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.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/runtime/runtime.h') diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 68d3748f37..f2926037aa 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -57,6 +57,8 @@ typedef struct SigTab SigTab; typedef struct MCache MCache; typedef struct Iface Iface; typedef struct Itype Itype; +typedef struct Eface Eface; +typedef struct Sigt Sigt; typedef struct Defer Defer; /* @@ -118,6 +120,11 @@ struct Iface Itype* type; void* data; }; +struct Eface +{ + Sigt* type; + void* data; +}; struct Array { // must not move anything @@ -238,6 +245,7 @@ enum ANOEQ, ASTRING, AINTER, + ANILINTER, AFAKE, Amax }; @@ -323,7 +331,9 @@ void stackfree(void*); MCache* allocmcache(void); void mallocinit(void); bool ifaceeq(Iface, Iface); +bool efaceeq(Eface, Eface); uint64 ifacehash(Iface); +uint64 efacehash(Eface); uint64 nohash(uint32, void*); uint32 noequal(uint32, void*, void*); void* malloc(uintptr size); @@ -396,7 +406,8 @@ void notewakeup(Note*); #define sys_printfloat sys·printfloat #define sys_printhex sys·printhex #define sys_printint sys·printint -#define sys_printinter sys·printinter +#define sys_printiface sys·printiface +#define sys_printeface sys·printeface #define sys_printpc sys·printpc #define sys_printpointer sys·printpointer #define sys_printstring sys·printstring @@ -420,7 +431,8 @@ void* sys_getcallerpc(void*); void sys_printbool(bool); void sys_printfloat(float64); void sys_printint(int64); -void sys_printinter(Iface); +void sys_printiface(Iface); +void sys_printeface(Eface); void sys_printstring(String); void sys_printpc(void*); void sys_printpointer(void*); -- cgit v1.3-5-g9baa