]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.cfg.linear-scan.*: refactoring to simplify init-allocator and get rid of...
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 14 Dec 2014 17:59:14 +0000 (18:59 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Mon, 15 Dec 2014 19:44:06 +0000 (20:44 +0100)
basis/compiler/cfg/linear-scan/allocation/allocation.factor
basis/compiler/cfg/linear-scan/allocation/state/state.factor
basis/compiler/cfg/linear-scan/assignment/assignment.factor

index 8e3826116b63918692ef59e74815bfa63d5a6031..73049ec0d99da83866adf304430744ae034c7f07 100644 (file)
@@ -76,7 +76,6 @@ M: sync-point handle ( sync-point -- )
 
 : allocate-registers ( live-intervals sync-point machine-registers -- live-intervals )
     init-allocator
-    init-unhandled
     unhandled-intervals get unhandled-sync-points get (allocate-registers)
     finish-allocation
     handled-intervals get ;
index 0460ec2a67b20f6f36bf96dc38112b5c75890941..deb05fbee2dea741aace68e92362ef0a058e161c 100644 (file)
@@ -22,6 +22,12 @@ SYMBOL: progress
 : check-handled ( live-interval -- )
     end>> progress get > [ "check-handled" throw ] when ; inline
 
+: live-intervals>min-heap ( live-intervals -- min-heap )
+    [ [ start>> ] map ] keep zip >min-heap ;
+
+: sync-points>min-heap ( sync-points -- min-heap )
+    [ [ n>> ] map ] keep zip >min-heap ;
+
 ! Mapping from register classes to sequences of machine registers
 SYMBOL: registers
 
@@ -108,7 +114,6 @@ ERROR: register-already-used live-interval ;
         [ don't-change ]
     } process-intervals ;
 
-! Minheap of live intervals which still need a register allocation
 SYMBOL: unhandled-intervals
 
 : add-unhandled ( live-interval -- )
@@ -127,7 +132,6 @@ SYMBOL: unhandled-intervals
 : align-spill-area ( align -- )
     cfg get [ max ] change-spill-area-align drop ;
 
-! Minheap of sync points which still need to be processed
 SYMBOL: unhandled-sync-points
 
 SYMBOL: spill-slots
@@ -141,10 +145,11 @@ SYMBOL: spill-slots
 : lookup-spill-slot ( coalesced-vreg rep -- spill-slot )
     rep-size 2array spill-slots get ?at [ ] [ bad-vreg ] if ;
 
-: init-allocator ( registers -- )
+: init-allocator ( live-intervals sync-points registers -- )
     registers set
-    <min-heap> unhandled-intervals set
-    <min-heap> unhandled-sync-points set
+    [ live-intervals>min-heap unhandled-intervals set ]
+    [ sync-points>min-heap unhandled-sync-points set ] bi*
+
     [ V{ } clone ] reg-class-assoc active-intervals set
     [ V{ } clone ] reg-class-assoc inactive-intervals set
     V{ } clone handled-intervals set
@@ -152,10 +157,6 @@ SYMBOL: spill-slots
     H{ } clone spill-slots set
     -1 progress set ;
 
-: init-unhandled ( live-intervals sync-points -- )
-    [ unhandled-intervals get '[ dup start>> _ heap-push ] each ]
-    [ unhandled-sync-points get '[ dup n>> _ heap-push ] each ]
-    bi* ;
 
 ! A utility used by register-status and spill-status words
 : free-positions ( new -- assoc )
index 54f3600052c1bc39b8922a1c24fb6c3a4d453b13..8ca20183a8b026e20e3d0c33fe293ae150f5fa9e 100644 (file)
@@ -38,9 +38,6 @@ ERROR: not-spilled-error vreg ;
 
 SYMBOL: unhandled-intervals
 
-: init-unhandled ( live-intervals -- unhandled-intervals  )
-    [ dup start>> swap 2array ] map >min-heap  ;
-
 ! Liveness info is used by resolve pass
 SYMBOL: machine-live-ins
 
@@ -70,7 +67,7 @@ SYMBOL: machine-live-outs
     [ live-out keys vregs>regs ] keep machine-live-outs get set-at ;
 
 : init-assignment ( live-intervals -- )
-    init-unhandled unhandled-intervals set
+    live-intervals>min-heap unhandled-intervals set
     <min-heap> pending-interval-heap set
     H{ } clone pending-interval-assoc set
     H{ } clone machine-live-ins set