]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/linear-scan/debugger/debugger.factor
Merge branch 'thead' of git://github.com/phildawes/factor
[factor.git] / basis / compiler / cfg / linear-scan / debugger / debugger.factor
1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel sequences sets arrays math strings fry
4 namespaces prettyprint compiler.cfg.linear-scan.live-intervals
5 compiler.cfg.linear-scan.allocation compiler.cfg assocs ;
6 IN: compiler.cfg.linear-scan.debugger
7
8 : check-assigned ( live-intervals -- )
9     [
10         reg>>
11         [ "Not all intervals have registers" throw ] unless
12     ] each ;
13
14 : split-children ( live-interval -- seq )
15     dup split-before>> [
16         [ split-before>> ] [ split-after>> ] bi
17         [ split-children ] bi@
18         append
19     ] [ 1array ] if ;
20
21 : check-linear-scan ( live-intervals machine-registers -- )
22     [
23         [ clone ] map dup [ [ vreg>> ] keep ] H{ } map>assoc
24         live-intervals set
25     ] dip allocate-registers
26     [ split-children ] map concat check-assigned ;
27
28 : picture ( uses -- str )
29     dup last 1 + CHAR: space <string>
30     [ '[ CHAR: * swap _ set-nth ] each ] keep ;
31
32 : interval-picture ( interval -- str )
33     [ uses>> picture ]
34     [ copy-from>> unparse ]
35     [ vreg>> unparse ]
36     tri 3array ;
37
38 : live-intervals. ( seq -- )
39     [ interval-picture ] map simple-table. ;