Fix possible infinite loop in skip-empty-blocks and remove redundant test in compiler.cfg.useless-conditionals
parent
f412bbc6d6
commit
fc595a7075
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2008, 2009 Slava Pestov.
|
! Copyright (C) 2008, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel arrays vectors accessors
|
USING: kernel arrays vectors accessors assocs sets
|
||||||
namespaces math make fry sequences
|
namespaces math make fry sequences
|
||||||
combinators.short-circuit
|
combinators.short-circuit
|
||||||
compiler.cfg.instructions ;
|
compiler.cfg.instructions ;
|
||||||
|
@ -28,8 +28,18 @@ M: basic-block hashcode* nip id>> ;
|
||||||
[ first ##branch? ]
|
[ first ##branch? ]
|
||||||
} 1&& ;
|
} 1&& ;
|
||||||
|
|
||||||
|
SYMBOL: visited
|
||||||
|
|
||||||
|
: (skip-empty-blocks) ( bb -- bb' )
|
||||||
|
dup visited get key? [
|
||||||
|
dup empty-block? [
|
||||||
|
dup visited get conjoin
|
||||||
|
successors>> first (skip-empty-blocks)
|
||||||
|
] when
|
||||||
|
] unless ;
|
||||||
|
|
||||||
: skip-empty-blocks ( bb -- bb' )
|
: skip-empty-blocks ( bb -- bb' )
|
||||||
dup empty-block? [ successors>> first skip-empty-blocks ] when ;
|
H{ } clone visited [ (skip-empty-blocks) ] with-variable ;
|
||||||
|
|
||||||
: add-instructions ( bb quot -- )
|
: add-instructions ( bb quot -- )
|
||||||
[ instructions>> building ] dip '[
|
[ instructions>> building ] dip '[
|
||||||
|
|
|
@ -6,7 +6,6 @@ IN: compiler.cfg.useless-conditionals
|
||||||
|
|
||||||
: delete-conditional? ( bb -- ? )
|
: delete-conditional? ( bb -- ? )
|
||||||
{
|
{
|
||||||
[ instructions>> length 1 > ]
|
|
||||||
[ instructions>> last class { ##compare-branch ##compare-imm-branch ##compare-float-branch } memq? ]
|
[ instructions>> last class { ##compare-branch ##compare-imm-branch ##compare-float-branch } memq? ]
|
||||||
[ successors>> first2 [ skip-empty-blocks ] bi@ eq? ]
|
[ successors>> first2 [ skip-empty-blocks ] bi@ eq? ]
|
||||||
} 1&& ;
|
} 1&& ;
|
||||||
|
|
Loading…
Reference in New Issue