compiler.cfg.linear-scan.allocation: fix broken spill slot reuse logic

db4
Slava Pestov 2009-07-10 00:25:46 -05:00
parent 7edb2df01c
commit dea872c7e3
3 changed files with 15 additions and 18 deletions
basis/compiler/cfg/linear-scan/allocation

View File

@ -1,6 +1,6 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel sequences
USING: accessors kernel sequences namespaces assocs fry
combinators.short-circuit
compiler.cfg.linear-scan.live-intervals
compiler.cfg.linear-scan.allocation.state ;
@ -20,9 +20,16 @@ IN: compiler.cfg.linear-scan.allocation.coalescing
[ avoids-inactive-intervals? ]
} 1&& ;
: reuse-spill-slot ( old new -- )
[ vreg>> spill-slots get at ] dip '[ _ vreg>> spill-slots get set-at ] when* ;
: reuse-register ( old new -- )
reg>> >>reg drop ;
: (coalesce) ( old new -- )
[ add-active ] [ [ delete-active ] [ add-handled ] bi ] bi* ;
: coalesce ( live-interval -- )
dup copy-from>> active-interval
[ [ add-active ] [ [ delete-active ] [ add-handled ] bi ] bi* ]
[ reg>> >>reg drop ]
2bi ;
[ reuse-spill-slot ] [ reuse-register ] [ (coalesce) ] 2tri ;

View File

@ -38,10 +38,10 @@ ERROR: bad-live-ranges interval ;
} 2cleave ;
: assign-spill ( live-interval -- )
dup assign-spill-slot >>spill-to f >>split-next drop ;
dup vreg>> assign-spill-slot >>spill-to f >>split-next drop ;
: assign-reload ( live-interval -- )
dup assign-spill-slot >>reload-from drop ;
dup vreg>> assign-spill-slot >>reload-from drop ;
: split-and-spill ( live-interval n -- before after )
split-for-spill 2dup [ assign-spill ] [ assign-reload ] bi* ;

View File

@ -126,18 +126,8 @@ SYMBOL: spill-counts
! Mapping from vregs to spill slots
SYMBOL: spill-slots
DEFER: assign-spill-slot
: compute-spill-slot ( live-interval -- n )
dup copy-from>>
[ assign-spill-slot ]
[ vreg>> reg-class>> next-spill-slot ] ?if ;
: assign-spill-slot ( live-interval -- n )
dup vreg>> spill-slots get at [ ] [
[ compute-spill-slot dup ] keep
vreg>> spill-slots get set-at
] ?if ;
: assign-spill-slot ( vreg -- n )
spill-slots get [ reg-class>> next-spill-slot ] cache ;
: init-allocator ( registers -- )
registers set