ref: f056f3aecfa11bb28eb32f63421a05eea4e15a54
parent: a13e213407d86a54a24977578e0f903248b8702c
author: Ori Bernstein <[email protected]>
date: Thu Dec 25 21:53:34 EST 2014
We were killing the spare stack space when unpopping args. Oops.
--- a/libstd/syswrap+plan9-x64.myr
+++ b/libstd/syswrap+plan9-x64.myr
@@ -89,7 +89,7 @@
const digitchars = "0123456789"
const exit = {status
var buf : byte[32] /* big enough for exit status numbers */
- var n, i, idx
+ var n, i
if status == 0
sys.exits("")
@@ -98,10 +98,8 @@
i = 100
n = 0
while i > 0
- if i <= status
- idx = (status/i)
- idx %= 10
- buf[n++] = digitchars[idx]
+ if status >= i
+ buf[n++] = digitchars[(status/i)%10]
;;
i /= 10
;;
--- a/libstd/util+plan9-x64.s
+++ b/libstd/util+plan9-x64.s
@@ -26,12 +26,12 @@
SUBQ $1,SP /* +1 for nul */
MOVQ SP,DI /* dest */
MOVQ SP,AX /* ret val */
- SUBQ $16,SP /* "unpop" the args */
+ SUBQ $31,SP /* "unpop" the args */
ANDQ $(~15),SP /* align */
CLD
REP
- MOVSB
+ MOVSB
MOVB $0,(DI) /* terminate */
/* Restore registers */
@@ -57,7 +57,7 @@
/* get stack space */
SUBQ BX,SP /* get stack space */
MOVQ SP,AX /* top of stack (return value) */
- SUBQ $16,SP /* "unpop" the args for return */
+ SUBQ $3,SP /* "unpop" the args for return */
ANDQ $(~15),SP /* align */
MOVQ R15,0(SP) /* place ret addr */
--- a/libstd/util+posixy-x64.s
+++ b/libstd/util+posixy-x64.s
@@ -28,7 +28,7 @@
subq $1,%rsp /* +1 for nul */
movq %rsp,%rdi /* dest */
movq %rsp,%rax /* ret val */
- subq $16,%rsp /* "unpop" the args */
+ subq $31,%rsp /* "unpop" the args */
andq $(~15),%rsp /* align */
cld
@@ -61,7 +61,7 @@
/* get stack space */
subq %rbx,%rsp /* get stack space */
movq %rsp,%rax /* top of stack (return value) */
- subq $16,%rsp /* "unpop" the args for return */
+ subq $31,%rsp /* "unpop" the args for return */
andq $(~15),%rsp /* align */
pushq %r15 /* ret addr */