: dest/src ( vop -- dest src )
dup vop-out-1 v>operand swap vop-in-1 v>operand ;
+
+! These constants must match native/card.h
+: card-bits 7 ;
+: card-mark HEX: 80 ;
USING: alien compiler compiler-backend inference kernel
kernel-internals lists math memory namespaces words ;
+: compile-call-far ( addr -- ) 19 LOAD32 19 MTLR BLRL ;
+
M: %alien-invoke generate-node ( vop -- )
uncons load-library 2dup 1 rel-dlsym dlsym compile-call-far ;
: RLWINM 0 (RLWINM) ;
: RLWINM. 1 (RLWINM) ;
-: LWZ d-form 32 insn ;
-: STW d-form 36 insn ;
-: STWU d-form 37 insn ;
+: LBZ d-form 34 insn ; : LBZU d-form 35 insn ;
+: LHA d-form 42 insn ; : LHAU d-form 43 insn ;
+: LHZ d-form 40 insn ; : LHZU d-form 41 insn ;
+: LWZ d-form 32 insn ; : LWZU d-form 33 insn ;
+
+: STB d-form 38 insn ; : STBU d-form 39 insn ;
+: STH d-form 44 insn ; : STHU d-form 45 insn ;
+: STW d-form 36 insn ; : STWU d-form 37 insn ;
G: (B) ( dest aa lk -- ) [ pick ] [ type ] ;
M: integer (B) i-form 18 insn ;
! PowerPC register assignments
! r14 data stack
! r15 call stack
-! r16 callframe
-! r17 executing
-! r18-r30 vregs
+! r16-r30 vregs
M: integer v>operand tag-bits shift ;
-M: vreg v>operand vreg-n 18 + ;
+M: vreg v>operand vreg-n 17 + ;
M: %prologue generate-node ( vop -- )
- #! At the start of each word that calls a subroutine, we
- #! store the link register in r0, then push r0 on the C
- #! stack.
drop
1 1 -16 STWU
0 MFLR
dest/src 0 0 28 RLWINM ;
M: %dispatch generate-node ( vop -- )
- ! Compile a piece of code that jumps to an offset in a
- ! jump table indexed by the fixnum at the top of the stack.
- ! The jump table must immediately follow this macro.
drop
! POP-DS
18 18 1 SRAWI
kernel-internals lists math memory namespaces sequences words ;
M: %slot generate-node ( vop -- )
- #! the untagged object is in vop-out-1, the tagged slot
- #! number is in vop-in-1.
dest/src
! turn tagged fixnum slot # into an offset, multiple of 4
dup dup 1 SRAWI
dup 0 LWZ ;
M: %fast-slot generate-node ( vop -- )
- #! the tagged object is in vop-out-1, the pointer offset is
- #! in vop-in-1. the offset already takes the type tag
- #! into account, so its just one instruction to load.
dup vop-out-1 v>operand dup rot vop-in-1 LWZ ;
+: write-barrier ( reg -- )
+ #! Mark the card pointed to by vreg.
+ dup dup card-bits SRAWI
+ dup dup 16 ADD
+ 20 over 0 LBZ
+ 20 20 card-mark ORI
+ 20 swap 0 STB ;
+
+M: %set-slot generate-node ( vop -- )
+ dup vop-in-3 v>operand over vop-in-2 v>operand
+ ! turn tagged fixnum slot # into an offset, multiple of 4
+ over dup 1 SRAWI
+ ! compute slot address in vop-in-2
+ over dup pick ADD
+ ! store new slot value
+ >r >r vop-in-1 v>operand r> 0 STW r> write-barrier ;
+
+M: %fast-set-slot generate-node ( vop -- )
+ dup vop-in-1 v>operand over vop-in-2 v>operand
+ [ rot vop-in-3 STW ] keep write-barrier ;
+
: userenv ( reg -- )
#! Load the userenv pointer in a virtual register.
"userenv" f dlsym swap LOAD32 0 1 rel-userenv ;
ESP 8 ADD ;
M: %cleanup generate-node
- #! In the cdecl ABI, the caller must pop input parameters
- #! off the C stack. In stdcall, the callee does it, so
- #! this node is not used in that case.
vop-in-1 dup 0 = [ drop ] [ ESP swap ADD ] ifte ;
kernel-internals lists math memory namespaces sequences words ;
M: %slot generate-node ( vop -- )
- #! the untagged object is in vop-out-1, the tagged slot
- #! number is in vop-in-1.
dest/src
! turn tagged fixnum slot # into an offset, multiple of 4
dup 1 SHR
dup unit MOV ;
M: %fast-slot generate-node ( vop -- )
- #! the tagged object is in vop-out-1, the pointer offset is
- #! in vop-in-1. the offset already takes the type tag
- #! into account, so its just one instruction to load.
dup vop-in-1 swap vop-out-1 v>operand tuck >r 2list r>
swap MOV ;
-: card-bits
- #! must be the same as CARD_BITS in native/cards.h.
- 7 ;
-
: card-offset 1 getenv ;
-: card-mark HEX: 80 ;
: write-barrier ( reg -- )
#! Mark the card pointed to by vreg.
0 rel-cards ;
M: %set-slot generate-node ( vop -- )
- #! the new value is vop-in-1, the object is vop-in-2, and
- #! the slot number is vop-in-3.
dup vop-in-3 v>operand over vop-in-2 v>operand
! turn tagged fixnum slot # into an offset, multiple of 4
over 1 SHR
write-barrier ;
M: %fast-set-slot generate-node ( vop -- )
- #! the new value is vop-in-1, the object is vop-in-2, and
- #! the slot offset is vop-in-3.
- #! the offset already takes the type tag into account, so
- #! it's just one instruction to load.
dup vop-in-3 over vop-in-2 v>operand
[ swap 2list swap vop-in-1 v>operand MOV ] keep
write-barrier ;
#define CARD_MARK_MASK 0x80
#define CARD_BASE_MASK 0x7f
typedef u8 CARD;
-CARD *cards;
+
+#ifdef FACTOR_PPC
+ register CARD *cards asm("r16");
+#else
+ CARD *cards;
+#endif
+
CARD *cards_end;
/* A card is 16 bytes (128 bits), 5 address bits per card.
#endif
/* TAGGED currently executing quotation */
-#if defined(FACTOR_PPC)
- register CELL callframe asm("r16");
-#else
- CELL callframe;
-#endif
+CELL callframe;
/* TAGGED pointer to currently executing word */
-#if defined(FACTOR_PPC)
- register CELL executing asm("r17");
-#else
- CELL executing;
-#endif
+CELL executing;
#include <errno.h>
#include <fcntl.h>