From c9f07af1112ec55d71d41ff0b018549b81846d7f Mon Sep 17 00:00:00 2001 From: slava Date: Sat, 4 Mar 2006 23:46:49 +0000 Subject: [PATCH] Fix a bug in the kill literals phase --- TODO.FACTOR.txt | 1 + library/collections/sequence-sort.factor | 2 +- library/inference/kill-literals.factor | 4 ++-- library/test/compiler/optimizer.factor | 23 +++++++++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index a12232a591..459bb1c78d 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -36,6 +36,7 @@ + compiler/ffi: +- inform-compile dies with funny error - amd64 %unbox-struct - float intrinsics - complex float type diff --git a/library/collections/sequence-sort.factor b/library/collections/sequence-sort.factor index 6547c91ee8..510bae5ee2 100644 --- a/library/collections/sequence-sort.factor +++ b/library/collections/sequence-sort.factor @@ -15,7 +15,7 @@ C: sorter ( seq start end -- sorter ) : exchange ( n n seq -- ) [ tuck nth-unsafe >r nth r> ] 3keep tuck - >r >r set-nth-unsafe r> r> set-nth-unsafe ; + >r >r set-nth-unsafe r> r> set-nth-unsafe ; inline : s*/e* dup sorter-start swap sorter-end ; inline : s*/e dup sorter-start swap sorter-seq length 1- ; inline diff --git a/library/inference/kill-literals.factor b/library/inference/kill-literals.factor index 6aa2fc3d9e..2abb61d2da 100644 --- a/library/inference/kill-literals.factor +++ b/library/inference/kill-literals.factor @@ -75,8 +75,8 @@ M: #killable live-values* ( node -- seq ) drop { } ; ! #label M: #label live-values* ( node -- seq ) - dup node-child [ node-in-d ] 2apply 2array - purge-invariants ; + dup node-child node-in-d over node-in-d 2array + rot collect-recursion append purge-invariants ; ! branching UNION: #branch #if #dispatch ; diff --git a/library/test/compiler/optimizer.factor b/library/test/compiler/optimizer.factor index 991b0ff7cf..a9a9a0cdf0 100644 --- a/library/test/compiler/optimizer.factor +++ b/library/test/compiler/optimizer.factor @@ -38,6 +38,20 @@ IN: temporary : set= 2dup subset? >r swap subset? r> and ; +: kill-set dup live-values swap literals hash-diff ; + +: kill-set= + dataflow kill-set hash-keys [ value-literal ] map set= ; + +: foo 1 2 3 ; + +[ H{ } ] [ \ foo word-def dataflow kill-set ] unit-test + +[ t ] [ [ [ 1 ] [ 2 ] ] [ [ 1 ] [ 2 ] if ] kill-set= ] unit-test + +[ t ] [ [ [ 1 ] [ 2 ] ] [ [ 1 ] [ 2 ] if ] kill-set= ] unit-test + + : literal-kill-test-1 4 compiled-offset 2 cells - ; compiled [ 4 ] [ literal-kill-test-1 drop ] unit-test @@ -68,6 +82,10 @@ IN: temporary [ ] [ t literal-kill-test-6 ] unit-test [ ] [ f literal-kill-test-6 ] unit-test +[ t ] [ [ + 5 [ dup ] [ dup ] ] \ literal-kill-test-6 word-def kill-set= +] unit-test + : literal-kill-test-7 [ 1 2 3 ] >r + r> drop ; compiled @@ -76,6 +94,11 @@ IN: temporary : literal-kill-test-8 dup [ >r dup slip r> literal-kill-test-8 ] [ 2drop ] if ; inline +[ t ] [ + [ [ ] swap literal-kill-test-8 ] dataflow + live-values hash-values [ value? ] subset empty? +] unit-test + ! Test method inlining [ f ] [ fixnum { } min-class ] unit-test