cpu.x86.64: fix calling varargs functions

db4
Slava Pestov 2010-07-19 16:03:39 -04:00
parent cc0d69416f
commit 0fbe78be00
3 changed files with 7 additions and 2 deletions

View File

@ -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.

View File

@ -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= ;

View File

@ -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