diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 7ed80d1e39..3808fb47ba 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -209,6 +209,8 @@ M:: x86.32 %binary-float-function ( dst src1 src2 func -- ) #! MINGW ABI incompatibility disaster [ large-struct? ] [ mingw eq? os windows? not or ] bi* and ; +M: x86.32 %prepare-var-args ( -- ) ; + M:: x86.32 stack-cleanup ( stack-size return abi -- n ) #! a) Functions which are stdcall/fastcall/thiscall have to #! clean up the caller's stack frame. diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 0aad0382fd..fad1a747e6 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -140,6 +140,8 @@ M:: x86.64 %binary-float-function ( dst src1 src2 func -- ) func "libm" load-library f %c-invoke dst double-rep %load-return ; +M: x86.64 %prepare-var-args ( -- ) RAX RAX XOR ; + M: x86.64 stack-cleanup 3drop 0 ; M: x86.64 %cleanup 0 assert= ; diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index 16037dc62a..6442044d35 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -347,8 +347,8 @@ M: x86.64 has-small-reg? 2drop t ; :: (%convert-integer) ( dst src bits quot -- ) dst { src } bits [| new-dst | - new-dst dup bits n-bit-version-of dup src MOV - quot call + new-dst src int-rep %copy + new-dst dup bits n-bit-version-of quot call dst new-dst int-rep %copy ] with-small-register ; inline @@ -644,6 +644,7 @@ HOOK: %cleanup cpu ( n -- ) :: emit-alien-insn ( reg-inputs stack-inputs reg-outputs cleanup stack-size quot -- ) stack-inputs [ first3 %store-stack-param ] each reg-inputs [ first3 %store-reg-param ] each + %prepare-var-args quot call cleanup %cleanup reg-outputs [ first3 %load-reg-param ] each ; inline