G: load-literal ( obj vreg -- ) 1 standard-combination ;
! Set up caller stack frame (PowerPC and AMD64)
-: %prologue ( n -- ) drop ;
+: %prologue ( n -- ) drop ; inline
! Tear down stack frame (PowerPC and AMD64)
-: %epilogue ( n -- ) drop ;
+: %epilogue ( -- ) ; inline
! Tail call another word
DEFER: %jump ( label -- )
drop-return-reg ;
: %alien-callback ( quot -- )
- EAX swap load-literal
+ T{ vreg f 0 } load-literal
EAX PUSH
"run_callback" f %alien-invoke
EAX POP ;
! Restore data/callstacks
"unnest_stacks" f %alien-invoke
! Restore return register
- dup pop-return-reg ;
+ pop-return-reg ;
: %cleanup ( n -- ) dup zero? [ drop ] [ ESP swap ADD ] if ;
! Copyright (C) 2005, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-IN: compiler
USING: alien arrays assembler generic kernel kernel-internals
math memory namespaces sequences words ;
+IN: compiler
! x86 register assignments
! EAX, ECX, EDX vregs
: prepare-division CDQ ; inline
-M: immediate load-literal ( dest literal -- ) address MOV ;
+M: immediate load-literal ( literal vreg -- )
+ v>operand swap address MOV ;
-M: object load-literal ( dest literal -- )
+M: object load-literal ( literal vreg -- )
+ v>operand swap
add-literal [] MOV rel-absolute-cell rel-address ;
: (%call) ( label -- label )
! Add to jump table base. We use a temporary register since
! on AMD4 we have to load a 64-bit immediate. On x86, this
! is redundant.
- "scratch" get HEX: ffffffff MOV "end" get absolute-cell
- "n" operand "scratch" get ADD
+ "scratch" operand HEX: ffffffff MOV "end" get absolute-cell
+ "n" operand "scratch" operand ADD
! Jump to jump table entry
"n" operand [] JMP
! Align for better performance
: %replace ( vreg loc -- ) swap %peek ;
-: (%inc) cells dup 0 > [ ADD ] [ neg SUB ] if ;
+: (%inc) swap cells dup 0 > [ ADD ] [ neg SUB ] if ;
: %inc-d ( n -- ) ds-reg (%inc) ;