]> gitweb.factorcode.org Git - factor.git/commitdiff
more PowerPC vops
authorSlava Pestov <slava@factorcode.org>
Mon, 30 May 2005 04:21:17 +0000 (04:21 +0000)
committerSlava Pestov <slava@factorcode.org>
Mon, 30 May 2005 04:21:17 +0000 (04:21 +0000)
library/compiler/generator.factor
library/compiler/ppc/alien.factor
library/compiler/ppc/assembler.factor
library/compiler/ppc/generator.factor
library/compiler/ppc/slots.factor
library/compiler/x86/alien.factor
library/compiler/x86/slots.factor
native/cards.h
native/factor.h

index 0615b9d602a980a3992450e0379ca5df6dfbef83..b23bea0e75846652b742e3b719b74adccffd3ca6 100644 (file)
@@ -61,3 +61,7 @@ GENERIC: v>operand
 
 : 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 ;
index 97bc3a1354c8a77255f34f5a29064cf9b7da8442..d6edcfd9a753e298d8ef515e3a95e5d6486301a7 100644 (file)
@@ -4,6 +4,8 @@ IN: assembler
 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 ;
 
index a9631eae0e6fec70bc4dd3b412ed5781ab6a67ba..d75c2d9b48aa0bbc857b935400168f113eda69cc 100644 (file)
@@ -133,9 +133,14 @@ USING: compiler errors kernel math memory words ;
 : 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 ;
index da8ebec717b53225dcc63c521e36942be7d3cacd..67ee456ac346a57ebe27984ddb80258462826e50 100644 (file)
@@ -7,17 +7,12 @@ lists math memory words ;
 ! 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
@@ -83,9 +78,6 @@ M: %untag generate-node ( vop -- )
     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
index 50ee3a803689a668e01a33f281d6ee0ab6bd4024..1458e6cc571383b28264c86e00ea618231a35d0b 100644 (file)
@@ -5,8 +5,6 @@ USING: alien assembler compiler inference kernel
 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
@@ -16,11 +14,29 @@ M: %slot generate-node ( vop -- )
     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 ;
index b26661c1ff529256e1e471ff4d619bd813526b4c..c5cda701dc0826a5e09b69a8f053855604a53eac 100644 (file)
@@ -75,7 +75,4 @@ M: %box-double generate-node
     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 ;
index 12f1fd775b5e3fac385565bd3cfd62adb9a0e0ea..f5c5dacdf300e31e9d57d5b63152d1bb1a5a19fe 100644 (file)
@@ -5,8 +5,6 @@ USING: alien assembler compiler inference kernel
 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
@@ -16,18 +14,10 @@ M: %slot generate-node ( vop -- )
     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.
@@ -36,8 +26,6 @@ M: %fast-slot generate-node ( vop -- )
     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
@@ -48,10 +36,6 @@ M: %set-slot generate-node ( vop -- )
     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 ;
index f1e4bcab7af192a6b78d737bb14f90f7eb3a56a3..94f97f73fc423108825188f89f58a7086518161c 100644 (file)
@@ -12,7 +12,13 @@ the offset of the first object is set by the allocator.
 #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.
index 386b350f69fa78d3f068fdbd738b51d10daf10fe..1f3b28ca61336583763cfecdab741c3de3d70d5e 100644 (file)
@@ -36,18 +36,10 @@ CELL cs_bot;
 #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>