mirror of
https://github.com/golang/go
synced 2024-11-22 02:44:39 -07:00
arm: bugfixes and syscall
- integer divide by zero raises panic - float comparisons involving NaNs work - syscall interface actually handles return values and errno correctly. R=rsc, bradfitzpatrick CC=golang-dev https://golang.org/cl/1847047
This commit is contained in:
parent
c8c2bdbc59
commit
df88fc6109
@ -1044,7 +1044,16 @@ bgen(Node *n, int true, Prog *to)
|
|||||||
cgen(nr, &n2);
|
cgen(nr, &n2);
|
||||||
|
|
||||||
gcmp(optoas(OCMP, nr->type), &n1, &n2);
|
gcmp(optoas(OCMP, nr->type), &n1, &n2);
|
||||||
|
if(isfloat[nl->type->etype]) {
|
||||||
|
p1 = gbranch(ABVS, nr->type);
|
||||||
patch(gbranch(a, nr->type), to);
|
patch(gbranch(a, nr->type), to);
|
||||||
|
if(n->op == ONE)
|
||||||
|
patch(p1, to);
|
||||||
|
else
|
||||||
|
patch(p1, pc);
|
||||||
|
} else {
|
||||||
|
patch(gbranch(a, nr->type), to);
|
||||||
|
}
|
||||||
|
|
||||||
regfree(&n1);
|
regfree(&n1);
|
||||||
regfree(&n2);
|
regfree(&n2);
|
||||||
|
@ -62,7 +62,7 @@ TEXT save<>(SB), 7, $0
|
|||||||
MOVW 20(FP), R(D) /* denominator */
|
MOVW 20(FP), R(D) /* denominator */
|
||||||
CMP $0, R(D)
|
CMP $0, R(D)
|
||||||
BNE s1
|
BNE s1
|
||||||
SWI 0
|
BL panicdivide(SB)
|
||||||
/* MOVW -1(R(D)), R(TMP) /* divide by zero fault */
|
/* MOVW -1(R(D)), R(TMP) /* divide by zero fault */
|
||||||
s1: RET
|
s1: RET
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
// declared here to avoid include of runtime.h
|
||||||
|
void panicstring(char*);
|
||||||
|
|
||||||
typedef unsigned long ulong;
|
typedef unsigned long ulong;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
typedef unsigned short ushort;
|
typedef unsigned short ushort;
|
||||||
@ -31,6 +34,12 @@ typedef signed char schar;
|
|||||||
|
|
||||||
#define SIGN(n) (1UL<<(n-1))
|
#define SIGN(n) (1UL<<(n-1))
|
||||||
|
|
||||||
|
void
|
||||||
|
panicdivide(void)
|
||||||
|
{
|
||||||
|
panicstring("integer divide by zero");
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct Vlong Vlong;
|
typedef struct Vlong Vlong;
|
||||||
struct Vlong
|
struct Vlong
|
||||||
{
|
{
|
||||||
@ -190,7 +199,7 @@ dodiv(Vlong num, Vlong den, Vlong *q, Vlong *r)
|
|||||||
* get a divide by zero
|
* get a divide by zero
|
||||||
*/
|
*/
|
||||||
if(denlo==0 && denhi==0) {
|
if(denlo==0 && denhi==0) {
|
||||||
numlo = numlo / denlo;
|
panicdivide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -17,9 +17,21 @@ TEXT ·Syscall(SB),7,$0
|
|||||||
MOVW 12(SP), R1
|
MOVW 12(SP), R1
|
||||||
MOVW 16(SP), R2
|
MOVW 16(SP), R2
|
||||||
SWI $0
|
SWI $0
|
||||||
|
MOVW $0xfffff001, R1
|
||||||
|
CMP R1, R0
|
||||||
|
BLS ok
|
||||||
|
MOVW $-1, R1
|
||||||
|
MOVW R1, 20(SP) // r1
|
||||||
|
MOVW $0, R2
|
||||||
|
MOVW R2, 24(SP) // r2
|
||||||
|
RSB $0, R0, R0
|
||||||
|
MOVW R0, 28(SP) // errno
|
||||||
|
BL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
ok:
|
||||||
MOVW R0, 20(SP) // r1
|
MOVW R0, 20(SP) // r1
|
||||||
MOVW R1, 24(SP) // r2
|
|
||||||
MOVW $0, R0
|
MOVW $0, R0
|
||||||
|
MOVW R0, 24(SP) // r2
|
||||||
MOVW R0, 28(SP) // errno
|
MOVW R0, 28(SP) // errno
|
||||||
BL runtime·exitsyscall(SB)
|
BL runtime·exitsyscall(SB)
|
||||||
RET
|
RET
|
||||||
@ -36,9 +48,21 @@ TEXT ·Syscall6(SB),7,$0
|
|||||||
MOVW 24(SP), R4
|
MOVW 24(SP), R4
|
||||||
MOVW 28(SP), R5
|
MOVW 28(SP), R5
|
||||||
SWI $0
|
SWI $0
|
||||||
|
MOVW $0xfffff001, R1
|
||||||
|
CMP R1, R0
|
||||||
|
BLS ok6
|
||||||
|
MOVW $-1, R1
|
||||||
|
MOVW R1, 32(SP) // r1
|
||||||
|
MOVW $0, R2
|
||||||
|
MOVW R2, 36(SP) // r2
|
||||||
|
RSB $0, R0, R0
|
||||||
|
MOVW R0, 40(SP) // errno
|
||||||
|
BL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
ok6:
|
||||||
MOVW R0, 32(SP) // r1
|
MOVW R0, 32(SP) // r1
|
||||||
MOVW R1, 36(SP) // r2
|
|
||||||
MOVW $0, R0
|
MOVW $0, R0
|
||||||
|
MOVW R0, 36(SP) // r2
|
||||||
MOVW R0, 40(SP) // errno
|
MOVW R0, 40(SP) // errno
|
||||||
BL runtime·exitsyscall(SB)
|
BL runtime·exitsyscall(SB)
|
||||||
RET
|
RET
|
||||||
@ -50,8 +74,19 @@ TEXT ·RawSyscall(SB),7,$0
|
|||||||
MOVW 12(SP), R1
|
MOVW 12(SP), R1
|
||||||
MOVW 16(SP), R2
|
MOVW 16(SP), R2
|
||||||
SWI $0
|
SWI $0
|
||||||
MOVW R0, 20(SP) // r1
|
MOVW $0xfffff001, R1
|
||||||
MOVW R1, 24(SP) // r2
|
CMP R1, R0
|
||||||
MOVW $0, R0
|
BLS ok1
|
||||||
|
MOVW $-1, R1
|
||||||
|
MOVW R1, 20(SP) // r1
|
||||||
|
MOVW $0, R2
|
||||||
|
MOVW R2, 24(SP) // r2
|
||||||
|
RSB $0, R0, R0
|
||||||
|
MOVW R0, 28(SP) // errno
|
||||||
|
RET
|
||||||
|
ok1:
|
||||||
|
MOVW R0, 20(SP) // r1
|
||||||
|
MOVW $0, R0
|
||||||
|
MOVW R0, 24(SP) // r2
|
||||||
MOVW R0, 28(SP) // errno
|
MOVW R0, 28(SP) // errno
|
||||||
RET
|
RET
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
./env.go
|
./env.go
|
||||||
./escape.go
|
./escape.go
|
||||||
./float_lit.go
|
./float_lit.go
|
||||||
# ./floatcmp.go # fail, BUG
|
./floatcmp.go
|
||||||
./for.go
|
./for.go
|
||||||
./func.go
|
./func.go
|
||||||
./func1.go
|
./func1.go
|
||||||
@ -116,7 +116,7 @@
|
|||||||
./varerr.go
|
./varerr.go
|
||||||
./varinit.go
|
./varinit.go
|
||||||
./vectors.go
|
./vectors.go
|
||||||
# ./zerodivide.go # fail, BUG
|
./zerodivide.go
|
||||||
ken/array.go
|
ken/array.go
|
||||||
ken/chan.go
|
ken/chan.go
|
||||||
ken/chan1.go
|
ken/chan1.go
|
||||||
|
Loading…
Reference in New Issue
Block a user