From facd455e9229d54a916781b1de30549913d61459 Mon Sep 17 00:00:00 2001 From: sheeple Date: Thu, 12 Feb 2009 06:25:07 -0600 Subject: [PATCH] Working on complex float support in FFI on NetBSD --- basis/alien/structs/structs.factor | 5 +++-- basis/compiler/alien/alien.factor | 2 +- basis/cpu/architecture/architecture.factor | 2 +- basis/cpu/ppc/ppc.factor | 2 +- basis/cpu/x86/32/32.factor | 9 ++++++--- basis/cpu/x86/64/unix/unix.factor | 2 +- basis/cpu/x86/64/winnt/winnt.factor | 3 ++- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/basis/alien/structs/structs.factor b/basis/alien/structs/structs.factor index 8ec694198d..9c28b71cc6 100755 --- a/basis/alien/structs/structs.factor +++ b/basis/alien/structs/structs.factor @@ -13,7 +13,8 @@ fields { boxer-quot callable } { unboxer-quot callable } { getter callable } -{ setter callable } ; +{ setter callable } +return-in-registers ; M: struct-type heap-size size>> ; @@ -37,7 +38,7 @@ M: struct-type box-parameter [ %box-large-struct ] [ box-parameter ] if-value-struct ; : if-small-struct ( c-type true false -- ? ) - [ dup struct-small-enough? ] 2dip '[ f swap @ ] if ; inline + [ dup return-struct-in-registers? ] 2dip '[ f swap @ ] if ; inline M: struct-type unbox-return [ %unbox-small-struct ] [ %unbox-large-struct ] if-small-struct ; diff --git a/basis/compiler/alien/alien.factor b/basis/compiler/alien/alien.factor index 4a41014ab2..59901cf79a 100644 --- a/basis/compiler/alien/alien.factor +++ b/basis/compiler/alien/alien.factor @@ -5,7 +5,7 @@ alien.c-types alien.structs cpu.architecture ; IN: compiler.alien : large-struct? ( ctype -- ? ) - dup c-struct? [ struct-small-enough? not ] [ drop f ] if ; + dup c-struct? [ return-struct-in-registers? not ] [ drop f ] if ; : alien-parameters ( params -- seq ) dup parameters>> diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index 5670110f04..2c9675426b 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -152,7 +152,7 @@ HOOK: %loop-entry cpu ( -- ) HOOK: small-enough? cpu ( n -- ? ) ! Is this structure small enough to be returned in registers? -HOOK: struct-small-enough? cpu ( c-type -- ? ) +HOOK: return-struct-in-registers? cpu ( c-type -- ? ) ! Do we pass this struct by value or hidden reference? HOOK: value-struct? cpu ( c-type -- ? ) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index b177c71d77..f245bcb7e1 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -659,7 +659,7 @@ M: ppc %callback-value ( ctype -- ) M: ppc small-enough? ( n -- ? ) -32768 32767 between? ; -M: ppc struct-small-enough? ( size -- ? ) drop f ; +M: ppc return-struct-in-registers? ( c-type -- ? ) drop f ; M: ppc %box-small-struct drop "No small structs" throw ; diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index affd39ffc5..c409cfb164 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -48,9 +48,12 @@ M: x86.32 %alien-invoke (CALL) rel-dlsym ; M: x86.32 %alien-invoke-tail (JMP) rel-dlsym ; -M: x86.32 struct-small-enough? ( size -- ? ) - heap-size { 1 2 4 8 } member? - os { linux netbsd solaris } member? not and ; +M: x86.32 return-struct-in-registers? ( c-type -- ? ) + c-type + [ return-in-registers?>> ] + [ heap-size { 1 2 4 8 } member? ] bi + os { linux netbsd solaris } member? not + and and ; : struct-return@ ( n -- operand ) [ next-stack@ ] [ stack-frame get params>> stack@ ] if* ; diff --git a/basis/cpu/x86/64/unix/unix.factor b/basis/cpu/x86/64/unix/unix.factor index f5fb5b9640..eea960d03d 100644 --- a/basis/cpu/x86/64/unix/unix.factor +++ b/basis/cpu/x86/64/unix/unix.factor @@ -44,7 +44,7 @@ M: struct-type flatten-value-type ( type -- seq ) flatten-small-struct ] if ; -M: x86.64 struct-small-enough? ( size -- ? ) +M: x86.64 return-struct-in-registers? ( c-type -- ? ) heap-size 2 cells <= ; M: x86.64 dummy-stack-params? f ; diff --git a/basis/cpu/x86/64/winnt/winnt.factor b/basis/cpu/x86/64/winnt/winnt.factor index 4c6af6c1e7..8091be65ae 100644 --- a/basis/cpu/x86/64/winnt/winnt.factor +++ b/basis/cpu/x86/64/winnt/winnt.factor @@ -10,7 +10,8 @@ M: float-regs param-regs drop { XMM0 XMM1 XMM2 XMM3 } ; M: x86.64 reserved-area-size 4 cells ; -M: x86.64 struct-small-enough? heap-size { 1 2 4 8 } member? ; +M: x86.64 return-struct-in-registers? ( c-type -- ? ) + heap-size { 1 2 4 8 } member? ; M: x86.64 value-struct? heap-size { 1 2 4 8 } member? ;