diff --git a/basis/compiler/tree/dead-code/simple/simple-docs.factor b/basis/compiler/tree/dead-code/simple/simple-docs.factor index ff1b49a861..1f069b5bc6 100644 --- a/basis/compiler/tree/dead-code/simple/simple-docs.factor +++ b/basis/compiler/tree/dead-code/simple/simple-docs.factor @@ -1,6 +1,10 @@ -USING: compiler.tree help.markup help.syntax sequences ; +USING: compiler.tree help.markup help.syntax kernel sequences ; IN: compiler.tree.dead-code.simple +HELP: dead-flushable-call? +{ $values { "#call" #call } { "?" boolean } } +{ $description { $link t } " if the called word is flushable and none of its outputs are used." } ; + 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." } ; diff --git a/basis/compiler/tree/dead-code/simple/simple-tests.factor b/basis/compiler/tree/dead-code/simple/simple-tests.factor new file mode 100644 index 0000000000..82b5a9bc24 --- /dev/null +++ b/basis/compiler/tree/dead-code/simple/simple-tests.factor @@ -0,0 +1,23 @@ +USING: accessors compiler.tree compiler.tree.dead-code.liveness +compiler.tree.dead-code.simple kernel math namespaces tools.test ; +IN: compiler.tree.dead-code.simple.tests + +! dead-flushable-call? +{ t } [ + { } { } \ + <#call> dead-flushable-call? +] unit-test + +{ f t } [ + H{ { 3 t } } live-values set + { 1 2 } { 3 } \ + <#call> dead-flushable-call? + { 1 2 } { 77 } \ + <#call> dead-flushable-call? +] unit-test + +{ + f + "foo" { 3 } +} [ + H{ { 3 t } } live-values set + "foo" 9 <#push> remove-dead-code* + "foo" 3 <#push> remove-dead-code* [ literal>> ] [ out-d>> ] bi +] unit-test