From: Ken Thompson Date: Thu, 5 Nov 2009 20:47:22 +0000 (-0800) Subject: same speedup as 6l X-Git-Tag: weekly.2009-11-06~47 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=505fd760a20d27753def021bd5c2eecbf670e87d;p=gostls13.git same speedup as 6l R=rsc http://go/go-review/1016050 --- diff --git a/src/cmd/8l/asm.c b/src/cmd/8l/asm.c index 6dfdc387a8..7f101b74ea 100644 --- a/src/cmd/8l/asm.c +++ b/src/cmd/8l/asm.c @@ -1035,27 +1035,31 @@ datblk(int32 s, int32 n) char *cast; int32 l, fl, j; int i, c; + Adr *a; memset(buf.dbuf, 0, n+Dbufslop); for(p = datap; p != P; p = p->link) { - curp = p; - if(!p->from.sym->reachable) - diag("unreachable symbol in datblk - %s", p->from.sym->name); - if(p->from.sym->type == SMACHO) + a = &p->from; + + l = a->sym->value + a->offset - s; + if(l >= n) continue; - l = p->from.sym->value + p->from.offset - s; - c = p->from.scale; + + c = a->scale; i = 0; if(l < 0) { if(l+c <= 0) continue; - while(l < 0) { - l++; - i++; - } + i = -l; + l = 0; } - if(l >= n) + + curp = p; + if(!a->sym->reachable) + diag("unreachable symbol in datblk - %s", a->sym->name); + if(a->sym->type == SMACHO) continue; + if(p->as != AINIT && p->as != ADYNT) { for(j=l+(c-i)-1; j>=l; j--) if(buf.dbuf[j]) { @@ -1071,12 +1075,6 @@ datblk(int32 s, int32 n) case 4: fl = ieeedtof(&p->to.ieee); cast = (char*)&fl; - if(debug['a'] && i == 0) { - Bprint(&bso, pcstr, l+s+INITDAT); - for(j=0; jto.ieee; - if(debug['a'] && i == 0) { - Bprint(&bso, pcstr, l+s+INITDAT); - for(j=0; jto.scon[j] & 0xff); - Bprint(&bso, "\t%P\n", curp); - } for(; ito.scon[i]; l++; @@ -1134,36 +1120,18 @@ datblk(int32 s, int32 n) diag("bad nuxi %d %d\n%P", c, i, curp); break; case 1: - if(debug['a'] && i == 0) { - Bprint(&bso, pcstr, l+s+INITDAT); - for(j=0; jlink) { + a = &p->from; + + l = a->sym->value + a->offset - s; + if(l < 0 || l >= n) + continue; + + c = a->scale; + i = 0; + + switch(p->to.type) { + case D_FCONST: + switch(c) { + default: + case 4: + fl = ieeedtof(&p->to.ieee); + cast = (char*)&fl; + Bprint(&bso, pcstr, l+s+INITDAT); + for(j=0; jto.ieee; + Bprint(&bso, pcstr, l+s+INITDAT); + for(j=0; jto.scon[j] & 0xff); + Bprint(&bso, "\t%P\n", curp); + break; + + default: + fl = p->to.offset; + if(p->to.type == D_SIZE) + fl += p->to.sym->size; + if(p->to.type == D_ADDR) { + if(p->to.index != D_STATIC && p->to.index != D_EXTERN) + diag("DADDR type%P", p); + if(p->to.sym) { + if(p->to.sym->type == SUNDEF) + ckoff(p->to.sym, fl); + fl += p->to.sym->value; + if(p->to.sym->type != STEXT && p->to.sym->type != SUNDEF) + fl += INITDAT; + if(dlm) + dynreloc(p->to.sym, l+s+INITDAT, 1); + } + } + cast = (char*)&fl; + switch(c) { + default: + diag("bad nuxi %d %d\n%P", c, i, curp); + break; + case 1: + Bprint(&bso, pcstr, l+s+INITDAT); + for(j=0; jfrom read EXTERN Adr* reloca; EXTERN int doexp, dlm; diff --git a/src/cmd/8l/list.c b/src/cmd/8l/list.c index a8a042fc64..94ef97624c 100644 --- a/src/cmd/8l/list.c +++ b/src/cmd/8l/list.c @@ -179,8 +179,8 @@ brk: } conv: fmtstrcpy(fp, str); - if(a->gotype) - fmtprint(fp, "«%s»", a->gotype->name); +// if(a->gotype) +// fmtprint(fp, "«%s»", a->gotype->name); return 0; } diff --git a/src/cmd/8l/obj.c b/src/cmd/8l/obj.c index d60b9eaba5..88925e691d 100644 --- a/src/cmd/8l/obj.c +++ b/src/cmd/8l/obj.c @@ -401,12 +401,11 @@ zaddr(Biobuf *f, Adr *a, Sym *h[]) Auto *u; t = Bgetc(f); + a->index = D_NONE; + a->scale = 0; if(t & T_INDEX) { a->index = Bgetc(f); a->scale = Bgetc(f); - } else { - a->index = D_NONE; - a->scale = 0; } a->type = D_NONE; a->offset = 0; @@ -431,8 +430,9 @@ zaddr(Biobuf *f, Adr *a, Sym *h[]) } if(t & T_TYPE) a->type = Bgetc(f); + adrgotype = S; if(t & T_GOTYPE) - a->gotype = h[Bgetc(f)]; + adrgotype = h[Bgetc(f)]; t = a->type; if(t == D_INDIR+D_GS) @@ -442,8 +442,8 @@ zaddr(Biobuf *f, Adr *a, Sym *h[]) if(s == S) return; if(t != D_AUTO && t != D_PARAM) { - if(a->gotype) - s->gotype = a->gotype; + if(adrgotype) + s->gotype = adrgotype; return; } l = a->offset; @@ -452,8 +452,8 @@ zaddr(Biobuf *f, Adr *a, Sym *h[]) if(u->type == t) { if(u->aoffset > l) u->aoffset = l; - if(a->gotype) - u->gotype = a->gotype; + if(adrgotype) + u->gotype = adrgotype; return; } } @@ -464,7 +464,7 @@ zaddr(Biobuf *f, Adr *a, Sym *h[]) u->asym = s; u->aoffset = l; u->type = t; - u->gotype = a->gotype; + u->gotype = adrgotype; } void @@ -570,7 +570,10 @@ loop: p->as = o; p->line = Bget4(f); p->back = 2; + p->ft = 0; + p->tt = 0; zaddr(f, &p->from, h); + fromgotype = adrgotype; zaddr(f, &p->to, h); if(debug['W']) @@ -668,8 +671,8 @@ loop: // redefinitions. s = p->from.sym; if(s != S && s->dupok) { - if(debug['v']) - Bprint(&bso, "skipping %s in %s: dupok\n", s->name, pn); +// if(debug['v']) +// Bprint(&bso, "skipping %s in %s: dupok\n", s->name, pn); goto loop; } if(s != S) { diff --git a/src/cmd/8l/span.c b/src/cmd/8l/span.c index 0204caa1e8..370ae67d33 100644 --- a/src/cmd/8l/span.c +++ b/src/cmd/8l/span.c @@ -882,21 +882,33 @@ subreg(Prog *p, int from, int to) if(debug['Q']) print("\n%P s/%R/%R/\n", p, from, to); - if(p->from.type == from) + if(p->from.type == from) { p->from.type = to; - if(p->to.type == from) + p->ft = 0; + } + if(p->to.type == from) { p->to.type = to; + p->tt = 0; + } - if(p->from.index == from) + if(p->from.index == from) { p->from.index = to; - if(p->to.index == from) + p->ft = 0; + } + if(p->to.index == from) { p->to.index = to; + p->tt = 0; + } from += D_INDIR; - if(p->from.type == from) + if(p->from.type == from) { p->from.type = to+D_INDIR; - if(p->to.type == from) + p->ft = 0; + } + if(p->to.type == from) { p->to.type = to+D_INDIR; + p->tt = 0; + } if(debug['Q']) print("%P\n", p); @@ -934,9 +946,30 @@ doasm(Prog *p) if(pre) *andptr++ = pre; + +if(p->ft != 0) { + ft = oclass(&p->from); + if(ft != p->ft) { + print("***** %d %d %D\n", p->ft, ft, &p->from); + p->ft = ft; + } +} +if(p->tt != 0) { + tt = oclass(&p->to); + if(tt != p->tt) { + print("***** %d %d %D\n", p->tt, tt, &p->to); + p->tt = tt; + } +} + +// if(p->ft == 0) + p->ft = oclass(&p->from); +// if(p->tt == 0) + p->tt = oclass(&p->to); + + ft = p->ft * Ymax; + tt = p->tt * Ymax; o = &optab[p->as]; - ft = oclass(&p->from) * Ymax; - tt = oclass(&p->to) * Ymax; t = o->ytab; if(t == 0) { diag("asmins: noproto %P", p); @@ -998,9 +1031,11 @@ found: diag("asmins: Zaut sb type ADDR"); p->from.type = p->from.index; p->from.index = D_NONE; + p->ft = 0; asmand(&p->from, reg[p->to.type]); p->from.index = p->from.type; p->from.type = D_ADDR; + p->ft = 0; break; case Zm_o: