Fix problem with callbacks

db4
Slava Pestov 2008-04-17 04:14:42 -05:00
parent deb51fbd00
commit c00f89c38b
8 changed files with 1186 additions and 8 deletions

View File

@ -3,7 +3,7 @@ USING: alien alien.c-types alien.syntax compiler kernel
namespaces namespaces tools.test sequences inference words
arrays parser quotations continuations inference.backend effects
namespaces.private io io.streams.string memory system threads
tools.test ;
tools.test math ;
FUNCTION: void ffi_test_0 ;
[ ] [ ffi_test_0 ] unit-test
@ -354,3 +354,14 @@ FUNCTION: double ffi_test_36 ( test-struct-12 x ) ;
] alien-callback ;
[ ] [ callback-8 callback_test_1 ] unit-test
: callback-9
"int" { "int" "int" "int" } "cdecl" [
+ + 1+
] alien-callback ;
FUNCTION: int ffi_test_37 ( void* func ) ;
[ 1 ] [ callback-9 ffi_test_37 ] unit-test
[ 7 ] [ callback-9 ffi_test_37 ] unit-test

View File

@ -403,7 +403,6 @@ TUPLE: callback-context ;
: generate-callback ( node -- )
dup xt>> dup [
init-templates
%save-word-xt
%prologue-later
dup alien-stack-frame [
dup registers>objects

View File

@ -16,7 +16,6 @@ IN: cpu.x86.32
M: x86.32 ds-reg ESI ;
M: x86.32 rs-reg EDI ;
M: x86.32 stack-reg ESP ;
M: x86.32 xt-reg ECX ;
M: x86.32 stack-save-reg EDX ;
M: temp-reg v>operand drop EBX ;

View File

@ -11,7 +11,6 @@ IN: cpu.x86.64
M: x86.64 ds-reg R14 ;
M: x86.64 rs-reg R15 ;
M: x86.64 stack-reg RSP ;
M: x86.64 xt-reg RCX ;
M: x86.64 stack-save-reg RSI ;
M: temp-reg v>operand drop RBX ;

View File

@ -9,7 +9,6 @@ IN: cpu.x86.architecture
HOOK: ds-reg cpu
HOOK: rs-reg cpu
HOOK: stack-reg cpu
HOOK: xt-reg cpu
HOOK: stack-save-reg cpu
: stack@ stack-reg swap [+] ;

View File

@ -65,9 +65,7 @@ M: float-regs move-spec drop float ;
M: float-regs operand-class* drop float ;
! Temporary register for stack shuffling
TUPLE: temp-reg reg-class>> ;
: temp-reg T{ temp-reg f int-regs } ;
SINGLETON: temp-reg
M: temp-reg move-spec drop f ;

View File

@ -250,3 +250,13 @@ double ffi_test_36(struct test_struct_12 x)
{
return x.x;
}
int ffi_test_37(int (*f)(int, int, int))
{
static int global_var = 0;
printf("ffi_test_37\n");
global_var = f(global_var,global_var * 2,global_var * 3);
printf("global_var is %d\n",global_var);
fflush(stdout);
return global_var;
}

1163
vm/ffi_test.s Normal file

File diff suppressed because it is too large Load Diff