From 0180209f4ec94be20872bf73a59cbccbe0b120e8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 3 Jul 2009 21:31:26 -0500 Subject: [PATCH] compiler.tree.dead-code: methods on flushable generics should be flushable --- .../tree/cleanup/cleanup-tests.factor | 21 +++++++++++++++++++ .../tree/dead-code/simple/simple.factor | 11 +++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/basis/compiler/tree/cleanup/cleanup-tests.factor b/basis/compiler/tree/cleanup/cleanup-tests.factor index 549d492d20..e5b75bb5b0 100755 --- a/basis/compiler/tree/cleanup/cleanup-tests.factor +++ b/basis/compiler/tree/cleanup/cleanup-tests.factor @@ -6,6 +6,7 @@ definitions system layouts vectors math.partial-dispatch math.order math.functions accessors hashtables classes assocs io.encodings.utf8 io.encodings.ascii io.encodings fry slots sorting.private combinators.short-circuit grouping prettyprint +generalizations compiler.tree compiler.tree.combinators compiler.tree.cleanup @@ -518,3 +519,23 @@ cell-bits 32 = [ [ { integer integer } declare + drop ] { + +-integer-integer } inlined? ] unit-test + +[ [ ] ] [ + [ + 20 f + [ 0 swap nth ] keep + [ 1 swap nth ] keep + [ 2 swap nth ] keep + [ 3 swap nth ] keep + [ 4 swap nth ] keep + [ 5 swap nth ] keep + [ 6 swap nth ] keep + [ 7 swap nth ] keep + [ 8 swap nth ] keep + [ 9 swap nth ] keep + [ 10 swap nth ] keep + [ 11 swap nth ] keep + [ 12 swap nth ] keep + 14 ndrop + ] cleaned-up-tree nodes>quot +] unit-test \ No newline at end of file diff --git a/basis/compiler/tree/dead-code/simple/simple.factor b/basis/compiler/tree/dead-code/simple/simple.factor index c9b73808a1..5134a67a5b 100755 --- a/basis/compiler/tree/dead-code/simple/simple.factor +++ b/basis/compiler/tree/dead-code/simple/simple.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel accessors words assocs sequences arrays namespaces -fry locals definitions classes.algebra +fry locals definitions classes classes.algebra generic stack-checker.state stack-checker.backend compiler.tree @@ -9,8 +9,13 @@ compiler.tree.propagation.info compiler.tree.dead-code.liveness ; IN: compiler.tree.dead-code.simple -: flushable? ( word -- ? ) - [ "flushable" word-prop ] [ "predicating" word-prop ] bi or ; +GENERIC: flushable? ( word -- ? ) + +M: predicate flushable? drop t ; + +M: word flushable? "flushable" word-prop ; + +M: method-body flushable? "method-generic" word-prop flushable? ; : flushable-call? ( #call -- ? ) dup word>> dup flushable? [