Fix problem which only seems to occur on Core Duo: we were relying on unspecified behavior, and that is SHL setting the overflow flag with a shift count greater than one

slava 2006-07-06 03:30:56 +00:00
parent d8be9e23ec
commit a393fe218c
3 changed files with 12 additions and 4 deletions

View File

@ -27,10 +27,15 @@ M: cs-loc v>operand cs-loc-n cs-reg reg-stack ;
: %alien-invoke ( symbol dll -- )
2dup dlsym CALL rel-relative rel-dlsym ;
: with-aligned-stack ( n quot -- )
#! On Linux, there is no requirement to align stack frames,
#! so this is mostly a no-op.
swap slip stack-reg swap ADD ; inline
: compile-c-call* ( symbol dll args -- operands )
<reversed>
[ [ PUSH ] each %alien-invoke ] keep
[ drop EDX POP ] each ;
dup length cells [
<reversed> [ PUSH ] each %alien-invoke
] with-aligned-stack ;
GENERIC: push-return-reg ( reg-class -- )
GENERIC: pop-return-reg ( reg-class -- )

View File

@ -352,6 +352,9 @@ M: operand CMP OCT: 071 2-operand ;
: DIV ( dst -- ) BIN: 110 t HEX: f7 1-operand ;
: IDIV ( src -- ) BIN: 111 t HEX: f7 1-operand ;
GENERIC: IMUL2 ( dst src -- )
M: integer IMUL2 swap dup reg-code t HEX: 69 immediate-1/4 ;
: CDQ HEX: 99 assemble-1 ;
: CQO HEX: 48 assemble-1 CDQ ;

View File

@ -216,7 +216,7 @@ IN: compiler
"y" operand "x" operand MOV
! Tag the value, since division cancelled tags from both
! inputs
"x" operand tag-bits SHL
"x" operand 1 tag-bits shift IMUL2
! Did it overflow?
"end" get JNO
! There was an overflow, so make ECX into a bignum. we must