]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor into simd-cleanup
authorJoe Groff <arcata@gmail.com>
Sun, 15 Nov 2009 03:02:39 +0000 (21:02 -0600)
committerJoe Groff <arcata@gmail.com>
Sun, 15 Nov 2009 03:02:39 +0000 (21:02 -0600)
Conflicts:
basis/math/vectors/simd/functor/functor.factor

1  2 
basis/classes/struct/struct.factor
basis/compiler/cfg/intrinsics/intrinsics.factor
basis/compiler/tree/propagation/known-words/known-words.factor
basis/cpu/x86/x86.factor
core/sequences/sequences.factor

index f86f3c9d972b735ed7b4023ff604e601eb0d22a2,c7dd3fb50516d455e45ec255e155cf596592365f..09de4ac8bc5954ebf9466b22f3a81a060d6417bf
@@@ -189,6 -189,9 +189,6 @@@ M: struct-c-type c-struct? drop t 
      \ cleave [ ] 2sequence
      \ output>array [ ] 2sequence ;
  
 -: define-inline-method ( class generic quot -- )
 -    [ create-method-in ] dip [ define ] [ drop make-inline ] 2bi ;
 -
  : (define-struct-slot-values-method) ( class -- )
      [ \ struct-slot-values ] [ struct-slot-values-quot ] bi
      define-inline-method ;
          slots >>fields
          size >>size
          align >>align
+         align >>align-first
          class (unboxer-quot) >>unboxer-quot
-         class (boxer-quot)   >>boxer-quot ;
-     
- GENERIC: align-offset ( offset class -- offset' )
+         class (boxer-quot) >>boxer-quot ;
  
- M: struct-slot-spec align-offset
-     [ type>> c-type-align 8 * align ] keep
+ GENERIC: compute-slot-offset ( offset class -- offset' )
+ : c-type-align-at ( class offset -- n )
+     0 = [ c-type-align-first ] [ c-type-align ] if ;
+ M: struct-slot-spec compute-slot-offset
+     [ type>> over c-type-align-at 8 * align ] keep
      [ [ 8 /i ] dip (>>offset) ] [ type>> heap-size 8 * + ] 2bi ;
  
- M: struct-bit-slot-spec align-offset
+ M: struct-bit-slot-spec compute-slot-offset
      [ (>>offset) ] [ bits>> + ] 2bi ;
  
- : struct-offsets ( slots -- size )
-     0 [ align-offset ] reduce 8 align 8 /i ;
+ : compute-struct-offsets ( slots -- size )
+     0 [ compute-slot-offset ] reduce 8 align 8 /i ;
  
- : union-struct-offsets ( slots -- size )
+ : compute-union-offsets ( slots -- size )
      1 [ 0 >>offset type>> heap-size max ] reduce ;
  
- : struct-align ( slots -- align )
+ : struct-alignment ( slots -- align )
      [ struct-bit-slot-spec? not ] filter
-     1 [ type>> c-type-align max ] reduce ;
+     1 [ [ type>> ] [ offset>> ] bi c-type-align-at max ] reduce ;
  PRIVATE>
  
  M: struct byte-length class "struct-size" word-prop ; foldable
@@@ -240,10 -248,8 +245,8 @@@ GENERIC: binary-zero? ( value -- ? 
  
  M: object binary-zero? drop f ;
  M: f binary-zero? drop t ;
- M: number binary-zero? zero? ;
- M: struct binary-zero?
-     [ byte-length iota ] [ >c-ptr ] bi
-     [ <displaced-alien> *uchar zero? ] curry all? ;
+ M: number binary-zero? 0 = ;
+ M: struct binary-zero? >c-ptr [ 0 = ] all? ;
  
  : struct-needs-prototype? ( class -- ? )
      struct-slots [ initial>> binary-zero? ] all? not ;
      slots empty? [ struct-must-have-slots ] when
      class redefine-struct-tuple-class
      slots make-slots dup check-struct-slots :> slot-specs
-     slot-specs struct-align :> alignment
+     slot-specs struct-alignment :> alignment
      slot-specs offsets-quot call alignment align :> size
  
      class  slot-specs  size  alignment  c-type-for-class :> c-type
  PRIVATE>
  
  : define-struct-class ( class slots -- )
-     [ struct-offsets ] (define-struct-class) ;
+     [ compute-struct-offsets ] (define-struct-class) ;
  
  : define-union-struct-class ( class slots -- )
-     [ union-struct-offsets ] (define-struct-class) ;
+     [ compute-union-offsets ] (define-struct-class) ;
  
  M: struct-class reset-class
      [ call-next-method ] [ name>> c-types get delete-at ] bi ;
index f4bbcdb25594742a568835df5d063de5591364bd,f40b838b97214f6cac38672e0a646eaed3d243d3..e8c93899cb71c25d64ffef1699c531cb0ae0a545
@@@ -7,6 -7,7 +7,6 @@@ compiler.cfg.intrinsics.alie
  compiler.cfg.intrinsics.allot
  compiler.cfg.intrinsics.fixnum
  compiler.cfg.intrinsics.float
 -compiler.cfg.intrinsics.simd
  compiler.cfg.intrinsics.slots
  compiler.cfg.intrinsics.misc
  compiler.cfg.comparisons ;
@@@ -22,6 -23,7 +22,6 @@@ QUALIFIED: classes.tuple.privat
  QUALIFIED: math.private
  QUALIFIED: math.integers.private
  QUALIFIED: math.floats.private
 -QUALIFIED: math.vectors.simd.intrinsics
  QUALIFIED: math.libm
  IN: compiler.cfg.intrinsics
  
@@@ -31,6 -33,7 +31,7 @@@
  {
      { kernel.private:tag [ drop emit-tag ] }
      { kernel.private:getenv [ emit-getenv ] }
+     { kernel.private:(identity-hashcode) [ drop emit-identity-hashcode ] }
      { math.private:both-fixnums? [ drop emit-both-fixnums? ] }
      { math.private:fixnum+ [ drop emit-fixnum+ ] }
      { math.private:fixnum- [ drop emit-fixnum- ] }
          { math.integers.private:fixnum-log2 [ drop emit-fixnum-log2 ] }
      } enable-intrinsics ;
  
 -: enable-simd ( -- )
 -    {
 -        { math.vectors.simd.intrinsics:assert-positive [ drop ] }
 -        { math.vectors.simd.intrinsics:(simd-v+) [ [ ^^add-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vs+) [ [ ^^saturated-add-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-v+-) [ [ ^^add-sub-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-v-) [ [ ^^sub-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vs-) [ [ ^^saturated-sub-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vneg) [ [ generate-neg-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-v*) [ [ ^^mul-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vs*) [ [ ^^saturated-mul-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-v/) [ [ ^^div-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vmin) [ [ generate-min-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vmax) [ [ generate-max-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-v.) [ [ ^^dot-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vabs) [ [ generate-abs-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vsqrt) [ [ ^^sqrt-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vbitand) [ [ ^^and-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vbitandn) [ [ ^^andn-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vbitor) [ [ ^^or-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vbitxor) [ [ ^^xor-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vbitnot) [ [ generate-not-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vand) [ [ ^^and-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vandn) [ [ ^^andn-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vor) [ [ ^^or-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vxor) [ [ ^^xor-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vnot) [ [ generate-not-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-v<=) [ [ cc<= generate-compare-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-v<) [ [ cc< generate-compare-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-v=) [ [ cc= generate-compare-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-v>) [ [ cc> generate-compare-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-v>=) [ [ cc>= generate-compare-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vunordered?) [ [ cc/<>= generate-compare-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vany?) [ [ vcc-any ^^test-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vall?) [ [ vcc-all ^^test-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vnone?) [ [ vcc-none ^^test-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vlshift) [ [ ^^shl-vector-imm ] [ ^^shl-vector ] emit-shift-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-vrshift) [ [ ^^shr-vector-imm ] [ ^^shr-vector ] emit-shift-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-hlshift) [ [ ^^horizontal-shl-vector-imm ] emit-shift-vector-imm-op ] }
 -        { math.vectors.simd.intrinsics:(simd-hrshift) [ [ ^^horizontal-shr-vector-imm ] emit-shift-vector-imm-op ] }
 -        { math.vectors.simd.intrinsics:(simd-with) [ [ ^^with-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-gather-2) [ emit-gather-vector-2 ] }
 -        { math.vectors.simd.intrinsics:(simd-gather-4) [ emit-gather-vector-4 ] }
 -        { math.vectors.simd.intrinsics:(simd-vshuffle-elements) [ emit-shuffle-vector ] }
 -        { math.vectors.simd.intrinsics:(simd-vshuffle-bytes) [ emit-shuffle-vector-var ] }
 -        { math.vectors.simd.intrinsics:(simd-(vmerge-head)) [ [ ^^merge-vector-head ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-(vmerge-tail)) [ [ ^^merge-vector-tail ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-(v>float)) [ [ ^^integer>float-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-(v>integer)) [ [ ^^float>integer-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-(vpack-signed)) [ [ ^^signed-pack-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-(vpack-unsigned)) [ [ ^^unsigned-pack-vector ] emit-binary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-(vunpack-head)) [ [ generate-unpack-vector-head ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-(vunpack-tail)) [ [ generate-unpack-vector-tail ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:(simd-select) [ emit-select-vector ] }
 -        { math.vectors.simd.intrinsics:(simd-sum) [ [ ^^horizontal-add-vector ] emit-unary-vector-op ] }
 -        { math.vectors.simd.intrinsics:alien-vector [ emit-alien-vector ] }
 -        { math.vectors.simd.intrinsics:set-alien-vector [ emit-set-alien-vector ] }
 -    } enable-intrinsics ;
 -
  : emit-intrinsic ( node word -- )
      "intrinsic" word-prop call( node -- ) ;
index 6e906e685a2df2bf8cb6aa861078bb86b2ce3848,1453bebf9aa30f78ae48667619da8fa8d369aa07..0fde7ffa86d1b154389be7b923f61f93c5221c6c
@@@ -8,7 -8,7 +8,7 @@@ classes.algebra combinators generic.mat
  classes.tuple alien.accessors classes.tuple.private
  slots.private definitions strings.private vectors hashtables
  generic quotations alien
- stack-checker.state
+ stack-checker.dependencies
  compiler.tree.comparisons
  compiler.tree.propagation.info
  compiler.tree.propagation.nodes
@@@ -16,7 -16,8 +16,7 @@@ compiler.tree.propagation.slot
  compiler.tree.propagation.simple
  compiler.tree.propagation.constraints
  compiler.tree.propagation.call-effect
 -compiler.tree.propagation.transforms
 -compiler.tree.propagation.simd ;
 +compiler.tree.propagation.transforms ;
  FROM: alien.c-types => (signed-interval) (unsigned-interval) ;
  IN: compiler.tree.propagation.known-words
  
diff --combined basis/cpu/x86/x86.factor
index 0de9e7d1e49ff7490176971297beefbf21851f22,d78d05bac75c51d04cdec4a368768c099e28d230..a55489dcee0b9af0ca3c782fd44549d99a5b2280
@@@ -430,7 -430,7 +430,7 @@@ M: x86 %vm-field-ptr ( dst field -- 
      [ [] ] dip data-alignment get align ADD ;
  
  : store-header ( temp class -- )
-     [ [] ] [ type-number tag-fixnum ] bi* MOV ;
+     [ [] ] [ type-number tag-header ] bi* MOV ;
  
  : store-tagged ( dst tag -- )
      type-number OR ;
@@@ -1162,28 -1162,34 +1162,28 @@@ M: x86 %max-vector-rep
  M: x86 %dot-vector
      [ two-operand ] keep
      {
 -        { float-4-rep [
 -            sse4.1?
 -            [ HEX: ff DPPS ]
 -            [ [ MULPS ] [ drop dup float-4-rep %horizontal-add-vector ] 2bi ]
 -            if
 -        ] }
 -        { double-2-rep [
 -            sse4.1?
 -            [ HEX: ff DPPD ]
 -            [ [ MULPD ] [ drop dup double-2-rep %horizontal-add-vector ] 2bi ]
 -            if
 -        ] }
 +        { float-4-rep [ HEX: ff DPPS ] }
 +        { double-2-rep [ HEX: ff DPPD ] }
      } case ;
  
  M: x86 %dot-vector-reps
      {
 -        { sse3? { float-4-rep double-2-rep } }
 +        { sse4.1? { float-4-rep double-2-rep } }
      } available-reps ;
  
 -M: x86 %horizontal-add-vector ( dst src rep -- )
 -    {
 -        { float-4-rep [ [ float-4-rep %copy ] [ HADDPS ] [ HADDPS ] 2tri ] }
 -        { double-2-rep [ [ double-2-rep %copy ] [ HADDPD ] 2bi ] }
 +M: x86 %horizontal-add-vector ( dst src1 src2 rep -- )
 +    [ two-operand ] keep
 +    unsign-rep {
 +        { float-4-rep  [ HADDPS ] }
 +        { double-2-rep [ HADDPD ] }
 +        { int-4-rep    [ PHADDD ] }
 +        { short-8-rep  [ PHADDW ] }
      } case ;
  
  M: x86 %horizontal-add-vector-reps
      {
          { sse3? { float-4-rep double-2-rep } }
 +        { ssse3? { int-4-rep uint-4-rep short-8-rep ushort-8-rep } }
      } available-reps ;
  
  M: x86 %horizontal-shl-vector-imm ( dst src1 src2 rep -- )
  
  M: x86 %horizontal-shl-vector-imm-reps
      {
 -        { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
 +        { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep float-4-rep double-2-rep } }
      } available-reps ;
  
  M: x86 %horizontal-shr-vector-imm ( dst src1 src2 rep -- )
  
  M: x86 %horizontal-shr-vector-imm-reps
      {
 -        { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
 +        { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep float-4-rep double-2-rep } }
      } available-reps ;
  
  M: x86 %abs-vector ( dst src rep -- )
@@@ -1395,6 -1401,7 +1395,6 @@@ M: x86 immediate-bitwise? ( n -- ? 
      #! set up by the caller.
      stack-frame get total-size>> + stack@ ;
  
 -enable-simd
  enable-min/max
  enable-fixnum-log2
  
index e8c24a3b96ab4bbcc80b1ff7821fee3e82669471,5017e52ce577fa6c49297b9545c9cc94b3f9ea34..16949f5542da48d43daba98dfbaff786e7a655c2
@@@ -182,15 -182,15 +182,15 @@@ PRIVATE
      2dup bounds-check? [ nth-unsafe ] [ 2drop f ] if ; inline
  
  MIXIN: virtual-sequence
- GENERIC: virtual-seq ( seq -- seq' )
+ GENERIC: virtual-exemplar ( seq -- seq' )
  GENERIC: virtual@ ( n seq -- n' seq' )
  
  M: virtual-sequence nth virtual@ nth ; inline
  M: virtual-sequence set-nth virtual@ set-nth ; inline
  M: virtual-sequence nth-unsafe virtual@ nth-unsafe ; inline
  M: virtual-sequence set-nth-unsafe virtual@ set-nth-unsafe ; inline
- M: virtual-sequence like virtual-seq like ; inline
- M: virtual-sequence new-sequence virtual-seq new-sequence ; inline
+ M: virtual-sequence like virtual-exemplar like ; inline
+ M: virtual-sequence new-sequence virtual-exemplar new-sequence ; inline
  
  INSTANCE: virtual-sequence sequence
  
@@@ -199,7 -199,7 +199,7 @@@ TUPLE: reversed { seq read-only } 
  
  C: <reversed> reversed
  
- M: reversed virtual-seq seq>> ; inline
+ M: reversed virtual-exemplar seq>> ; inline
  M: reversed virtual@ seq>> [ length swap - 1 - ] keep ; inline
  M: reversed length seq>> length ; inline
  
@@@ -231,7 -231,7 +231,7 @@@ TUPLE: slice-error from to seq reason 
      check-slice
      slice boa ; inline
  
- M: slice virtual-seq seq>> ; inline
+ M: slice virtual-exemplar seq>> ; inline
  
  M: slice virtual@ [ from>> + ] [ seq>> ] bi ; inline
  
@@@ -659,9 -659,9 +659,9 @@@ PRIVATE
          [ 0 swap copy ] keep
      ] new-like ;
  
- : suffix! ( seq elt -- seq ) over push ;
+ : suffix! ( seq elt -- seq ) over push ; inline
  
- : append! ( seq1 seq2 -- seq1 ) over push-all ;
+ : append! ( seq1 seq2 -- seq1 ) over push-all ; inline
  
  : last ( seq -- elt ) [ length 1 - ] [ nth ] bi ;
  
@@@ -929,8 -929,7 +929,8 @@@ PRIVATE
  : trim ( seq quot -- newseq )
      [ trim-slice ] [ drop ] 2bi like ; inline
  
 -: sum ( seq -- n ) 0 [ + ] binary-reduce ;
 +GENERIC: sum ( seq -- n )
 +M: object sum 0 [ + ] binary-reduce ; inline
  
  : product ( seq -- n ) 1 [ * ] binary-reduce ;