Add a new ##allocation union to remove some code duplication

db4
Slava Pestov 2009-05-27 18:55:49 -05:00
parent 2025823ba6
commit 3b79d61496
3 changed files with 15 additions and 24 deletions

View File

@ -220,17 +220,7 @@ M: ##load-reference analyze-aliases*
M: ##alien-global analyze-aliases* M: ##alien-global analyze-aliases*
dup dst>> set-heap-ac ; dup dst>> set-heap-ac ;
M: ##allot analyze-aliases* M: ##allocation 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*
#! A freshly allocated object is distinct from any other #! A freshly allocated object is distinct from any other
#! object. #! object.
dup dst>> set-new-ac ; dup dst>> set-new-ac ;

View File

@ -160,6 +160,9 @@ INSN: ##set-alien-double < ##alien-setter ;
! Memory allocation ! Memory allocation
INSN: ##allot < ##flushable size class { temp vreg } ; INSN: ##allot < ##flushable size class { temp vreg } ;
UNION: ##allocation ##allot ##box-float ##box-alien ##integer>bignum ;
INSN: ##write-barrier < ##effect card# table ; INSN: ##write-barrier < ##effect card# table ;
INSN: ##alien-global < ##read symbol library ; INSN: ##alien-global < ##read symbol library ;
@ -225,7 +228,7 @@ INSN: _epilogue stack-frame ;
INSN: _label id ; INSN: _label id ;
INSN: _gc ; INSN: _gc live-in ;
INSN: _branch label ; INSN: _branch label ;

View File

@ -1,9 +1,11 @@
! Copyright (C) 2008 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 math accessors sequences namespaces make USING: kernel math accessors sequences namespaces make
combinators classes combinators assocs
cpu.architecture
compiler.cfg compiler.cfg
compiler.cfg.rpo compiler.cfg.rpo
compiler.cfg.liveness
compiler.cfg.instructions ; compiler.cfg.instructions ;
IN: compiler.cfg.linearization IN: compiler.cfg.linearization
@ -56,18 +58,14 @@ M: ##compare-float-branch linearize-insn
binary-conditional _compare-float-branch emit-branch ; binary-conditional _compare-float-branch emit-branch ;
: gc? ( bb -- ? ) : gc? ( bb -- ? )
instructions>> [ instructions>> [ ##allocation? ] any? ;
class {
##allot : object-pointer-regs ( basic-block -- vregs )
##integer>bignum live-in keys [ reg-class>> int-regs eq? ] filter ;
##box-float
##box-alien
} memq?
] any? ;
: linearize-basic-block ( bb -- ) : linearize-basic-block ( bb -- )
[ number>> _label ] [ number>> _label ]
[ gc? [ _gc ] when ] [ dup gc? [ object-pointer-regs _gc ] [ drop ] if ]
[ linearize-insns ] [ linearize-insns ]
tri ; tri ;