Merge branch 'master' of git://factorcode.org/git/factor into s3
Conflicts: basis/compiler/cfg/finalization/finalization.factordb4
commit
277705345f
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel math namespaces assocs hashtables sequences arrays
|
USING: kernel math namespaces assocs hashtables sequences arrays
|
||||||
accessors words vectors combinators combinators.short-circuit
|
accessors words vectors combinators combinators.short-circuit
|
||||||
sets classes layouts cpu.architecture
|
sets classes layouts fry cpu.architecture
|
||||||
compiler.cfg
|
compiler.cfg
|
||||||
compiler.cfg.rpo
|
compiler.cfg.rpo
|
||||||
compiler.cfg.def-use
|
compiler.cfg.def-use
|
||||||
|
@ -100,6 +100,15 @@ SYMBOL: acs>vregs
|
||||||
: each-alias ( vreg quot -- )
|
: each-alias ( vreg quot -- )
|
||||||
[ aliases ] dip each ; inline
|
[ aliases ] dip each ; inline
|
||||||
|
|
||||||
|
: merge-acs ( vreg into -- )
|
||||||
|
[ vreg>ac ] dip
|
||||||
|
2dup eq? [ 2drop ] [
|
||||||
|
[ ac>vregs ] dip
|
||||||
|
[ vregs>acs get '[ [ _ ] dip _ set-at ] each ]
|
||||||
|
[ acs>vregs get at push-all ]
|
||||||
|
2bi
|
||||||
|
] if ;
|
||||||
|
|
||||||
! Map vregs -> slot# -> vreg
|
! Map vregs -> slot# -> vreg
|
||||||
SYMBOL: live-slots
|
SYMBOL: live-slots
|
||||||
|
|
||||||
|
@ -187,7 +196,8 @@ SYMBOL: heap-ac
|
||||||
: remember-set-slot ( slot#/f vreg -- )
|
: remember-set-slot ( slot#/f vreg -- )
|
||||||
over [
|
over [
|
||||||
[ record-constant-set-slot ]
|
[ record-constant-set-slot ]
|
||||||
[ kill-constant-set-slot ] 2bi
|
[ kill-constant-set-slot ]
|
||||||
|
2bi
|
||||||
] [ nip kill-computed-set-slot ] if ;
|
] [ nip kill-computed-set-slot ] if ;
|
||||||
|
|
||||||
GENERIC: insn-slot# ( insn -- slot#/f )
|
GENERIC: insn-slot# ( insn -- slot#/f )
|
||||||
|
@ -262,7 +272,10 @@ M: ##write analyze-aliases*
|
||||||
dup
|
dup
|
||||||
[ src>> resolve ] [ insn-slot# ] [ insn-object ] tri
|
[ src>> resolve ] [ insn-slot# ] [ insn-object ] tri
|
||||||
3dup idempotent? [ 3drop ] [
|
3dup idempotent? [ 3drop ] [
|
||||||
[ remember-set-slot drop ] [ load-slot ] 3bi
|
[ 2drop heap-ac get merge-acs ]
|
||||||
|
[ remember-set-slot drop ]
|
||||||
|
[ load-slot ]
|
||||||
|
3tri
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
M: ##copy analyze-aliases*
|
M: ##copy analyze-aliases*
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
! Copyright (C) 2008, 2009 Slava Pestov.
|
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
|
||||||
USING: kernel accessors sequences namespaces combinators
|
|
||||||
combinators.short-circuit classes vectors compiler.cfg
|
|
||||||
compiler.cfg.instructions compiler.cfg.rpo ;
|
|
||||||
IN: compiler.cfg.empty-blocks
|
|
||||||
|
|
||||||
<PRIVATE
|
|
||||||
|
|
||||||
: update-predecessor ( bb -- )
|
|
||||||
! We have to replace occurrences of bb with bb's successor
|
|
||||||
! in bb's predecessor's list of successors.
|
|
||||||
dup predecessors>> first [
|
|
||||||
[
|
|
||||||
2dup eq? [ drop successors>> first ] [ nip ] if
|
|
||||||
] with map
|
|
||||||
] change-successors drop ;
|
|
||||||
|
|
||||||
: update-successor ( bb -- )
|
|
||||||
! We have to replace occurrences of bb with bb's predecessor
|
|
||||||
! in bb's sucessor's list of predecessors.
|
|
||||||
dup successors>> first [
|
|
||||||
[
|
|
||||||
2dup eq? [ drop predecessors>> first ] [ nip ] if
|
|
||||||
] with map
|
|
||||||
] change-predecessors drop ;
|
|
||||||
|
|
||||||
SYMBOL: changed?
|
|
||||||
|
|
||||||
: delete-basic-block ( bb -- )
|
|
||||||
[ update-predecessor ] [ update-successor ] bi
|
|
||||||
changed? on ;
|
|
||||||
|
|
||||||
: delete-basic-block? ( bb -- ? )
|
|
||||||
{
|
|
||||||
[ instructions>> length 1 = ]
|
|
||||||
[ predecessors>> length 1 = ]
|
|
||||||
[ successors>> length 1 = ]
|
|
||||||
[ instructions>> first ##branch? ]
|
|
||||||
} 1&& ;
|
|
||||||
|
|
||||||
PRIVATE>
|
|
||||||
|
|
||||||
: delete-empty-blocks ( cfg -- cfg' )
|
|
||||||
changed? off
|
|
||||||
dup [ dup delete-basic-block? [ delete-basic-block ] [ drop ] if ] each-basic-block
|
|
||||||
changed? get [ cfg-changed ] when ;
|
|
|
@ -1,9 +1,9 @@
|
||||||
! Copyright (C) 2010 Slava Pestov.
|
! Copyright (C) 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: compiler.cfg.empty-blocks compiler.cfg.gc-checks
|
USING: compiler.cfg.gc-checks compiler.cfg.representations
|
||||||
compiler.cfg.representations compiler.cfg.save-contexts
|
compiler.cfg.save-contexts compiler.cfg.ssa.destruction
|
||||||
compiler.cfg.ssa.destruction compiler.cfg.build-stack-frame
|
compiler.cfg.build-stack-frame compiler.cfg.linear-scan
|
||||||
compiler.cfg.linear-scan compiler.cfg.scheduling ;
|
compiler.cfg.scheduling ;
|
||||||
IN: compiler.cfg.finalization
|
IN: compiler.cfg.finalization
|
||||||
|
|
||||||
: finalize-cfg ( cfg -- cfg' )
|
: finalize-cfg ( cfg -- cfg' )
|
||||||
|
|
|
@ -10,13 +10,7 @@ compiler.cfg.alias-analysis
|
||||||
compiler.cfg.value-numbering
|
compiler.cfg.value-numbering
|
||||||
compiler.cfg.copy-prop
|
compiler.cfg.copy-prop
|
||||||
compiler.cfg.dce
|
compiler.cfg.dce
|
||||||
compiler.cfg.write-barrier
|
compiler.cfg.write-barrier ;
|
||||||
compiler.cfg.representations
|
|
||||||
compiler.cfg.gc-checks
|
|
||||||
compiler.cfg.save-contexts
|
|
||||||
compiler.cfg.ssa.destruction
|
|
||||||
compiler.cfg.empty-blocks
|
|
||||||
compiler.cfg.checker ;
|
|
||||||
IN: compiler.cfg.optimizer
|
IN: compiler.cfg.optimizer
|
||||||
|
|
||||||
: optimize-cfg ( cfg -- cfg' )
|
: optimize-cfg ( cfg -- cfg' )
|
||||||
|
|
Loading…
Reference in New Issue