 
 M: x86.64 %alien-callback ( quot -- )
     param-reg-1 swap %load-reference
-    "c_to_factor" %vm-invoke-2nd-arg ;
+    param-reg-2 %mov-vm-ptr
+    "c_to_factor" f %alien-invoke ;
 
 M: x86.64 %callback-value ( ctype -- )
     ! Save top of data stack

    param-reg-1 R14 [] MOV
    R14 cell SUB ;

: %vm-invoke-1st-arg ( function -- )
    param-reg-1 0 MOV rc-absolute-cell rt-vm rel-fixup
    f %alien-invoke ;

: %vm-invoke-2nd-arg ( function -- )
    param-reg-2 0 MOV rc-absolute-cell rt-vm rel-fixup
    f %alien-invoke ;

: %vm-invoke-3rd-arg ( function -- )
    param-reg-3 0 MOV rc-absolute-cell rt-vm rel-fixup
    f %alien-invoke ;

: %vm-invoke-4th-arg ( function -- )
    int-regs param-regs fourth 0 MOV rc-absolute-cell rt-vm rel-fixup
    f %alien-invoke ;


M:: x86.64 %unbox ( n rep func -- )
    ! Call the unboxer
    func %vm-invoke-2nd-arg
    ! Store the return value on the C stack if this is an
    ! alien-invoke, otherwise leave it the return register if
    ! this is the end of alien-callback

        [ param-reg-3 swap heap-size MOV ] bi
        param-reg-1 0 box-struct-field@ MOV
        param-reg-2 1 box-struct-field@ MOV
        param-reg-4 %mov-vm-ptr
        "box_small_struct" f %alien-invoke
    ] with-return-regs ;

: struct-return@ ( n -- operand )
