\ +-integer-fixnum inlined?
] unit-test
-
-[ t ] [
- [ { string sbuf } declare ] \ push-all def>> append \ + inlined?
-] unit-test
-
-[ t ] [
- [ { string sbuf } declare ] \ push-all def>> append \ fixnum+ inlined?
-] unit-test
-
-[ t ] [
- [ { string sbuf } declare ] \ push-all def>> append \ >fixnum inlined?
-] unit-test
-
[ t ] [
[ { array-capacity } declare 0 < ] \ < inlined?
] unit-test
M: fixnum annotate-entry-test-1 drop ;
-: (annotate-entry-test-2) ( from to quot: ( -- ) -- )
- 2over >= [
- 3drop
+: (annotate-entry-test-2) ( from to -- )
+ 2dup >= [
+ 2drop
] [
- [ swap >r call dup annotate-entry-test-1 1+ r> ] keep (annotate-entry-test-2)
+ >r dup annotate-entry-test-1 1+ r> (annotate-entry-test-2)
] if ; inline recursive
: annotate-entry-test-2 0 -rot (annotate-entry-test-2) ; inline
[ f ] [
- [ { bignum } declare [ ] annotate-entry-test-2 ]
+ [ { bignum } declare annotate-entry-test-2 ]
\ annotate-entry-test-1 inlined?
] unit-test
] unit-test
] when
-[ f ] [
- [ { integer } declare -63 shift 4095 bitand ]
- \ shift inlined?
-] unit-test
-
[ t ] [
[ B{ 1 0 } *short 0 number= ]
\ number= inlined?
] \ + inlined?
] unit-test
-[ f ] [
- [
- 256 mod
- ] { mod fixnum-mod } inlined?
-] unit-test
-
-[ f ] [
- [
- dup 0 >= [ 256 mod ] when
- ] { mod fixnum-mod } inlined?
-] unit-test
-
-[ t ] [
- [
- { integer } declare dup 0 >= [ 256 mod ] when
- ] { mod fixnum-mod } inlined?
-] unit-test
-
-[ t ] [
- [
- { integer } declare 256 rem
- ] { mod fixnum-mod } inlined?
-] unit-test
-
-[ t ] [
- [
- { integer } declare [ 256 rem ] map
- ] { mod fixnum-mod rem } inlined?
-] unit-test
-
[ t ] [
[ 1000 [ 1+ ] map ] { 1+ fixnum+ } inlined?
] unit-test
[ 27/2 fib ] { < - } inlined?
] unit-test
-: hang-regression ( m n -- x )
- over 0 number= [
- nip
- ] [
- dup [
- drop 1 hang-regression
- ] [
- dupd hang-regression hang-regression
- ] if
- ] if ; inline recursive
-
-[ t ] [
- [ dup fixnum? [ 3 over hang-regression ] [ 3 over hang-regression ] if
-] { } inlined? ] unit-test
-
[ t ] [
[ { fixnum } declare 10 [ -1 shift ] times ] \ shift inlined?
] unit-test
\ fixnum-bitand inlined?
] unit-test
-[ t ] [
- [ { integer } declare 127 bitand 3 + ]
- { + +-integer-fixnum +-integer-fixnum-fast bitand } inlined?
-] unit-test
-
-[ f ] [
- [ { integer } declare 127 bitand 3 + ]
- { >fixnum } inlined?
-] unit-test
-
[ t ] [
[ { fixnum } declare [ drop ] each-integer ]
{ < <-integer-fixnum +-integer-fixnum + } inlined?
[ t ] [
[ { fixnum } declare 0 [ + ] reduce ]
- { < <-integer-fixnum } inlined?
+ { < <-integer-fixnum nth-unsafe } inlined?
] unit-test
[ f ] [
\ +-integer-fixnum inlined?
] unit-test
-[ t ] [
- [
- { integer } declare
- dup 0 >= [
- 615949 * 797807 + 20 2^ mod dup 19 2^ -
- ] [ dup ] if
- ] { * + shift mod fixnum-mod fixnum* fixnum+ fixnum- } inlined?
-] unit-test
-
-[ t ] [
- [
- { fixnum } declare
- 615949 * 797807 + 20 2^ mod dup 19 2^ -
- ] { >fixnum } inlined?
-] unit-test
-
[ f ] [
[
{ integer } declare [ ] map
] \ >fixnum inlined?
] unit-test
-[ t ] [
- [
- { integer } declare 0 swap
- [
- drop 615949 * 797807 + 20 2^ rem dup 19 2^ -
- ] map
- ] { * + shift rem mod fixnum-mod fixnum* fixnum+ fixnum- } inlined?
-] unit-test
-
-[ t ] [
- [
- { fixnum } declare 0 swap
- [
- drop 615949 * 797807 + 20 2^ rem dup 19 2^ -
- ] map
- ] { * + shift rem mod fixnum-mod fixnum* fixnum+ fixnum- >fixnum } inlined?
-] unit-test
-
-[ t ] [
- [ hashtable new ] \ new inlined?
-] unit-test
-
-[ t ] [
- [ dup hashtable eq? [ new ] when ] \ new inlined?
-] unit-test
-
-[ t ] [
- [ { hashtable } declare hashtable instance? ] \ instance? inlined?
-] unit-test
-
-[ t ] [
- [ { vector } declare hashtable instance? ] \ instance? inlined?
-] unit-test
-
-[ f ] [
- [ { assoc } declare hashtable instance? ] \ instance? inlined?
-] unit-test
-
-TUPLE: declared-fixnum { x fixnum } ;
-
-[ t ] [
- [ { declared-fixnum } declare [ 1 + ] change-x ]
- { + fixnum+ >fixnum } inlined?
-] unit-test
-
-[ t ] [
- [ { declared-fixnum } declare x>> drop ]
- { slot } inlined?
-] unit-test
-
[ t ] [
[
{ array } declare length
[ t ] [ [ { 1 2 } length ] { length length>> slot } inlined? ] unit-test
-[ t ] [
- [
- { integer } declare [ 256 mod ] map
- ] { mod fixnum-mod } inlined?
-] unit-test
-
[ t ] [
[
{ integer } declare [ 0 >= ] map
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel accessors sequences sequences.deep combinators fry
-namespaces
+classes.algebra namespaces assocs math math.private
+math.partial-dispatch
compiler.tree
compiler.tree.combinators
compiler.tree.propagation.info
#! do it since the logic is a bit more involved
[ cleanup* ] map flatten ;
-: cleanup-constant-folding ( #call -- nodes )
+: cleanup-folding? ( #call -- ? )
+ node-output-infos dup empty?
+ [ drop f ] [ [ literal?>> ] all? ] if ;
+
+: cleanup-folding ( #call -- nodes )
+ #! Replace a #call having a known result with a #drop of its
+ #! inputs followed by #push nodes for the outputs.
[
[ node-output-infos ] [ out-d>> ] bi
[ [ literal>> ] dip #push ] 2map
: cleanup-inlining ( #call -- nodes )
body>> cleanup ;
+! Removing overflow checks
+: no-overflow-variant ( op -- fast-op )
+ H{
+ { fixnum+ fixnum+fast }
+ { fixnum- fixnum-fast }
+ { fixnum* fixnum*fast }
+ { fixnum-shift fixnum-shift-fast }
+ } at ;
+
+: remove-overflow-check? ( #call -- ? )
+ dup word>> no-overflow-variant
+ [ node-output-infos first class>> fixnum class<= ] [ drop f ] if ;
+
+: remove-overflow-check ( #call -- #call )
+ [ in-d>> ] [ out-d>> ] [ word>> no-overflow-variant ] tri #call cleanup* ;
+
M: #call cleanup*
{
- { [ dup node-output-infos [ literal?>> ] all? ] [ cleanup-constant-folding ] }
{ [ dup body>> ] [ cleanup-inlining ] }
+ { [ dup cleanup-folding? ] [ cleanup-folding ] }
+ { [ dup remove-overflow-check? ] [ remove-overflow-check ] }
[ ]
} cond ;
M: #if live-branches
in-d>> first value-info class>> {
- { [ dup null class<= ] [ { f f } ] }
+ { [ dup null-class? ] [ { f f } ] }
{ [ dup true-class? ] [ { t f } ] }
{ [ dup false-class? ] [ { f t } ] }
[ { t t } ]
[ t ] [
f f 3 <literal-info> 3array test-tuple <tuple-info> dup
- object <class-info>
- value-info-intersect =
+ object-info value-info-intersect =
] unit-test
combinators arrays compiler.tree.copy-equiv ;
IN: compiler.tree.propagation.info
+: false-class? ( class -- ? ) \ f class<= ;
+
+: true-class? ( class -- ? ) \ f class-not class<= ;
+
+: null-class? ( class -- ? ) null class<= ;
+
SYMBOL: +interval+
GENERIC: eql? ( obj1 obj2 -- ? )
: null-info T{ value-info f null empty-interval } ; inline
+: object-info T{ value-info f object T{ interval f { -1.0/0.0 t } { 1.0/0.0 t } } } ; inline
+
: class-interval ( class -- interval )
dup real class<=
[ +interval+ word-prop [-inf,inf] or ] [ drop f ] if ;
dup literal>> class >>class
dup literal>> dup real? [ [a,a] ] [ drop [-inf,inf] ] if >>interval
] [
- dup [ class>> null class<= ] [ interval>> empty-interval eq? ] bi or [
+ dup [ class>> null-class? ] [ interval>> empty-interval eq? ] bi or [
null >>class
empty-interval >>interval
] [
: value-info-intersect ( info1 info2 -- info )
{
- { [ dup class>> null class<= ] [ nip ] }
- { [ over class>> null class<= ] [ drop ] }
+ { [ dup class>> null-class? ] [ nip ] }
+ { [ over class>> null-class? ] [ drop ] }
[ (value-info-intersect) ]
} cond ;
: value-info-union ( info1 info2 -- info )
{
- { [ dup class>> null class<= ] [ drop ] }
- { [ over class>> null class<= ] [ nip ] }
+ { [ dup class>> null-class? ] [ drop ] }
+ { [ over class>> null-class? ] [ nip ] }
[ (value-info-union) ]
} cond ;
: value-literal ( value -- obj ? )
value-info >literal< ;
-: false-class? ( class -- ? ) \ f class<= ;
-
-: true-class? ( class -- ? ) \ f class-not class<= ;
-
: possible-boolean-values ( info -- values )
dup literal?>> [
literal>> 1array
] [
class>> {
- { [ dup null class<= ] [ { } ] }
+ { [ dup null-class? ] [ { } ] }
{ [ dup true-class? ] [ { t } ] }
{ [ dup false-class? ] [ { f } ] }
[ { t f } ]
layouts words sequences sequences.private arrays assocs classes
classes.algebra combinators generic.math splitting fry locals
classes.tuple alien.accessors classes.tuple.private slots.private
-compiler.tree.propagation.info compiler.tree.propagation.nodes
-compiler.tree.propagation.constraints
+compiler.tree.comparisons
+compiler.tree.propagation.info
+compiler.tree.propagation.nodes
compiler.tree.propagation.slots
-compiler.tree.comparisons ;
+compiler.tree.propagation.simple
+compiler.tree.propagation.constraints ;
IN: compiler.tree.propagation.known-words
\ fixnum
: binary-op-class ( info1 info2 -- newclass )
[ class>> ] bi@
- 2dup [ null class<= ] either? [ 2drop null ] [
+ 2dup [ null-class? ] either? [ 2drop null ] [
[ math-closure ] bi@ math-class-max
] if ;
[ fixnum class<= ] [ fixnum fits? ] bi* and ;
: may-overflow ( class interval -- class' interval' )
- over null class<= [
+ over null-class? [
2dup won't-overflow?
[ [ integer math-class-max ] dip ] unless
] unless ;
: may-be-rational ( class interval -- class' interval' )
- over null class<= [
+ over null-class? [
[ rational math-class-max ] dip
] unless ;
[ real math-class-min ] dip ;
: float-valued ( class interval -- class' interval' )
- over null class<= [
+ over null-class? [
[ drop float ] dip
] unless ;
! Remove redundant comparisons
: fold-comparison ( info1 info2 word -- info )
[ [ interval>> ] bi@ ] dip interval-comparison {
- { incomparable [ object <class-info> ] }
+ { incomparable [ object-info ] }
{ t [ t <literal-info> ] }
{ f [ f <literal-info> ] }
} case ;
] each
: maybe-or-never ( ? -- info )
- [ object <class-info> ] [ \ f <class-info> ] if ;
+ [ object-info ] [ f <literal-info> ] if ;
: info-intervals-intersect? ( info1 info2 -- ? )
[ interval>> ] bi@ intervals-intersect? ;
\ slot [
dup literal?>>
- [ literal>> swap value-info-slot ] [ 2drop object <class-info> ] if
+ [ literal>> swap value-info-slot ] [ 2drop object-info ] if
+] +outputs+ set-word-prop
+
+\ instance? [
+ [ value-info ] dip over literal>> class? [
+ [ literal>> ] dip predicate-constraints
+ ] [ 2drop f ] if
+] +constraints+ set-word-prop
+
+\ instance? [
+ dup literal>> class?
+ [ literal>> predicate-output-infos ] [ 2drop f ] if
] +outputs+ set-word-prop
alien.accessors alien.c-types sequences.private
byte-arrays classes.algebra classes.tuple.private
math.functions math.private strings layouts
-compiler.tree.propagation.info slots.private ;
+compiler.tree.propagation.info slots.private words hashtables
+classes assocs ;
IN: compiler.tree.propagation.tests
\ propagate must-infer
iterate [ dead-loop ] when ; inline recursive
[ V{ fixnum } ] [ [ { fixnum } declare dead-loop ] final-classes ] unit-test
+
+: hang-1 ( m -- x )
+ dup 0 number= [ hang-1 ] unless ; inline recursive
+
+[ ] [ [ 3 hang-1 ] final-info drop ] unit-test
+
+: hang-2 ( m n -- x )
+ over 0 number= [
+ nip
+ ] [
+ dup [
+ drop 1 hang-2
+ ] [
+ dupd hang-2 hang-2
+ ] if
+ ] if ; inline recursive
+
+[ ] [ [ 3 over hang-2 ] final-info drop ] unit-test
+
+[ ] [
+ [
+ dup fixnum? [ 3 over hang-2 ] [ 3 over hang-2 ] if
+ ] final-info drop
+] unit-test
+
+[ V{ word } ] [
+ [ { hashtable } declare hashtable instance? ] final-classes
+] unit-test
+
+[ V{ POSTPONE: f } ] [
+ [ { vector } declare hashtable instance? ] final-classes
+] unit-test
+
+[ V{ object } ] [
+ [ { assoc } declare hashtable instance? ] final-classes
+] unit-test
+
+[ V{ word } ] [
+ [ { string } declare string? ] final-classes
+] unit-test
+
+[ V{ POSTPONE: f } ] [
+ [ 3 string? ] final-classes
+] unit-test
+
+[ V{ fixnum } ] [
+ [ { fixnum } declare [ ] curry obj>> ] final-classes
+] unit-test
+
+[ V{ fixnum } ] [
+ [ { fixnum fixnum } declare [ nth-unsafe ] curry call ] final-classes
+] unit-test
--- /dev/null
+IN: compiler.tree.propagation.recursive.tests
+USING: tools.test compiler.tree.propagation.recursive
+math.intervals kernel ;
+
+[ T{ interval f { 0 t } { 1/0. t } } ] [
+ T{ interval f { 1 t } { 1 t } }
+ T{ interval f { 0 t } { 0 t } } generalize-counter-interval
+] unit-test
+
+[ T{ interval f { -1/0. t } { 10 t } } ] [
+ T{ interval f { -1 t } { -1 t } }
+ T{ interval f { 10 t } { 10 t } } generalize-counter-interval
+] unit-test
+
+[ t ] [
+ T{ interval f { 1 t } { 268435455 t } }
+ T{ interval f { -268435456 t } { 268435455 t } } tuck
+ generalize-counter-interval =
+] unit-test
: generalize-counter-interval ( interval initial-interval -- interval' )
{
- { [ 2dup = ] [ empty-interval ] }
+ { [ 2dup interval-subset? ] [ empty-interval ] }
{ [ over empty-interval eq? ] [ empty-interval ] }
{ [ 2dup interval>= t eq? ] [ 1./0. [a,a] ] }
{ [ 2dup interval<= t eq? ] [ -1./0. [a,a] ] }
[ [-inf,inf] ]
- } cond nip interval-union ;
+ } cond interval-union nip ;
: generalize-counter ( info' initial -- info )
- [ drop clone ] [ [ interval>> ] bi@ ] 2bi
- generalize-counter-interval >>interval ;
+ 2dup [ class>> null-class? ] either? [ drop ] [
+ [ drop clone ] [ [ interval>> ] bi@ ] 2bi
+ generalize-counter-interval >>interval
+ ] if ;
: unify-recursive-stacks ( stacks initial -- infos )
over empty? [ nip ] [
] [ dup label>> fixed-point>> [ drop ] [ propagate-around ] if ] bi ;
: generalize-return-interval ( info -- info' )
- dup literal?>> [
+ dup [ literal?>> ] [ class>> null-class? ] bi or [
clone [-inf,inf] >>interval
] unless ;
! Propagation for straight-line code.
M: #introduce propagate-before
- value>> object <class-info> swap set-value-info ;
+ value>> object-info swap set-value-info ;
M: #push propagate-before
[ literal>> <literal-info> ] [ out-d>> first ] bi
bi* with-datastack
[ <literal-info> ] map ;
+: predicate-output-infos ( info class -- info )
+ [ class>> ] dip {
+ { [ 2dup class<= ] [ t <literal-info> ] }
+ { [ 2dup classes-intersect? not ] [ f <literal-info> ] }
+ [ object-info ]
+ } cond 2nip ;
+
+: propagate-predicate ( #call word -- infos )
+ [ in-d>> first value-info ] [ "predicating" word-prop ] bi*
+ predicate-output-infos 1array ;
+
: default-output-value-infos ( #call word -- infos )
"default-output-classes" word-prop
- [ class-infos ] [ out-d>> length object <class-info> <repetition> ] ?if ;
+ [ class-infos ] [ out-d>> length object-info <repetition> ] ?if ;
: output-value-infos ( #call word -- infos )
{
{ [ 2dup foldable-call? ] [ fold-call ] }
{ [ dup tuple-constructor? ] [ propagate-tuple-constructor ] }
{ [ dup sequence-constructor? ] [ propagate-sequence-constructor ] }
+ { [ dup predicate? ] [ propagate-predicate ] }
{ [ dup +outputs+ word-prop ] [ call-outputs-quot ] }
[ default-output-value-infos ]
} cond ;
USING: fry assocs arrays byte-arrays strings accessors sequences
kernel slots classes.algebra classes.tuple classes.tuple.private
words math math.private combinators sequences.private namespaces
-classes compiler.tree.propagation.info ;
+slots.private classes compiler.tree.propagation.info ;
IN: compiler.tree.propagation.slots
! Propagation of immutable slots and array lengths
bi* value-info-intersect 1array ;
: tuple-constructor? ( word -- ? )
- { <tuple-boa> <complex> } memq? ;
+ { <tuple-boa> curry compose <complex> } memq? ;
: read-only-slots ( values class -- slots )
#! Delegation.
[ , f , [ literal>> ] map % ] { } make >tuple
<literal-info> ;
-: propagate-<tuple-boa> ( #call -- info )
- #! Delegation
- in-d>> [ value-info ] map unclip-last
- literal>> class>> [ read-only-slots ] keep
+: (propagate-tuple-constructor) ( values class -- info )
+ [ [ value-info ] map ] dip [ read-only-slots ] keep
over 2 tail-slice [ dup [ literal?>> ] when ] all? [
[ 2 tail-slice ] dip fold-<tuple-boa>
] [
<tuple-info>
] if ;
+: propagate-<tuple-boa> ( #call -- info )
+ #! Delegation
+ in-d>> unclip-last
+ value-info literal>> class>> (propagate-tuple-constructor) ;
+
+: propagate-curry ( #call -- info )
+ in-d>> \ curry (propagate-tuple-constructor) ;
+
+: propagate-compose ( #call -- info )
+ in-d>> \ compose (propagate-tuple-constructor) ;
+
: propagate-<complex> ( #call -- info )
in-d>> [ value-info ] map complex <tuple-info> ;
: propagate-tuple-constructor ( #call word -- infos )
{
{ \ <tuple-boa> [ propagate-<tuple-boa> ] }
+ { \ curry [ propagate-curry ] }
+ { \ compose [ propagate-compose ] }
{ \ <complex> [ propagate-<complex> ] }
} case 1array ;
-: tuple>array* ( tuple -- array )
- prepare-tuple>array
- >r copy-tuple-slots r>
- prefix ;
-
: read-only-slot? ( n class -- ? )
all-slots [ offset>> = ] with find nip
dup [ read-only>> ] when ;
: literal-info-slot ( slot object -- info/f )
- 2dup class read-only-slot? [
- {
- { [ dup tuple? ] [
- [ 1- ] [ tuple>array* ] bi* nth <literal-info>
- ] }
- { [ dup complex? ] [
- [ 1- ] [ [ real-part ] [ imaginary-part ] bi ] bi*
- 2array nth <literal-info>
- ] }
- } cond
- ] [ 2drop f ] if ;
+ 2dup class read-only-slot?
+ [ swap slot <literal-info> ] [ 2drop f ] if ;
: length-accessor? ( slot info -- ? )
[ 1 = ] [ length>> ] bi* and ;
{ [ 2dup length-accessor? ] [ nip length>> ] }
{ [ dup literal?>> ] [ literal>> literal-info-slot ] }
[ [ 1- ] [ slots>> ] bi* ?nth ]
- } cond [ object <class-info> ] unless* ;
+ } cond [ object-info ] unless* ;
--- /dev/null
+TUPLE: declared-fixnum { x fixnum } ;
+
+[ t ] [
+ [ { declared-fixnum } declare [ 1 + ] change-x ]
+ { + fixnum+ >fixnum } inlined?
+] unit-test
+
+[ t ] [
+ [ { declared-fixnum } declare x>> drop ]
+ { slot } inlined?
+] unit-test
+
+[ t ] [
+ [ hashtable new ] \ new inlined?
+] unit-test
+
+[ t ] [
+ [ dup hashtable eq? [ new ] when ] \ new inlined?
+] unit-test
+
+[ f ] [
+ [ { integer } declare -63 shift 4095 bitand ]
+ \ shift inlined?
+] unit-test
+
+[ t ] [
+ [ { integer } declare 127 bitand 3 + ]
+ { + +-integer-fixnum +-integer-fixnum-fast bitand } inlined?
+] unit-test
+
+[ f ] [
+ [ { integer } declare 127 bitand 3 + ]
+ { >fixnum } inlined?
+] unit-test
+
+[ t ] [
+ [
+ { integer } declare
+ dup 0 >= [
+ 615949 * 797807 + 20 2^ mod dup 19 2^ -
+ ] [ dup ] if
+ ] { * + shift mod fixnum-mod fixnum* fixnum+ fixnum- } inlined?
+] unit-test
+
+[ t ] [
+ [
+ { fixnum } declare
+ 615949 * 797807 + 20 2^ mod dup 19 2^ -
+ ] { >fixnum } inlined?
+] unit-test
+
+[ t ] [
+ [
+ { integer } declare 0 swap
+ [
+ drop 615949 * 797807 + 20 2^ rem dup 19 2^ -
+ ] map
+ ] { * + shift rem mod fixnum-mod fixnum* fixnum+ fixnum- } inlined?
+] unit-test
+
+[ t ] [
+ [
+ { fixnum } declare 0 swap
+ [
+ drop 615949 * 797807 + 20 2^ rem dup 19 2^ -
+ ] map
+ ] { * + shift rem mod fixnum-mod fixnum* fixnum+ fixnum- >fixnum } inlined?
+] unit-test
+
+[ t ] [
+ [ { string sbuf } declare ] \ push-all def>> append \ + inlined?
+] unit-test
+
+[ t ] [
+ [ { string sbuf } declare ] \ push-all def>> append \ fixnum+ inlined?
+] unit-test
+
+[ t ] [
+ [ { string sbuf } declare ] \ push-all def>> append \ >fixnum inlined?
+] unit-test
+
+
+
+[ t ] [
+ [
+ { integer } declare [ 256 mod ] map
+ ] { mod fixnum-mod } inlined?
+] unit-test
+
+
+[ f ] [
+ [
+ 256 mod
+ ] { mod fixnum-mod } inlined?
+] unit-test
+
+[ f ] [
+ [
+ dup 0 >= [ 256 mod ] when
+ ] { mod fixnum-mod } inlined?
+] unit-test
+
+[ t ] [
+ [
+ { integer } declare dup 0 >= [ 256 mod ] when
+ ] { mod fixnum-mod } inlined?
+] unit-test
+
+[ t ] [
+ [
+ { integer } declare 256 rem
+ ] { mod fixnum-mod } inlined?
+] unit-test
+
+[ t ] [
+ [
+ { integer } declare [ 256 rem ] map
+ ] { mod fixnum-mod rem } inlined?
+] unit-test
bi
] "" make "math.partial-dispatch" lookup ;
-: integer-op-word ( triple fix-word big-word -- word )
- [
- drop
- name>> "fast" tail? >r
- [ "-" % ] [ name>> % ] interleave
- r> [ "-fast" % ] when
- ] "" make "math.partial-dispatch" create ;
+: integer-op-word ( triple -- word )
+ [ name>> ] map "-" join "math.partial-dispatch" create ;
-: integer-op-quot ( word fix-word big-word -- quot )
+: integer-op-quot ( triple fix-word big-word -- quot )
rot integer-op-combinator 1quotation 2curry ;
-: define-integer-op-word ( word fix-word big-word -- )
+: define-integer-op-word ( triple fix-word big-word -- )
[
- [ integer-op-word ] [ integer-op-quot ] 3bi
+ [ 2drop integer-op-word ] [ integer-op-quot ] 3bi
(( x y -- z )) define-declared
- ]
- [
- [ integer-op-word ] [ 2drop ] 3bi
+ ] [
+ 2drop
+ [ integer-op-word ] keep
"derived-from" set-word-prop
] 3bi ;
-: define-integer-op-words ( words fix-word big-word -- )
+: define-integer-op-words ( triples fix-word big-word -- )
[ define-integer-op-word ] 2curry each ;
: integer-op-triples ( word -- triples )
: define-integer-ops ( word fix-word big-word -- )
>r >r integer-op-triples r> r>
[ define-integer-op-words ]
- [ [ 2drop ] [ [ integer-op-word ] 2curry map ] 3bi zip % ]
+ [ 2drop [ dup integer-op-word ] { } map>assoc % ]
3bi ;
: define-math-ops ( op -- )
\ number= \ eq? \ bignum= define-integer-ops
] { } make >hashtable math-ops set-global
- [
- { { + fixnum fixnum } fixnum+fast } ,
- { { - fixnum fixnum } fixnum-fast } ,
- { { * fixnum fixnum } fixnum*fast } ,
- { { shift fixnum fixnum } fixnum-shift-fast } ,
-
- \ + \ fixnum+fast \ bignum+ define-integer-ops
- \ - \ fixnum-fast \ bignum- define-integer-ops
- \ * \ fixnum*fast \ bignum* define-integer-ops
- \ shift \ fixnum-shift-fast \ bignum-shift define-integer-ops
- ] { } make >hashtable fast-math-ops set-global
+ H{
+ { { + fixnum fixnum } fixnum+fast }
+ { { - fixnum fixnum } fixnum-fast }
+ { { * fixnum fixnum } fixnum*fast }
+ { { shift fixnum fixnum } fixnum-shift-fast }
+ } fast-math-ops set-global
] with-compilation-unit
sorting assocs definitions prettyprint io inspector
classes.tuple classes.union classes.predicate debugger
threads.private io.streams.string io.timeouts io.thread
-sequences.private destructors combinators ;
+sequences.private destructors combinators eval ;
IN: stack-checker.tests
: short-effect ( effect -- pair )