diff options
author | Russ Cox <rsc@golang.org> | 2010-10-20 18:11:53 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-10-20 18:11:53 -0400 |
commit | 231fcea7e60ebf76d01b6ebd6534558ac079fe3c (patch) | |
tree | af8fb1935046d1ab7d1af27f8d0bc045a63fb7ea | |
parent | 10b53867e85dd2c43b2bb7ee7eb892019b2c08cf (diff) | |
download | go-231fcea7e60ebf76d01b6ebd6534558ac079fe3c.tar.gz go-231fcea7e60ebf76d01b6ebd6534558ac079fe3c.zip |
5l: two stack split bugs in one day
An ARM expert could probably phrase the
comparison in fewer instructions, but this works.
R=ken2
CC=golang-dev
https://golang.org/cl/2620041
-rw-r--r-- | src/cmd/5l/noop.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/cmd/5l/noop.c b/src/cmd/5l/noop.c index a3a0ae29b2..5def0d3f16 100644 --- a/src/cmd/5l/noop.c +++ b/src/cmd/5l/noop.c @@ -37,6 +37,7 @@ enum { StackBig = 4096, + StackSmall = 128, }; static Sym* sym_div; @@ -296,7 +297,7 @@ noops(void) // TODO(kaib): add more trampolines // TODO(kaib): put stackguard in register // TODO(kaib): add support for -K and underflow detection - + // MOVW g_stackguard(g), R1 p = appendp(p); p->as = AMOVW; @@ -304,14 +305,31 @@ noops(void) p->from.reg = REGG; p->to.type = D_REG; p->to.reg = 1; - - // CMP R1, $-autosize(SP) - p = appendp(p); - p->as = ACMP; - p->from.type = D_REG; - p->from.reg = 1; - p->from.offset = -autosize; - p->reg = REGSP; + + if(autosize < StackSmall) { + // CMP R1, SP + p = appendp(p); + p->as = ACMP; + p->from.type = D_REG; + p->from.reg = 1; + p->reg = REGSP; + } else { + // MOVW $-autosize(SP), R2 + // CMP R1, R2 + p = appendp(p); + p->as = AMOVW; + p->from.type = D_CONST; + p->from.reg = REGSP; + p->from.offset = -autosize; + p->to.type = D_REG; + p->to.reg = 2; + + p = appendp(p); + p->as = ACMP; + p->from.type = D_REG; + p->from.reg = 1; + p->reg = 2; + } // MOVW.LO $autosize, R1 p = appendp(p); |