fixed up some alien boxing (x86 32 & 64)
parent
2e50da6beb
commit
4af25578d8
|
@ -133,7 +133,8 @@ M:: x86.32 %box ( n rep func -- )
|
||||||
|
|
||||||
M: x86.32 %box-long-long ( n func -- )
|
M: x86.32 %box-long-long ( n func -- )
|
||||||
[ (%box-long-long) ] dip
|
[ (%box-long-long) ] dip
|
||||||
8 [
|
8 vm-ptr-size + [
|
||||||
|
push-vm-ptr
|
||||||
EDX PUSH
|
EDX PUSH
|
||||||
EAX PUSH
|
EAX PUSH
|
||||||
f %alien-invoke
|
f %alien-invoke
|
||||||
|
@ -141,12 +142,13 @@ M: x86.32 %box-long-long ( n func -- )
|
||||||
|
|
||||||
M:: x86.32 %box-large-struct ( n c-type -- )
|
M:: x86.32 %box-large-struct ( n c-type -- )
|
||||||
! Compute destination address
|
! Compute destination address
|
||||||
ECX n struct-return@ LEA
|
EDX n struct-return@ LEA
|
||||||
8 [
|
8 vm-ptr-size + [
|
||||||
|
push-vm-ptr
|
||||||
! Push struct size
|
! Push struct size
|
||||||
c-type heap-size PUSH
|
c-type heap-size PUSH
|
||||||
! Push destination address
|
! Push destination address
|
||||||
ECX PUSH
|
EDX PUSH
|
||||||
! Copy the struct from the C stack
|
! Copy the struct from the C stack
|
||||||
"box_value_struct" f %alien-invoke
|
"box_value_struct" f %alien-invoke
|
||||||
] with-aligned-stack ;
|
] with-aligned-stack ;
|
||||||
|
@ -159,7 +161,8 @@ M: x86.32 %prepare-box-struct ( -- )
|
||||||
|
|
||||||
M: x86.32 %box-small-struct ( c-type -- )
|
M: x86.32 %box-small-struct ( c-type -- )
|
||||||
#! Box a <= 8-byte struct returned in EAX:EDX. OS X only.
|
#! Box a <= 8-byte struct returned in EAX:EDX. OS X only.
|
||||||
12 [
|
12 vm-ptr-size + [
|
||||||
|
push-vm-ptr
|
||||||
heap-size PUSH
|
heap-size PUSH
|
||||||
EDX PUSH
|
EDX PUSH
|
||||||
EAX PUSH
|
EAX PUSH
|
||||||
|
@ -200,7 +203,8 @@ M: x86.32 %unbox-long-long ( n func -- )
|
||||||
|
|
||||||
: %unbox-struct-1 ( -- )
|
: %unbox-struct-1 ( -- )
|
||||||
#! Alien must be in EAX.
|
#! Alien must be in EAX.
|
||||||
4 [
|
4 vm-ptr-size + [
|
||||||
|
push-vm-ptr
|
||||||
EAX PUSH
|
EAX PUSH
|
||||||
"alien_offset" f %alien-invoke
|
"alien_offset" f %alien-invoke
|
||||||
! Load first cell
|
! Load first cell
|
||||||
|
@ -209,7 +213,8 @@ M: x86.32 %unbox-long-long ( n func -- )
|
||||||
|
|
||||||
: %unbox-struct-2 ( -- )
|
: %unbox-struct-2 ( -- )
|
||||||
#! Alien must be in EAX.
|
#! Alien must be in EAX.
|
||||||
4 [
|
4 vm-ptr-size + [
|
||||||
|
push-vm-ptr
|
||||||
EAX PUSH
|
EAX PUSH
|
||||||
"alien_offset" f %alien-invoke
|
"alien_offset" f %alien-invoke
|
||||||
! Load second cell
|
! Load second cell
|
||||||
|
@ -228,12 +233,13 @@ M: x86 %unbox-small-struct ( size -- )
|
||||||
M:: x86.32 %unbox-large-struct ( n c-type -- )
|
M:: x86.32 %unbox-large-struct ( n c-type -- )
|
||||||
! Alien must be in EAX.
|
! Alien must be in EAX.
|
||||||
! Compute destination address
|
! Compute destination address
|
||||||
ECX n stack@ LEA
|
EDX n stack@ LEA
|
||||||
12 [
|
12 vm-ptr-size + [
|
||||||
|
push-vm-ptr
|
||||||
! Push struct size
|
! Push struct size
|
||||||
c-type heap-size PUSH
|
c-type heap-size PUSH
|
||||||
! Push destination address
|
! Push destination address
|
||||||
ECX PUSH
|
EDX PUSH
|
||||||
! Push source address
|
! Push source address
|
||||||
EAX PUSH
|
EAX PUSH
|
||||||
! Copy the struct to the stack
|
! Copy the struct to the stack
|
||||||
|
@ -241,7 +247,8 @@ M:: x86.32 %unbox-large-struct ( n c-type -- )
|
||||||
] with-aligned-stack ;
|
] with-aligned-stack ;
|
||||||
|
|
||||||
M: x86.32 %prepare-alien-indirect ( -- )
|
M: x86.32 %prepare-alien-indirect ( -- )
|
||||||
"unbox_alien" f %alien-invoke
|
push-vm-ptr "unbox_alien" f %alien-invoke
|
||||||
|
temp-reg POP
|
||||||
EBP EAX MOV ;
|
EBP EAX MOV ;
|
||||||
|
|
||||||
M: x86.32 %alien-indirect ( -- )
|
M: x86.32 %alien-indirect ( -- )
|
||||||
|
|
|
@ -202,7 +202,7 @@ M: x86.64 %alien-indirect ( -- )
|
||||||
|
|
||||||
M: x86.64 %alien-callback ( quot -- )
|
M: x86.64 %alien-callback ( quot -- )
|
||||||
param-reg-1 swap %load-reference
|
param-reg-1 swap %load-reference
|
||||||
"c_to_factor" f %alien-invoke ;
|
"c_to_factor" %vm-invoke-2nd-arg ;
|
||||||
|
|
||||||
M: x86.64 %callback-value ( ctype -- )
|
M: x86.64 %callback-value ( ctype -- )
|
||||||
! Save top of data stack
|
! Save top of data stack
|
||||||
|
@ -211,7 +211,7 @@ M: x86.64 %callback-value ( ctype -- )
|
||||||
RSP 8 SUB
|
RSP 8 SUB
|
||||||
param-reg-1 PUSH
|
param-reg-1 PUSH
|
||||||
! Restore data/call/retain stacks
|
! Restore data/call/retain stacks
|
||||||
"unnest_stacks" f %alien-invoke
|
"unnest_stacks" %vm-invoke-1st-arg
|
||||||
! Put former top of data stack in param-reg-1
|
! Put former top of data stack in param-reg-1
|
||||||
param-reg-1 POP
|
param-reg-1 POP
|
||||||
RSP 8 ADD
|
RSP 8 ADD
|
||||||
|
|
Loading…
Reference in New Issue