compiler.tree.dead-code.simple: small refactoring and docs

db4
Björn Lindqvist 2015-11-18 12:35:13 +01:00
parent 097b40ce41
commit e1b22e0af4
2 changed files with 15 additions and 7 deletions

View File

@ -0,0 +1,10 @@
USING: compiler.tree help.markup help.syntax sequences ;
IN: compiler.tree.dead-code.simple
HELP: filter-corresponding
{ $values { "new" sequence } { "old" sequence } { "old'" sequence } }
{ $description "Remove elements from 'old' if the element with the same index in 'new' is dead." } ;
HELP: flushable-call?
{ $values { "#call" #call } { "?" "boolean" } }
{ $description { $link t } " if the call is flushable" } ;

View File

@ -2,17 +2,17 @@
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes.algebra combinators
compiler.tree compiler.tree.dead-code.liveness
compiler.tree.propagation.info fry kernel locals math
math.private namespaces sequences stack-checker.backend
stack-checker.dependencies words ;
compiler.tree.propagation.info fry kernel locals math math.private
namespaces sequences stack-checker.backend stack-checker.dependencies
words ;
IN: compiler.tree.dead-code.simple
: flushable-call? ( #call -- ? )
dup word>> dup flushable? [
"input-classes" word-prop dup [
"input-classes" word-prop [ drop t ] [
[ node-input-infos ] dip
[ [ class>> ] dip class<= ] 2all?
] [ 2drop t ] if
] if-empty
] [ 2drop f ] if ;
M: #call mark-live-values*
@ -41,8 +41,6 @@ M: #alien-node compute-live-values* nip look-at-inputs ;
live-values get '[ drop _ key? ] assoc-filter ;
: filter-corresponding ( new old -- old' )
! Remove elements from 'old' if the element with the same
! index in 'new' is dead.
zip filter-mapping values ;
: filter-live ( values -- values' )