diff --git a/library/compiler/x86/architecture.factor b/library/compiler/x86/architecture.factor index cbe4a44410..046dba8d9e 100644 --- a/library/compiler/x86/architecture.factor +++ b/library/compiler/x86/architecture.factor @@ -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 ) - - [ [ PUSH ] each %alien-invoke ] keep - [ drop EDX POP ] each ; + dup length cells [ + [ PUSH ] each %alien-invoke + ] with-aligned-stack ; GENERIC: push-return-reg ( reg-class -- ) GENERIC: pop-return-reg ( reg-class -- ) diff --git a/library/compiler/x86/assembler.factor b/library/compiler/x86/assembler.factor index 9cce4a3aeb..06ed8d88e6 100644 --- a/library/compiler/x86/assembler.factor +++ b/library/compiler/x86/assembler.factor @@ -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 ; diff --git a/library/compiler/x86/intrinsics.factor b/library/compiler/x86/intrinsics.factor index d4d8189358..3be041fd9a 100644 --- a/library/compiler/x86/intrinsics.factor +++ b/library/compiler/x86/intrinsics.factor @@ -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