Faster dynamic variable lookup: 6% speedup in benchmark.fib5
- If type of first input of equal? is known but not second, rewrite it as swap equal? and try to inline again - Fix hints on methods to work better - Put hints for word and fixnum keys on at* and set-at on hashtablesdb4
parent
41c448db8a
commit
60a1378a0a
|
@ -6,7 +6,7 @@ math.parser math.order layouts words sequences sequences.private
|
||||||
arrays assocs classes classes.algebra combinators generic.math
|
arrays assocs classes classes.algebra combinators generic.math
|
||||||
splitting fry locals classes.tuple alien.accessors
|
splitting fry locals classes.tuple alien.accessors
|
||||||
classes.tuple.private slots.private definitions strings.private
|
classes.tuple.private slots.private definitions strings.private
|
||||||
vectors hashtables
|
vectors hashtables generic
|
||||||
stack-checker.state
|
stack-checker.state
|
||||||
compiler.tree.comparisons
|
compiler.tree.comparisons
|
||||||
compiler.tree.propagation.info
|
compiler.tree.propagation.info
|
||||||
|
@ -337,3 +337,12 @@ generic-comparison-ops [
|
||||||
bi
|
bi
|
||||||
] [ 2drop object-info ] if
|
] [ 2drop object-info ] if
|
||||||
] "outputs" set-word-prop
|
] "outputs" set-word-prop
|
||||||
|
|
||||||
|
\ equal? [
|
||||||
|
! If first input has a known type and second input is an
|
||||||
|
! object, we convert this to [ swap equal? ].
|
||||||
|
in-d>> first2 value-info class>> object class= [
|
||||||
|
value-info class>> \ equal? specific-method
|
||||||
|
[ swap equal? ] f ?
|
||||||
|
] [ drop f ] if
|
||||||
|
] "custom-inlining" set-word-prop
|
||||||
|
|
|
@ -640,6 +640,10 @@ MIXIN: empty-mixin
|
||||||
[ { fixnum } declare log2 0 >= ] final-classes
|
[ { fixnum } declare log2 0 >= ] final-classes
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
[ V{ POSTPONE: f } ] [
|
||||||
|
[ { word object } declare eq? ] final-classes
|
||||||
|
] unit-test
|
||||||
|
|
||||||
! [ V{ string } ] [
|
! [ V{ string } ] [
|
||||||
! [ dup string? t xor [ "A" throw ] [ ] if ] final-classes
|
! [ dup string? t xor [ "A" throw ] [ ] if ] final-classes
|
||||||
! ] unit-test
|
! ] unit-test
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
USING: parser words definitions kernel sequences assocs arrays
|
USING: parser words definitions kernel sequences assocs arrays
|
||||||
kernel.private fry combinators accessors vectors strings sbufs
|
kernel.private fry combinators accessors vectors strings sbufs
|
||||||
byte-arrays byte-vectors io.binary io.streams.string splitting
|
byte-arrays byte-vectors io.binary io.streams.string splitting
|
||||||
math generic generic.standard generic.standard.engines classes ;
|
math generic generic.standard generic.standard.engines classes
|
||||||
|
hashtables ;
|
||||||
IN: hints
|
IN: hints
|
||||||
|
|
||||||
GENERIC: specializer-predicate ( spec -- quot )
|
GENERIC: specializer-predicate ( spec -- quot )
|
||||||
|
@ -50,14 +51,10 @@ M: object specializer-declaration class ;
|
||||||
] [ drop f ] if ;
|
] [ drop f ] if ;
|
||||||
|
|
||||||
: specialized-def ( word -- quot )
|
: specialized-def ( word -- quot )
|
||||||
dup def>> swap {
|
[ def>> ] keep
|
||||||
{
|
[ dup standard-method? [ specialize-method ] [ drop ] if ]
|
||||||
[ dup "specializer" word-prop ]
|
[ "specializer" word-prop [ specialize-quot ] when* ]
|
||||||
[ "specializer" word-prop specialize-quot ]
|
bi ;
|
||||||
}
|
|
||||||
{ [ dup standard-method? ] [ specialize-method ] }
|
|
||||||
[ drop ]
|
|
||||||
} cond ;
|
|
||||||
|
|
||||||
: specialized-length ( specializer -- n )
|
: specialized-length ( specializer -- n )
|
||||||
dup [ array? ] all? [ first ] when length ;
|
dup [ array? ] all? [ first ] when length ;
|
||||||
|
@ -120,3 +117,7 @@ M: object specializer-declaration class ;
|
||||||
\ >le { { fixnum fixnum } { bignum fixnum } } "specializer" set-word-prop
|
\ >le { { fixnum fixnum } { bignum fixnum } } "specializer" set-word-prop
|
||||||
|
|
||||||
\ >be { { bignum fixnum } { fixnum fixnum } } "specializer" set-word-prop
|
\ >be { { bignum fixnum } { fixnum fixnum } } "specializer" set-word-prop
|
||||||
|
|
||||||
|
\ hashtable \ at* method { { fixnum hashtable } { word hashtable } } "specializer" set-word-prop
|
||||||
|
|
||||||
|
\ hashtable \ set-at method { { object fixnum object } { object word object } } "specializer" set-word-prop
|
||||||
|
|
Loading…
Reference in New Issue