]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorDaniel Ehrenberg <littledan@pool-224-36.res.carleton.edu>
Wed, 20 Jan 2010 06:15:55 +0000 (00:15 -0600)
committerDaniel Ehrenberg <littledan@pool-224-36.res.carleton.edu>
Wed, 20 Jan 2010 06:15:55 +0000 (00:15 -0600)
Conflicts:

basis/compiler/tree/propagation/transforms/transforms.factor

1  2 
basis/compiler/tree/propagation/transforms/transforms.factor
core/math/integers/integers.factor

index b0605bfb356bfa0660d85410f0a104bc8a10ca86,63c0aea13ebf931dd8e197be625e6dd0c5f6f434..2d145ef74f637265b300fd14ad350f1ea6229433
@@@ -1,13 -1,14 +1,14 @@@
- ! Copyright (C) 2008, 2009 Slava Pestov, Daniel Ehrenberg.
+ ! Copyright (C) 2008, 2010 Slava Pestov, Daniel Ehrenberg.
  ! See http://factorcode.org/license.txt for BSD license.
- USING: kernel sequences words fry generic accessors
+ USING: alien.c-types kernel sequences words fry generic accessors
  classes.tuple classes classes.algebra definitions
- stack-checker.state quotations classes.tuple.private math
+ stack-checker.dependencies quotations classes.tuple.private math
  math.partial-dispatch math.private math.intervals sets.private
  math.floats.private math.integers.private layouts math.order
  vectors hashtables combinators effects generalizations assocs
- sets combinators.short-circuit sequences.private locals
+ sets combinators.short-circuit sequences.private locals growable
  stack-checker namespaces compiler.tree.propagation.info ;
+ FROM: math => float ;
  IN: compiler.tree.propagation.transforms
  
  \ equal? [
      ] "custom-inlining" set-word-prop
  ] each
  
- ! Integrate this with generic arithmetic optimization instead?
- : both-inputs? ( #call class -- ? )
-     [ in-d>> first2 ] dip '[ value-info class>> _ class<= ] both? ;
- \ min [
-     {
-         { [ dup fixnum both-inputs? ] [ [ fixnum-min ] ] }
-         { [ dup float both-inputs? ] [ [ float-min ] ] }
-         [ f ]
-     } cond nip
- ] "custom-inlining" set-word-prop
- \ max [
-     {
-         { [ dup fixnum both-inputs? ] [ [ fixnum-max ] ] }
-         { [ dup float both-inputs? ] [ [ float-max ] ] }
-         [ f ]
-     } cond nip
- ] "custom-inlining" set-word-prop
  ! Generate more efficient code for common idiom
  \ clone [
      in-d>> first value-info literal>> {
@@@ -208,7 -189,7 +189,7 @@@ ERROR: bad-partial-eval quot word 
  \ index [
      dup sequence? [
          dup length 4 >= [
-             dup length zip >hashtable '[ _ at ]
+             dup length iota zip >hashtable '[ _ at ]
          ] [ drop f ] if
      ] [ drop f ] if
  ] 1 define-partial-eval
@@@ -247,7 -228,7 +228,7 @@@ CONSTANT: lookup-table-at-max 25
      } 1&& ;
  
  : lookup-table-seq ( assoc -- table )
-     [ keys supremum 1 + ] keep '[ _ at ] { } map-as ;
+     [ keys supremum 1 + iota ] keep '[ _ at ] { } map-as ;
  
  : lookup-table-quot ( seq -- newquot )
      lookup-table-seq
  
  \ intersect [ intersect-quot ] 1 define-partial-eval
  
 +: fixnum-bits ( -- n )
 +    cell-bits tag-bits get - ;
 +
 +: bit-quot ( #call -- quot/f )
 +    in-d>> second value-info interval>> 0 fixnum-bits [a,b] interval-subset?
 +    [ [ >fixnum ] dip fixnum-bit? ] f ? ;
 +
 +\ bit? [ bit-quot ] "custom-inlining" set-word-prop
++
+ ! Speeds up sum-file, sort and reverse-complement benchmarks by
+ ! compiling decoder-readln better
+ \ push [
+     in-d>> second value-info class>> growable class<=
+     [ \ push def>> ] [ f ] if
+ ] "custom-inlining" set-word-prop
+ ! We want to constant-fold calls to heap-size, and recompile those
+ ! calls when a C type is redefined
+ \ heap-size [
+     dup word? [
+         [ inlined-dependency depends-on ] [ heap-size '[ _ ] ] bi
+     ] [ drop f ] if
+ ] 1 define-partial-eval
index e87d3a6a0db33f68954f8ce8af7db75226991f60,e95c6d832b4591606a6bd75c8c84a5f4260950f7..9f7543ca133d976f1ac9293a4a3baa78e45cd9a6
@@@ -1,8 -1,8 +1,8 @@@
- ! Copyright (C) 2004, 2009 Slava Pestov.
+ ! Copyright (C) 2004, 2010 Slava Pestov.
  ! Copyright (C) 2008, Doug Coleman.
  ! See http://factorcode.org/license.txt for BSD license.
- USING: kernel kernel.private sequences
sequences.private math math.private combinators ;
+ USING: kernel kernel.private sequences sequences.private math
math.private math.order combinators ;
  IN: math.integers.private
  
  : fixnum-min ( x y -- z ) [ fixnum< ] most ; foldable
@@@ -29,6 -29,9 +29,9 @@@ M: fixnum u<= fixnum<= ; inlin
  M: fixnum u> fixnum> ; inline
  M: fixnum u>= fixnum>= ; inline
  
+ M: fixnum min over fixnum? [ fixnum-min ] [ call-next-method ] if ; inline
+ M: fixnum max over fixnum? [ fixnum-max ] [ call-next-method ] if ; inline
  M: fixnum + fixnum+ ; inline
  M: fixnum - fixnum- ; inline
  M: fixnum * fixnum* ; inline
@@@ -55,10 -58,7 +58,10 @@@ M: fixnum shift >fixnum fixnum-shift ; 
  
  M: fixnum bitnot fixnum-bitnot ; inline
  
 -M: fixnum bit? neg shift 1 bitand 0 > ; inline
 +: fixnum-bit? ( n m -- b )
 +    neg shift 1 bitand 0 > ;
 +
 +M: fixnum bit? fixnum-bit? ; inline
  
  : fixnum-log2 ( x -- n )
      0 swap [ dup 1 eq? ] [ [ 1 + ] [ 2/ ] bi* ] until drop ;