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
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index 68d3748..f292603 100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -57,6 +57,8 @@
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 @@
Itype* type;
void* data;
};
+struct Eface
+{
+ Sigt* type;
+ void* data;
+};
struct Array
{ // must not move anything
@@ -238,6 +245,7 @@
ANOEQ,
ASTRING,
AINTER,
+ ANILINTER,
AFAKE,
Amax
};
@@ -323,7 +331,9 @@
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 @@
#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_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*);