diff options
author | Russ Cox <rsc@golang.org> | 2009-05-20 14:57:55 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-05-20 14:57:55 -0700 |
commit | d58b7beef04a482788ec91ecb409f4a96cea0be2 (patch) | |
tree | 262689682751a1adebce9c4281e1ab77eb480cb4 /src/runtime/runtime.h | |
parent | 7f9a034c1d42f97eda15f17317fa3f823d172661 (diff) | |
download | go-d58b7beef04a482788ec91ecb409f4a96cea0be2.tar.gz |
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.h')
-rw-r--r-- | src/runtime/runtime.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 68d3748f3..f2926037a 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*); |