diff options
author | Russ Cox <rsc@golang.org> | 2009-01-26 12:36:21 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-01-26 12:36:21 -0800 |
commit | 0a1049d41a25723f16e04731e5b3a783ae6f94d4 (patch) | |
tree | 2510d5aae07204aade67d94379f589f3c9bb7738 /src/cmd | |
parent | 081cbe92037e34574d75be5fddb30660805c67c6 (diff) | |
download | golang-0a1049d41a25723f16e04731e5b3a783ae6f94d4.tar.gz |
interface speedups and fixes.
more caching, better hash functions, proper locking.
fixed a bug in interface comparison too.
R=ken
DELTA=177 (124 added, 10 deleted, 43 changed)
OCL=23491
CL=23493
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/6g/obj.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/cmd/6g/obj.c b/src/cmd/6g/obj.c index 76c6a93e2..85e668d66 100644 --- a/src/cmd/6g/obj.c +++ b/src/cmd/6g/obj.c @@ -635,12 +635,14 @@ dumpsigt(Type *progt, Type *ifacet, Type *rcvrt, Type *methodt, Sym *s) Iter savet; Prog *oldlist; Sym *method; + uint32 sighash; at.sym = s; a = nil; o = 0; oldlist = nil; + sighash = 0; for(f=methodt->method; f!=T; f=f->down) { if(f->type->etype != TFUNC) continue; @@ -662,6 +664,8 @@ dumpsigt(Type *progt, Type *ifacet, Type *rcvrt, Type *methodt, Sym *s) a->hash += PRIME10*stringhash(package); a->perm = o; a->sym = methodsym(method, rcvrt); + + sighash = sighash*100003 + a->hash; if(!a->sym->siggen) { a->sym->siggen = 1; @@ -709,7 +713,7 @@ dumpsigt(Type *progt, Type *ifacet, Type *rcvrt, Type *methodt, Sym *s) ot = 0; ot = rnd(ot, maxround); // base structure - // sigi[0].name = "" + // sigt[0].name = "" ginsatoa(widthptr, stringo); // save type name for runtime error message. @@ -718,10 +722,10 @@ dumpsigt(Type *progt, Type *ifacet, Type *rcvrt, Type *methodt, Sym *s) // first field of an type signature contains // the element parameters and is not a real entry - // sigi[0].hash = elemalg - gensatac(wi, algtype(progt)); + // sigt[0].hash = elemalg + sighash<<8 + gensatac(wi, algtype(progt) + (sighash<<8)); - // sigi[0].offset = width + // sigt[0].offset = width gensatac(wi, progt->width); // skip the function @@ -730,10 +734,10 @@ dumpsigt(Type *progt, Type *ifacet, Type *rcvrt, Type *methodt, Sym *s) for(b=a; b!=nil; b=b->link) { ot = rnd(ot, maxround); // base structure - // sigx[++].name = "fieldname" + // sigt[++].name = "fieldname" ginsatoa(widthptr, stringo); - // sigx[++].hash = hashcode + // sigt[++].hash = hashcode gensatac(wi, b->hash); // sigt[++].offset = of embedded struct @@ -770,11 +774,13 @@ dumpsigi(Type *t, Sym *s) Sig *a, *b; Prog *p; char buf[NSYMB]; + uint32 sighash; at.sym = s; a = nil; o = 0; + sighash = 0; for(f=t->type; f!=T; f=f->down) { if(f->type->etype != TFUNC) continue; @@ -797,6 +803,8 @@ dumpsigi(Type *t, Sym *s) a->perm = o; a->sym = methodsym(f->sym, t); a->offset = 0; + + sighash = sighash*100003 + a->hash; o++; } @@ -815,8 +823,8 @@ dumpsigi(Type *t, Sym *s) // first field of an interface signature // contains the count and is not a real entry - // sigi[0].hash = 0 - gensatac(wi, 0); + // sigi[0].hash = sighash + gensatac(wi, sighash); // sigi[0].offset = count o = 0; |