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 ;
! 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 ;
INSN: _label id ;
-INSN: _gc ;
+INSN: _gc live-in ;
INSN: _branch label ;
-! 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
: 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.
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 ;