summaryrefslogtreecommitdiff
path: root/src/cmd/6g
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-03-19 15:41:34 -0700
committerKeith Randall <khr@golang.org>2014-03-19 15:41:34 -0700
commitccf7f12e4bf8b78dab0b660ebe905309c91135dc (patch)
tree92d9b558118fb02cf4f40bca8bfb9f2ac4587a37 /src/cmd/6g
parente887b456832eabc461ca48906a08ecf4dfc9a358 (diff)
downloadgo-ccf7f12e4bf8b78dab0b660ebe905309c91135dc.tar.gz
cmd/6g: do small zeroings with straightline code.
Removes most uses of the REP prefix, which has a high startup cost. LGTM=iant R=golang-codereviews, iant, khr CC=golang-codereviews https://codereview.appspot.com/77920043
Diffstat (limited to 'src/cmd/6g')
-rw-r--r--src/cmd/6g/ggen.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/cmd/6g/ggen.c b/src/cmd/6g/ggen.c
index b046ac5a4..6dcf26303 100644
--- a/src/cmd/6g/ggen.c
+++ b/src/cmd/6g/ggen.c
@@ -16,6 +16,7 @@ defframe(Prog *ptxt)
{
uint32 frame;
Prog *p;
+ vlong i;
// fill in argument size
ptxt->to.offset = rnd(curfn->type->argwid, widthptr);
@@ -29,12 +30,25 @@ defframe(Prog *ptxt)
// so that garbage collector only sees initialized values
// when it looks for pointers.
p = ptxt;
- if(stkzerosize > 0) {
- p = appendpp(p, movptr, D_CONST, 0, D_AX, 0);
- p = appendpp(p, movptr, D_CONST, stkzerosize/widthptr, D_CX, 0);
- p = appendpp(p, leaptr, D_SP+D_INDIR, frame-stkzerosize, D_DI, 0);
- p = appendpp(p, AREP, D_NONE, 0, D_NONE, 0);
- appendpp(p, stosptr, D_NONE, 0, D_NONE, 0);
+ if(stkzerosize % widthreg != 0)
+ fatal("zero size not a multiple of ptr size");
+ if(stkzerosize == 0) {
+ // nothing
+ } else if(stkzerosize <= 2*widthreg) {
+ for(i = 0; i < stkzerosize; i += widthreg) {
+ p = appendpp(p, AMOVQ, D_CONST, 0, D_SP+D_INDIR, frame-stkzerosize+i);
+ }
+ } else if(stkzerosize <= 16*widthreg) {
+ p = appendpp(p, AMOVQ, D_CONST, 0, D_AX, 0);
+ for(i = 0; i < stkzerosize; i += widthreg) {
+ p = appendpp(p, AMOVQ, D_AX, 0, D_SP+D_INDIR, frame-stkzerosize+i);
+ }
+ } else {
+ p = appendpp(p, AMOVQ, D_CONST, 0, D_AX, 0);
+ p = appendpp(p, AMOVQ, D_CONST, stkzerosize/widthreg, D_CX, 0);
+ p = appendpp(p, leaptr, D_SP+D_INDIR, frame-stkzerosize, D_DI, 0);
+ p = appendpp(p, AREP, D_NONE, 0, D_NONE, 0);
+ appendpp(p, ASTOSQ, D_NONE, 0, D_NONE, 0);
}
}