diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 6f255893db..67a8ec8a2c 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -173,6 +173,9 @@ M: x86.32 %box-long-long ( n func -- ) [ (%box-long-long) ] [ f %alien-invoke ] bi* ] with-aligned-stack ; +: struct-return@ ( size n -- n ) + [ stack-frame* cell + + ] [ \ stack-frame get swap - ] ?if ; + M: x86.32 %box-large-struct ( n size -- ) ! Compute destination address [ swap struct-return@ ] keep diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 1eb4a7896b..4770c09a83 100755 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -116,6 +116,9 @@ M: x86.64 %box-small-struct ( size -- ) RDX swap MOV "box_small_struct" f %alien-invoke ; +: struct-return@ ( size n -- n ) + [ ] [ \ stack-frame get swap - ] ?if ; + M: x86.64 %box-large-struct ( n size -- ) ! Struct size is parameter 2 RSI over MOV diff --git a/basis/cpu/x86/architecture/architecture.factor b/basis/cpu/x86/architecture/architecture.factor index 13524aecc4..171e67bcfb 100755 --- a/basis/cpu/x86/architecture/architecture.factor +++ b/basis/cpu/x86/architecture/architecture.factor @@ -141,13 +141,6 @@ M: x86 small-enough? ( n -- ? ) : temp@ ( n -- op ) stack-reg \ stack-frame get rot - [+] ; -: struct-return@ ( size n -- n ) - [ - stack-frame* cell + + - ] [ - \ stack-frame get swap - - ] ?if ; - HOOK: %unbox-struct-1 cpu ( -- ) HOOK: %unbox-struct-2 cpu ( -- )