Propagation pass: add inlined node counts to total node count, so that the more we inline the less we are eager to inline more

db4
Slava Pestov 2009-03-06 23:34:01 -06:00
parent 37bc52afa8
commit 42224eb4e7
2 changed files with 10 additions and 11 deletions

View File

@ -17,8 +17,10 @@ IN: compiler.tree.propagation.inlining
! we are more eager to inline ! we are more eager to inline
SYMBOL: node-count SYMBOL: node-count
: count-nodes ( nodes -- ) : count-nodes ( nodes -- n )
0 swap [ drop 1+ ] each-node node-count set ; 0 swap [ drop 1+ ] each-node ;
: compute-node-count ( nodes -- ) count-nodes node-count set ;
! We try not to inline the same word too many times, to avoid ! We try not to inline the same word too many times, to avoid
! combinatorial explosion ! combinatorial explosion
@ -33,9 +35,6 @@ M: word splicing-nodes
M: callable splicing-nodes M: callable splicing-nodes
build-sub-tree analyze-recursive normalize ; build-sub-tree analyze-recursive normalize ;
: propagate-body ( #call -- )
body>> (propagate) ;
! Dispatch elimination ! Dispatch elimination
: eliminate-dispatch ( #call class/f word/quot/f -- ? ) : eliminate-dispatch ( #call class/f word/quot/f -- ? )
dup [ dup [
@ -44,7 +43,7 @@ M: callable splicing-nodes
2dup splicing-nodes 2dup splicing-nodes
[ >>method ] [ >>body ] bi* [ >>method ] [ >>body ] bi*
] if ] if
propagate-body t body>> (propagate) t
] [ 2drop f >>method f >>body f >>class drop f ] if ; ] [ 2drop f >>method f >>body f >>class drop f ] if ;
: inlining-standard-method ( #call word -- class/f method/f ) : inlining-standard-method ( #call word -- class/f method/f )
@ -161,10 +160,10 @@ SYMBOL: history
: inline-word-def ( #call word quot -- ? ) : inline-word-def ( #call word quot -- ? )
over history get memq? [ 3drop f ] [ over history get memq? [ 3drop f ] [
[ [
swap remember-inlining [ remember-inlining ] dip
dupd splicing-nodes >>body [ drop ] [ splicing-nodes ] 2bi
propagate-body [ >>body drop ] [ count-nodes ] [ (propagate) ] tri
] with-scope ] with-scope node-count +@
t t
] if ; ] if ;

View File

@ -20,5 +20,5 @@ IN: compiler.tree.propagation
H{ } clone 1array value-infos set H{ } clone 1array value-infos set
H{ } clone 1array constraints set H{ } clone 1array constraints set
H{ } clone inlining-count set H{ } clone inlining-count set
dup count-nodes dup compute-node-count
dup (propagate) ; dup (propagate) ;