summaryrefslogtreecommitdiff
path: root/src/cmd/5a
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2013-08-30 15:46:12 +0400
committerDmitriy Vyukov <dvyukov@google.com>2013-08-30 15:46:12 +0400
commit5c03c230954d1491c25b14690d2b6bb96452cfa1 (patch)
tree4d916a84cc854b172ce2088cd8968c13316d8568 /src/cmd/5a
parent564f6b8ad1baba0e954929e1f3ac0bc0735982c3 (diff)
downloadgo-5c03c230954d1491c25b14690d2b6bb96452cfa1.tar.gz
libbio, all cmd: consistently use BGETC/BPUTC instead of Bgetc/Bputc
Also introduce BGET2/4, BPUT2/4 as they are widely used. Slightly improve BGETC/BPUTC implementation. This gives ~5% CPU time improvement on go install -a -p1 std. Before: real user sys 0m23.561s 0m16.625s 0m5.848s 0m23.766s 0m16.624s 0m5.846s 0m23.742s 0m16.621s 0m5.868s after: 0m22.999s 0m15.841s 0m5.889s 0m22.845s 0m15.808s 0m5.850s 0m22.889s 0m15.832s 0m5.848s R=golang-dev, r CC=golang-dev https://codereview.appspot.com/12745047
Diffstat (limited to 'src/cmd/5a')
-rw-r--r--src/cmd/5a/lex.c76
1 files changed, 29 insertions, 47 deletions
diff --git a/src/cmd/5a/lex.c b/src/cmd/5a/lex.c
index 3b537a967..c1b54e50b 100644
--- a/src/cmd/5a/lex.c
+++ b/src/cmd/5a/lex.c
@@ -485,14 +485,14 @@ void
zname(char *n, int t, int s)
{
- Bputc(&obuf, ANAME);
- Bputc(&obuf, t); /* type */
- Bputc(&obuf, s); /* sym */
+ BPUTC(&obuf, ANAME);
+ BPUTC(&obuf, t); /* type */
+ BPUTC(&obuf, s); /* sym */
while(*n) {
- Bputc(&obuf, *n);
+ BPUTC(&obuf, *n);
n++;
}
- Bputc(&obuf, 0);
+ BPUTC(&obuf, 0);
}
void
@@ -503,11 +503,11 @@ zaddr(Gen *a, int s)
char *n;
Ieee e;
- Bputc(&obuf, a->type);
- Bputc(&obuf, a->reg);
- Bputc(&obuf, s);
- Bputc(&obuf, a->name);
- Bputc(&obuf, 0);
+ BPUTC(&obuf, a->type);
+ BPUTC(&obuf, a->reg);
+ BPUTC(&obuf, s);
+ BPUTC(&obuf, a->name);
+ BPUTC(&obuf, 0);
switch(a->type) {
default:
print("unknown type %d\n", a->type);
@@ -522,45 +522,33 @@ zaddr(Gen *a, int s)
case D_REGREG:
case D_REGREG2:
- Bputc(&obuf, a->offset);
+ BPUTC(&obuf, a->offset);
break;
case D_CONST2:
l = a->offset2;
- Bputc(&obuf, l);
- Bputc(&obuf, l>>8);
- Bputc(&obuf, l>>16);
- Bputc(&obuf, l>>24);
+ BPUTLE4(&obuf, l);
// fall through
case D_OREG:
case D_CONST:
case D_BRANCH:
case D_SHIFT:
l = a->offset;
- Bputc(&obuf, l);
- Bputc(&obuf, l>>8);
- Bputc(&obuf, l>>16);
- Bputc(&obuf, l>>24);
+ BPUTLE4(&obuf, l);
break;
case D_SCONST:
n = a->sval;
for(i=0; i<NSNAME; i++) {
- Bputc(&obuf, *n);
+ BPUTC(&obuf, *n);
n++;
}
break;
case D_FCONST:
ieeedtod(&e, a->dval);
- Bputc(&obuf, e.l);
- Bputc(&obuf, e.l>>8);
- Bputc(&obuf, e.l>>16);
- Bputc(&obuf, e.l>>24);
- Bputc(&obuf, e.h);
- Bputc(&obuf, e.h>>8);
- Bputc(&obuf, e.h>>16);
- Bputc(&obuf, e.h>>24);
+ BPUTLE4(&obuf, e.l);
+ BPUTLE4(&obuf, e.h);
break;
}
}
@@ -642,13 +630,10 @@ jackpot:
goto jackpot;
break;
}
- Bputc(&obuf, a);
- Bputc(&obuf, scond);
- Bputc(&obuf, reg);
- Bputc(&obuf, stmtline);
- Bputc(&obuf, stmtline>>8);
- Bputc(&obuf, stmtline>>16);
- Bputc(&obuf, stmtline>>24);
+ BPUTC(&obuf, a);
+ BPUTC(&obuf, scond);
+ BPUTC(&obuf, reg);
+ BPUTLE4(&obuf, stmtline);
zaddr(g1, sf);
zaddr(g2, st);
@@ -722,12 +707,12 @@ outhist(void)
q = 0;
}
if(n) {
- Bputc(&obuf, ANAME);
- Bputc(&obuf, D_FILE); /* type */
- Bputc(&obuf, 1); /* sym */
- Bputc(&obuf, '<');
+ BPUTC(&obuf, ANAME);
+ BPUTC(&obuf, D_FILE); /* type */
+ BPUTC(&obuf, 1); /* sym */
+ BPUTC(&obuf, '<');
Bwrite(&obuf, p, n);
- Bputc(&obuf, 0);
+ BPUTC(&obuf, 0);
}
p = q;
if(p == 0 && op) {
@@ -737,13 +722,10 @@ outhist(void)
}
g.offset = h->offset;
- Bputc(&obuf, AHISTORY);
- Bputc(&obuf, Always);
- Bputc(&obuf, 0);
- Bputc(&obuf, h->line);
- Bputc(&obuf, h->line>>8);
- Bputc(&obuf, h->line>>16);
- Bputc(&obuf, h->line>>24);
+ BPUTC(&obuf, AHISTORY);
+ BPUTC(&obuf, Always);
+ BPUTC(&obuf, 0);
+ BPUTLE4(&obuf, h->line);
zaddr(&nullgen, 0);
zaddr(&g, 0);