]> gitweb.factorcode.org Git - factor.git/commitdiff
Add a new ##allocation union to remove some code duplication
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 27 May 2009 23:55:49 +0000 (18:55 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 27 May 2009 23:55:49 +0000 (18:55 -0500)
basis/compiler/cfg/alias-analysis/alias-analysis.factor
basis/compiler/cfg/instructions/instructions.factor
basis/compiler/cfg/linearization/linearization.factor

index 8e1034fb0d04809e6da60512ff59a0c65bd9b449..6b1e0c47b6a9fe063c6f2b7e1df2d69320b18520 100644 (file)
@@ -220,17 +220,7 @@ M: ##load-reference analyze-aliases*
 M: ##alien-global analyze-aliases*
     dup dst>> set-heap-ac ;
 
-M: ##allot analyze-aliases*
-    #! A freshly allocated object is distinct from any other
-    #! object.
-    dup dst>> set-new-ac ;
-
-M: ##box-float analyze-aliases*
-    #! A freshly allocated object is distinct from any other
-    #! object.
-    dup dst>> set-new-ac ;
-
-M: ##box-alien analyze-aliases*
+M: ##allocation analyze-aliases*
     #! A freshly allocated object is distinct from any other
     #! object.
     dup dst>> set-new-ac ;
index 650bcb57951362165f83f67b631250ec11a3be2f..747233dbba3cfd25d55526ca12f2c530ed718182 100644 (file)
@@ -160,6 +160,9 @@ INSN: ##set-alien-double < ##alien-setter ;
 
 ! Memory allocation
 INSN: ##allot < ##flushable size class { temp vreg } ;
+
+UNION: ##allocation ##allot ##box-float ##box-alien ##integer>bignum ;
+
 INSN: ##write-barrier < ##effect card# table ;
 
 INSN: ##alien-global < ##read symbol library ;
@@ -225,7 +228,7 @@ INSN: _epilogue stack-frame ;
 
 INSN: _label id ;
 
-INSN: _gc ;
+INSN: _gc live-in ;
 
 INSN: _branch label ;
 
index 9d80a2b28e90f8c67e2b7a837b01fc093de8da9b..64507779a4080cd20798dfee9e0ff8bc276ec66c 100755 (executable)
@@ -1,9 +1,11 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math accessors sequences namespaces make
-combinators classes
+combinators assocs
+cpu.architecture
 compiler.cfg
 compiler.cfg.rpo
+compiler.cfg.liveness
 compiler.cfg.instructions ;
 IN: compiler.cfg.linearization
 
@@ -18,7 +20,7 @@ M: insn linearize-insn , drop ;
 : useless-branch? ( basic-block successor -- ? )
     #! If our successor immediately follows us in RPO, then we
     #! don't need to branch.
-    [ number>> ] bi@ 1- = ; inline
+    [ number>> ] bi@ 1 - = ; inline
 
 : branch-to-branch? ( successor -- ? )
     #! A branch to a block containing just a jump return is cloned.
@@ -56,18 +58,14 @@ M: ##compare-float-branch linearize-insn
     binary-conditional _compare-float-branch emit-branch ;
 
 : gc? ( bb -- ? )
-    instructions>> [
-        class {
-            ##allot
-            ##integer>bignum
-            ##box-float
-            ##box-alien
-        } memq?
-    ] any? ;
+    instructions>> [ ##allocation? ] any? ;
+
+: object-pointer-regs ( basic-block -- vregs )
+    live-in keys [ reg-class>> int-regs eq? ] filter ;
 
 : linearize-basic-block ( bb -- )
     [ number>> _label ]
-    [ gc? [ _gc ] when ]
+    [ dup gc? [ object-pointer-regs _gc ] [ drop ] if ]
     [ linearize-insns ]
     tri ;