]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.builder: if there is a conditional where every branch is known to throw...
authorSlava Pestov <slava@factorcode.org>
Wed, 23 Jun 2010 07:33:15 +0000 (03:33 -0400)
committerSlava Pestov <slava@factorcode.org>
Wed, 23 Jun 2010 07:33:15 +0000 (03:33 -0400)
basis/compiler/cfg/builder/blocks/blocks.factor

index 293c3fe09b21fc63f8cc4a3477ae32a13c2c82e5..82af0f9b307fa215ca1e00d1e3da000836b39576 100644 (file)
@@ -60,19 +60,14 @@ IN: compiler.cfg.builder.blocks
 : set-successors ( branches -- )
     ! Set the successor of each branch's final basic block to the
     ! current block.
-    basic-block get dup [
-        '[ [ [ _ ] dip first successors>> push ] when* ] each
-    ] [ 2drop ] if ;
-
-: merge-heights ( branches -- )
-    ! If all elements are f, that means every branch ended with a backward
-    ! jump so the height is irrelevant since this block is unreachable.
-    [ ] find nip [ second current-height set ] [ end-basic-block ] if* ;
+    [ [ [ basic-block get ] dip first successors>> push ] when* ] each ;
 
 : emit-conditional ( branches -- )
     ! branches is a sequence of pairs as above
     end-basic-block
-    [ merge-heights begin-basic-block ]
-    [ set-successors ]
-    bi ;
+    dup [ ] find nip dup [
+        second current-height set
+        begin-basic-block
+        set-successors
+    ] [ 2drop ] if ;