]> gitweb.factorcode.org Git - factor.git/commitdiff
Huge compiler patch; two new fixnum-fast and fixnum+fast primitives which do not...
authorslava <slava@factorcode.org>
Mon, 24 Apr 2006 21:52:03 +0000 (21:52 +0000)
committerslava <slava@factorcode.org>
Mon, 24 Apr 2006 21:52:03 +0000 (21:52 +0000)
20 files changed:
library/bootstrap/primitives.factor
library/collections/sequence-combinators.facts
library/compiler/intrinsics.factor
library/compiler/linearizer.factor
library/compiler/ppc/fixnum.factor
library/compiler/stack.factor
library/compiler/templates.factor
library/compiler/vops.factor
library/compiler/x86/fixnum.factor
library/inference/known-words.factor
library/inference/optimizer.factor
library/kernel.factor
library/test/benchmark/empty-loop.factor
library/test/benchmark/fib.factor
library/test/compiler/templates.factor
library/test/inference.factor
native/fixnum.c
native/fixnum.h
native/primitives.c
native/primitives.h

index ccad6ca33b102fb117b5fcc1ec781c892fe79138..fee3cec058d9500a475d467ee5ba471b51198249 100644 (file)
@@ -59,7 +59,9 @@ call
     { "bits>double" "math"                  }
     { "<complex>" "math-internals"          }
     { "fixnum+" "math-internals"            }
+    { "fixnum+fast" "math-internals"        }
     { "fixnum-" "math-internals"            }
+    { "fixnum-fast" "math-internals"        }
     { "fixnum*" "math-internals"            }
     { "fixnum/i" "math-internals"           }
     { "fixnum/f" "math-internals"           }
index fa38347f6c59ab4d2b67c85a2b15153612e1e87f..0b21654f742e76b41f3596b2b94724f9ec9cd655 100644 (file)
@@ -3,7 +3,7 @@ USING: help math sequences-internals ;
 
 HELP: collect "( n quot -- array )"
 { $values { "n" "a non-negative integer" } { "quot" "a quotation with stack effect " { $snippet "( n -- value )" } } { "array" "an array with " { $snippet "n" } " elements" } }
-{ $description "A primitive mapping operation that applies a quotation to all integers from 0 up to but not including " { $snippet "n" } ", and collects the results in a new array. Client code should use " { $snippet map } " instead." } ;
+{ $description "A primitive mapping operation that applies a quotation to all integers from 0 up to but not including " { $snippet "n" } ", and collects the results in a new array. Client code should use " { $link map } " instead." } ;
 
 HELP: each "( seq quot -- )"
 { $values { "seq" "a sequence" } { "quot" "a quotation with stack effect " { $snippet "( elt -- )" } } }
index 606bd61669f5182048098310f56b052d95947046..f1c77dc4711740da24192185c725c00b128b5784 100644 (file)
@@ -7,8 +7,8 @@ namespaces sequences words ;
 
 \ slot [
     H{
-        { +input-d { { f "obj" } { f "n" } } }
-        { +output-d { "obj" } }
+        { +input { { f "obj" } { f "n" } } }
+        { +output { "obj" } }
     } [
         "obj" get %untag ,
         "n" get "obj" get %slot ,
@@ -17,7 +17,7 @@ namespaces sequences words ;
 
 \ set-slot [
     H{
-        { +input-d { { f "val" } { f "obj" } { f "slot" } } }
+        { +input { { f "val" } { f "obj" } { f "slot" } } }
         { +clobber { "obj" } }
     } [
         "obj" get %untag ,
@@ -29,8 +29,8 @@ namespaces sequences words ;
 
 \ char-slot [
     H{
-        { +input-d { { f "n" } { f "str" } } }
-        { +output-d { "str" } }
+        { +input { { f "n" } { f "str" } } }
+        { +output { "str" } }
     } [
         "n" get "str" get %char-slot ,
     ] with-template
@@ -38,7 +38,7 @@ namespaces sequences words ;
 
 \ set-char-slot [
     H{
-        { +input-d { { f "ch" } { f "n" } { f "str" } } }
+        { +input { { f "ch" } { f "n" } { f "str" } } }
     } [
         "ch" get "str" get "n" get %set-char-slot ,
     ] with-template
@@ -46,22 +46,22 @@ namespaces sequences words ;
 
 \ type [
     H{
-        { +input-d { { f "in" } } }
-        { +output-d { "in" } }
+        { +input { { f "in" } } }
+        { +output { "in" } }
     } [ finalize-contents "in" get %type , ] with-template
 ] "intrinsic" set-word-prop
 
 \ tag [
     H{
-        { +input-d { { f "in" } } }
-        { +output-d { "in" } }
+        { +input { { f "in" } } }
+        { +output { "in" } }
     } [ "in" get %tag , ] with-template
 ] "intrinsic" set-word-prop
 
 : binary-op ( op -- )
     H{
-        { +input-d { { 0 "x" } { 1 "y" } } }
-        { +output-d { "x" } }
+        { +input { { 0 "x" } { 1 "y" } } }
+        { +output { "x" } }
     } [
         finalize-contents >r "y" get "x" get dup r> execute ,
     ] with-template ; inline
@@ -69,9 +69,6 @@ namespaces sequences words ;
 {
     { fixnum+       %fixnum+       }
     { fixnum-       %fixnum-       }
-    { fixnum-bitand %fixnum-bitand }
-    { fixnum-bitor  %fixnum-bitor  }
-    { fixnum-bitxor %fixnum-bitxor }
     { fixnum/i      %fixnum/i      }
     { fixnum*       %fixnum*       }
 } [
@@ -79,9 +76,28 @@ namespaces sequences words ;
     "intrinsic" set-word-prop
 ] each
 
+: binary-op-fast ( op -- )
+    H{
+        { +input { { f "x" } { f "y" } } }
+        { +output { "x" } }
+    } [
+        >r "y" get "x" get dup r> execute ,
+    ] with-template ; inline
+
+{
+    { fixnum-bitand %fixnum-bitand }
+    { fixnum-bitor  %fixnum-bitor  }
+    { fixnum-bitxor %fixnum-bitxor }
+    { fixnum+fast   %fixnum+fast   }
+    { fixnum-fast   %fixnum-fast   }
+} [
+    first2 [ binary-op-fast ] curry
+    "intrinsic" set-word-prop
+] each
+
 : binary-jump ( label op -- )
     H{
-        { +input-d { { f "x" } { f "y" } } }
+        { +input { { f "x" } { f "y" } } }
     } [
         end-basic-block >r >r "y" get "x" get r> r> execute ,
     ] with-template ; inline
@@ -102,8 +118,8 @@ namespaces sequences words ;
     ! hard-coded to put its output in vreg 2, which happends to
     ! be EDX there.
     H{
-        { +input-d { { 0 "x" } { 1 "y" } } }
-        { +output-d { "out" } }
+        { +input { { 0 "x" } { 1 "y" } } }
+        { +output { "out" } }
     } [
         finalize-contents
         T{ vreg f 2 } "out" set
@@ -114,8 +130,8 @@ namespaces sequences words ;
 \ fixnum/mod [
     ! See the remark on fixnum-mod for vreg usage
     H{
-        { +input-d { { 0 "x" } { 1 "y" } } }
-        { +output-d { "quo" "rem" } }
+        { +input { { 0 "x" } { 1 "y" } } }
+        { +output { "quo" "rem" } }
     } [
         finalize-contents
         T{ vreg f 0 } "quo" set
@@ -127,7 +143,7 @@ namespaces sequences words ;
 
 \ fixnum-bitnot [
     H{
-        { +input-d { { f "x" } } }
-        { +output-d { "x" } }
+        { +input { { f "x" } } }
+        { +output { "x" } }
     } [ "x" get dup %fixnum-bitnot , ] with-template
 ] "intrinsic" set-word-prop
index d7d2981b8ba51f843ec1fecd9fada404816d687a..1913736b8f598cea9271fb68c4fa09a10644b6e9 100644 (file)
@@ -100,7 +100,7 @@ M: #call-label linearize* ( node -- next )
 
 M: #if linearize* ( node -- next )
     H{
-        { +input-d { { 0 "flag" } } }
+        { +input { { 0 "flag" } } }
     } [
         end-basic-block
         <label> dup "flag" get %jump-t ,
@@ -110,7 +110,7 @@ M: #if linearize* ( node -- next )
     #! Output the jump table insn and return a list of
     #! label/branch pairs.
     H{
-        { +input-d { { 0 "n" } } }
+        { +input { { 0 "n" } } }
     } [ end-basic-block "n" get %dispatch , ] with-template
     node-children [ <label> dup %target-label ,  2array ] map ;
 
index 29941ab182d903073db87e74d73ad48f6da74256..f5e6b762a8b37c67eb3a3409dd96c3d23557accc 100644 (file)
@@ -23,6 +23,10 @@ math-internals memory namespaces words ;
 M: %fixnum+ generate-node ( vop -- )
     drop 0 MTXER >3-vop< ADDO. \ SUBF \ ADD simple-overflow ;
 
+M: %fixnum+fast generate-node ( vop -- ) drop >3-vop< ADD ;
+
+M: %fixnum-fast generate-node ( vop -- ) drop >3-vop< SUBF ;
+
 M: %fixnum- generate-node ( vop -- )
     drop 0 MTXER >3-vop< SUBFO. \ ADD \ SUBF simple-overflow ;
 
index 4e250abbda19b8255455665508927bc54caa9eda..2cfc2e5e8d857b94efbebde73647d4013beff5d6 100644 (file)
@@ -4,6 +4,11 @@ IN: compiler
 USING: arrays generic inference io kernel math
 namespaces prettyprint sequences vectors words ;
 
+: immediate? ( obj -- ? ) dup fixnum? swap not or ;
+
+: load-literal ( obj dest -- )
+    over immediate? [ %immediate ] [ %indirect ] if , ;
+
 : phantom-shuffle-input ( n phantom -- seq )
     2dup length <= [
         cut-phantom
@@ -33,7 +38,6 @@ M: #shuffle linearize* ( #shuffle -- )
     node-shuffle phantom-shuffle iterate-next ;
 
 : linearize-push ( node -- )
-    compute-free-vregs
     >#push< dup length dup ensure-vregs
     alloc-reg# [ <vreg> ] map
     [ [ load-literal ] 2each ] keep
index 3969dbd2abfe5ce0485cb0750ec38379fd2fc431..d54ee36e9c63ba0b608423a541eb7ca35364d233 100644 (file)
@@ -22,9 +22,14 @@ GENERIC: finalize-height ( n stack -- )
 
 GENERIC: <loc> ( n stack -- loc )
 
-: (loc) phantom-stack-height - ;
+: (loc)
+    #! Utility for methods on <loc>
+    phantom-stack-height - ;
 
 : (finalize-height) ( stack word -- )
+    #! We consolidate multiple stack height changes until the
+    #! last moment, and we emit the final height changing
+    #! instruction here.
     swap [
         phantom-stack-height
         dup zero? [ 2drop ] [ swap execute , ] if
@@ -52,12 +57,14 @@ M: phantom-callstack finalize-height
     \ %inc-r (finalize-height) ;
 
 : phantom-locs ( n phantom -- locs )
+    #! A sequence of n ds-locs or cs-locs indexing the stack.
     swap reverse-slice [ swap <loc> ] map-with ;
 
 : phantom-locs* ( phantom -- locs )
     dup length swap phantom-locs ;
 
 : adjust-phantom ( n phantom -- )
+    #! Change stack heiht.
     [ phantom-stack-height + ] keep set-phantom-stack-height ;
 
 GENERIC: cut-phantom ( n phantom -- seq )
@@ -72,15 +79,6 @@ SYMBOL: phantom-r
     <phantom-datastack> phantom-d set
     <phantom-callstack> phantom-r set ;
 
-: immediate? ( obj -- ? )
-    #! fixnums and f have a pointerless representation, and
-    #! are compiled immediately. Everything else can be moved
-    #! by GC, and is indexed through a table.
-    dup fixnum? swap f eq? or ;
-
-: load-literal ( obj dest -- )
-    over immediate? [ %immediate ] [ %indirect ] if , ;
-
 : finalize-heights ( -- )
     phantom-d get finalize-height
     phantom-r get finalize-height ;
@@ -198,51 +196,36 @@ SYMBOL: phantom-r
     [ reverse-slice ] 2apply
     t [ swap first compatible-values? and ] 2reduce ;
 
-: templates-match? ( template template -- ? )
-    phantom-r get template-match?
-    >r phantom-d get template-match? r> and ;
-
 : split-template ( template phantom -- slow fast )
     over length over length <=
     [ drop { } swap ] [ length swap cut* ] if ;
 
-: split-templates ( template template -- slow slow fast fast )
-    >r phantom-d get split-template r>
-    phantom-r get split-template swapd ;
+: match-template ( template -- slow fast )
+    phantom-d get 2dup template-match?
+    [ split-template ] [ drop { } ] if ;
 
-: match-templates ( template template -- slow slow fast fast )
-    2dup templates-match? [ split-templates ] [ { } { } ] if ;
-
-: (fast-input) ( template phantom -- )
+: fast-input ( template -- )
+    phantom-d get
     over length neg over adjust-phantom
     over length swap cut-phantom
     swap phantom-vregs ;
 
-: fast-input ( template template -- )
-    phantoms swapd (fast-input) (fast-input) ;
-
-: (slow-input) ( template phantom -- )
-    swap [ stack>vregs ] keep phantom-vregs ;
-
 : phantom-append ( seq stack -- )
     over length over adjust-phantom swap nappend ;
 
 : (template-outputs) ( seq stack -- )
-    phantoms swapd phantom-append phantom-append ;
+    phantoms swapd phantom-append phantom-append
+    compute-free-vregs ;
 
-SYMBOL: +input-d
-SYMBOL: +input-r
-SYMBOL: +output-d
-SYMBOL: +output-r
+SYMBOL: +input
+SYMBOL: +output
 SYMBOL: +scratch
 SYMBOL: +clobber
 
 : fix-spec ( spec -- spec )
     H{
-        { +input-d { } }
-        { +input-r { } }
-        { +output-d { } }
-        { +output-r { } }
+        { +input { } }
+        { +output { } }
         { +scratch { } }
         { +clobber { } }
     } swap hash-union ;
@@ -250,31 +233,38 @@ SYMBOL: +clobber
 : adjust-free-vregs ( -- )
     used-vregs free-vregs [ diff ] change ;
 
-: output-vregs ( -- seq )
-    { +output-d +output-r +clobber }
-    [ get [ get ] map ] map concat ;
+: output-vregs ( -- seq seq )
+    +output get +clobber get [ [ get ] map ] 2apply ;
 
-: finalize-contents? ( -- ? )
-    output-vregs phantoms append
+: outputs-clash? ( -- ? )
+    output-vregs append phantoms append
     [ swap member? ] contains-with? ;
 
-: slow-input ( template template -- )
-    2dup [ empty? not ] 2apply or finalize-contents? or
+: finalize-carefully ( -- )
+    #! If the phantom callstack has datastack locations on it,
+    #! we cannot rearrange the datastack and expect meaningful
+    #! results.
+    phantom-r get [ ds-loc? ] contains? [
+        finalize-contents
+    ] [
+        phantom-d get dup { } flush-locs vregs>stack
+    ] if ;
+
+: slow-input ( template -- )
+    dup empty?
+    [ finalize-carefully ] unless
+    outputs-clash?
     [ finalize-contents ] when
-    phantoms swapd (slow-input) (slow-input) ;
+    phantom-d get swap [ stack>vregs ] keep phantom-vregs ;
 
 : template-inputs ( -- )
-    +input-d get +input-r get
-    2dup additional-vregs# ensure-vregs
-    match-templates fast-input
-    adjust-free-vregs
-    slow-input ;
+    +input get dup { } additional-vregs# ensure-vregs
+    match-template fast-input adjust-free-vregs slow-input ;
 
 : template-outputs ( -- )
-    +output-d get +output-r get [ [ get ] map ] 2apply
-    (template-outputs) ;
+    +output get [ get ] map { } (template-outputs) ;
 
 : with-template ( spec quot -- )
-    swap fix-spec [
-        template-inputs call template-outputs
-    ] bind ; inline
+    swap fix-spec
+    [ template-inputs call template-outputs ] bind
+    compute-free-vregs ; inline
index d65a85bb10d17984fe44ab495d970ac919babf83..129b90b096d4146e3e9c99327b8c33573f489743 100644 (file)
@@ -215,8 +215,12 @@ C: %write-barrier make-vop ;
 ! fixnum intrinsics
 TUPLE: %fixnum+ ;
 C: %fixnum+ make-vop ;       : %fixnum+ 3-vop <%fixnum+> ;
+TUPLE: %fixnum+fast ;
+C: %fixnum+fast make-vop ;   : %fixnum+fast 3-vop <%fixnum+fast> ;
 TUPLE: %fixnum- ;
 C: %fixnum- make-vop ;       : %fixnum- 3-vop <%fixnum-> ;
+TUPLE: %fixnum-fast ;
+C: %fixnum-fast make-vop ;   : %fixnum-fast 3-vop <%fixnum-fast> ;
 TUPLE: %fixnum* ;
 C: %fixnum* make-vop ;       : %fixnum* 3-vop <%fixnum*> ;
 TUPLE: %fixnum-mod ;
index 0c365fad434428b64783b5c6808d263dd08f5d3e..8fee285fe601a913545b85c3bb9c51628519ffe7 100644 (file)
@@ -34,9 +34,13 @@ math math-internals memory namespaces words ;
 M: %fixnum+ generate-node ( vop -- )
     drop dest/src ADD  \ SUB \ ADD simple-overflow ;
 
+M: %fixnum+fast generate-node ( vop -- ) drop dest/src ADD ;
+
 M: %fixnum- generate-node ( vop -- )
     drop dest/src SUB  \ ADD \ SUB simple-overflow ;
 
+M: %fixnum-fast generate-node ( vop -- ) drop dest/src SUB ;
+
 M: %fixnum* generate-node ( vop -- )
     drop
     ! both inputs are tagged, so one of them needs to have its
index 1100ba8c1828e9b6c6454c2fd0f7201afde10f43..553b22a9914b6884361fb1d1cb5943edd818e519 100644 (file)
@@ -139,10 +139,18 @@ sequences strings vectors words prettyprint ;
 \ fixnum+ t "flushable" set-word-prop
 \ fixnum+ t "foldable" set-word-prop
 
+\ fixnum+fast [ [ fixnum fixnum ] [ fixnum ] ] "infer-effect" set-word-prop
+\ fixnum+fast t "flushable" set-word-prop
+\ fixnum+fast t "foldable" set-word-prop
+
 \ fixnum- [ [ fixnum fixnum ] [ integer ] ] "infer-effect" set-word-prop
 \ fixnum- t "flushable" set-word-prop
 \ fixnum- t "foldable" set-word-prop
 
+\ fixnum-fast [ [ fixnum fixnum ] [ fixnum ] ] "infer-effect" set-word-prop
+\ fixnum-fast t "flushable" set-word-prop
+\ fixnum-fast t "foldable" set-word-prop
+
 \ fixnum* [ [ fixnum fixnum ] [ integer ] ] "infer-effect" set-word-prop
 \ fixnum* t "flushable" set-word-prop
 \ fixnum* t "foldable" set-word-prop
index 3984ae8fd1a9946c913f0d8fdcad2f8be7aff553..ae4cc58a8289e0bae15d0ad0eff75d05ee37fb03 100644 (file)
@@ -24,14 +24,22 @@ GENERIC: optimize-node* ( node -- node/t )
         optimizer-changed get
     ] with-node-iterator [ optimize ] when ;
 
+: prune-if ( node quot -- successor/t )
+    over >r call [ r> node-successor ] [ r> drop t ] if ;
+    inline
+
 ! Generic nodes
 M: f optimize-node* drop t ;
 
 M: node optimize-node* ( node -- t ) drop t ;
 
+! #shuffle
+M: #shuffle optimize-node*  ( node -- node/t )
+    [ node-values empty? ] prune-if ;
+
 ! #push
 M: #push optimize-node*  ( node -- node/t )
-    dup node-out-d empty? [ node-successor ] [ drop t ] if ;
+    [ node-out-d empty? ] prune-if ;
 
 ! #return
 M: #return optimize-node* ( node -- node/t )
index 0a794759421770bb3659bb9f7fd4e04ec6c69ccb..aa0249b43b84507a705ea6083a2f4ae183083e02 100644 (file)
@@ -81,8 +81,8 @@ IN: kernel-internals
 ! These words are unsafe. Don't use them.
 
 : array-capacity 1 slot ; inline
-: array-nth swap 2 fixnum+ slot ; inline
-: set-array-nth swap 2 fixnum+ set-slot ; inline
+: array-nth swap 2 fixnum+fast slot ; inline
+: set-array-nth swap 2 fixnum+fast set-slot ; inline
 
 : make-tuple <tuple> [ 2 set-slot ] keep ; flushable
 
index b0de42a23b9c18c9ad46c5758c07583109c59207..8bdf3af9d100caa0645c36a167d6549bce7e685e 100644 (file)
@@ -1,5 +1,9 @@
 IN: temporary
-USING: compiler kernel math sequences test ;
+USING: compiler kernel math math-internals sequences test ;
+
+: empty-loop-0 ( n -- )
+    dup 0 fixnum< [ drop ] [ 1 fixnum-fast empty-loop-0 ] if ;
+    compiled
 
 : empty-loop-1 ( n -- )
     [ ] times ; compiled
@@ -10,6 +14,7 @@ USING: compiler kernel math sequences test ;
 : empty-loop-3 ( n -- )
     [ drop ] each ; compiled
 
+[ ] [ 5000000 empty-loop-0 ] unit-test
 [ ] [ 5000000 empty-loop-1 ] unit-test
 [ ] [ 5000000 empty-loop-2 ] unit-test
 [ ] [ 5000000 empty-loop-3 ] unit-test
index df554852107e4bb562f760493e9b6acc94d96b54..2b9e76e683c2decebfd5150a56c3acfcdc9e9fb2 100644 (file)
@@ -6,9 +6,20 @@ USE: test
 USE: math-internals
 USE: namespaces
 
-! Four fibonacci implementations, each one slower than the
+! Five fibonacci implementations, each one slower than the
 ! previous.
 
+: fast-fixnum-fib ( n -- nth fibonacci number )
+    dup 1 fixnum<= [
+        drop 1
+    ] [
+        1 fixnum-fast dup fast-fixnum-fib
+        swap 1 fixnum-fast fast-fixnum-fib fixnum+fast
+    ] if ;
+    compiled
+
+[ 9227465 ] [ 34 fast-fixnum-fib ] unit-test
+
 : fixnum-fib ( n -- nth fibonacci number )
     dup 1 fixnum<= [
         drop 1
index b6e14e93b22a90c65d26b31bae6811ebc3233abb..5dc1e92c37462fc36599abebeaab2d6376200ff9 100644 (file)
@@ -2,7 +2,7 @@
 
 IN: temporary
 USING: arrays compiler kernel kernel-internals math
-math-internals namespaces test ;
+math-internals namespaces sequences sequences-internals test ;
 
 ! Oops!
 [ 5000 ] [ [ 5000 ] compile-1 ] unit-test
@@ -41,6 +41,21 @@ unit-test
 [ 1/2 [ dup 0 slot swap 1 slot [ foo ] keep ] compile-1 ]
 unit-test
 
+[ 41 5 4 ] [
+    5/4 4/5 [
+        dup ratio? [
+            over ratio? [
+                2dup 2>fraction >r * swap r> * swap
+                + -rot denominator swap denominator
+            ] [
+                2drop f f f
+            ] if
+        ] [
+            2drop f f f
+        ] if
+    ] compile-1
+] unit-test
+
 : jxyz
     over bignum? [
         dup ratio? [
@@ -78,3 +93,31 @@ unit-test
     global [ 3 \ foo set ] bind
     \ foo [ global [ get ] bind ] compile-1
 ] unit-test
+
+[ 12 13 ] [
+    -12 -13 [ [ 0 swap fixnum-fast ] 2apply ] compile-1
+] unit-test
+
+[ -1 2 ] [ 1 2 [ >r 0 swap fixnum- r> ] compile-1 ] unit-test
+
+[ 12 13 ] [
+    -12 -13 [ [ 0 swap fixnum- ] 2apply ] compile-1
+] unit-test
+
+[ { t t } ] [
+    { t } { t } [
+        dup array-capacity [
+            2dup swap swap 2 fixnum+fast slot
+            >r pick swap 2 fixnum+fast slot r> 2array
+        ] collect 2nip
+    ] compile-1 first
+] unit-test
+
+[ { t t } ] [
+    { t } { t } [
+        dup array-capacity [
+            2dup swap swap 2 fixnum+ slot
+            >r pick swap 2 fixnum+ slot r> 2array
+        ] collect 2nip
+    ] compile-1 first
+] unit-test
index 3c5570d09bba6f1c5e4efdeed1bc2fe37637905d..27527dee779da269d2ae2cf1a237e3185d6ad543 100644 (file)
@@ -10,22 +10,6 @@ math-internals namespaces parser sequences test vectors ;
 
 [ t ] [ [ [ ] [ ] if ] dataflow dup [ [ ] map-nodes ] with-node-iterator = ] unit-test
 
-[
-    T{ shuffle f { "a" } { } { "a" } { "a" } }
-] [
-    T{ shuffle f { "a" } { } { "a" "a" } { } }
-    T{ shuffle f { "b" } { } { } { "b" } }
-    compose-shuffle
-] unit-test
-
-[
-    T{ shuffle f { "b" "a" } { } { "b" "b" } { } }
-] [
-    T{ shuffle f { "a" } { } { } { } }
-    T{ shuffle f { "b" } { } { "b" "b" } { } }
-    compose-shuffle
-] unit-test
-
 [ { 0 2 } ] [ [ 2 "Hello" ] infer ] unit-test
 [ { 1 2 } ] [ [ dup ] infer ] unit-test
 
index b23db2b15f1f7899b31f19d19867f1bb7eb4b7ef..ce90f4b233b0563d155350c0d52dc2d30ac4b878 100644 (file)
@@ -42,6 +42,13 @@ void primitive_fixnum_add(void)
        box_signed_cell(x + y);
 }
 
+void primitive_fixnum_add_fast(void)
+{
+       F_FIXNUM y = untag_fixnum_fast(dpop());
+       F_FIXNUM x = untag_fixnum_fast(dpop());
+       dpush(tag_fixnum(x + y));
+}
+
 void primitive_fixnum_subtract(void)
 {
        F_FIXNUM y = untag_fixnum_fast(dpop());
@@ -49,6 +56,13 @@ void primitive_fixnum_subtract(void)
        box_signed_cell(x - y);
 }
 
+void primitive_fixnum_subtract_fast(void)
+{
+       F_FIXNUM y = untag_fixnum_fast(dpop());
+       F_FIXNUM x = untag_fixnum_fast(dpop());
+       dpush(tag_fixnum(x - y));
+}
+
 /**
  * Multiply two integers, and trap overflow.
  * Thanks to David Blaikie (The_Vulture from freenode #java) for the hint.
index df60e52a566e1c84a1ee8246a6588cd7fe0d3d6e..99b4e686761d4bea39665c391fc7292df6c475cf 100644 (file)
@@ -13,6 +13,8 @@ void primitive_to_fixnum(void);
 
 void primitive_fixnum_add(void);
 void primitive_fixnum_subtract(void);
+void primitive_fixnum_add_fast(void);
+void primitive_fixnum_subtract_fast(void);
 void primitive_fixnum_multiply(void);
 void primitive_fixnum_divint(void);
 void primitive_fixnum_divfloat(void);
index 610e31d8927dcb85fb62dc7c83f4e97cdc3b1177..bd2ea1226d42dea756fe359567dcc885003604dc 100644 (file)
@@ -24,7 +24,9 @@ void* primitives[] = {
        primitive_bits_double,
        primitive_from_rect,
        primitive_fixnum_add,
+       primitive_fixnum_add_fast,
        primitive_fixnum_subtract,
+       primitive_fixnum_subtract_fast,
        primitive_fixnum_multiply,
        primitive_fixnum_divint,
        primitive_fixnum_divfloat,
@@ -191,8 +193,5 @@ void* primitives[] = {
 
 CELL primitive_to_xt(CELL primitive)
 {
-       if(primitive < 0 || primitive >= PRIMITIVE_COUNT)
-               return (CELL)undefined;
-       else
-               return (CELL)primitives[primitive];
+       return (CELL)primitives[primitive];
 }
index 809f0f05b50f6ce8230713960a6d4e860fe88ff7..2ed5cdc7685c3b90aad2809f3dad8a2f053f274b 100644 (file)
@@ -1,4 +1,3 @@
 extern void* primitives[];
-#define PRIMITIVE_COUNT 190
 
 CELL primitive_to_xt(CELL primitive);