compiler.cfg.linear-scan.allocation: fix broken spill slot reuse logic
parent
7edb2df01c
commit
dea872c7e3
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors kernel sequences
|
USING: accessors kernel sequences namespaces assocs fry
|
||||||
combinators.short-circuit
|
combinators.short-circuit
|
||||||
compiler.cfg.linear-scan.live-intervals
|
compiler.cfg.linear-scan.live-intervals
|
||||||
compiler.cfg.linear-scan.allocation.state ;
|
compiler.cfg.linear-scan.allocation.state ;
|
||||||
|
@ -20,9 +20,16 @@ IN: compiler.cfg.linear-scan.allocation.coalescing
|
||||||
[ avoids-inactive-intervals? ]
|
[ avoids-inactive-intervals? ]
|
||||||
} 1&& ;
|
} 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 -- )
|
: coalesce ( live-interval -- )
|
||||||
dup copy-from>> active-interval
|
dup copy-from>> active-interval
|
||||||
[ [ add-active ] [ [ delete-active ] [ add-handled ] bi ] bi* ]
|
[ reuse-spill-slot ] [ reuse-register ] [ (coalesce) ] 2tri ;
|
||||||
[ reg>> >>reg drop ]
|
|
||||||
2bi ;
|
|
||||||
|
|
|
@ -38,10 +38,10 @@ ERROR: bad-live-ranges interval ;
|
||||||
} 2cleave ;
|
} 2cleave ;
|
||||||
|
|
||||||
: assign-spill ( live-interval -- )
|
: 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 -- )
|
: 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-and-spill ( live-interval n -- before after )
|
||||||
split-for-spill 2dup [ assign-spill ] [ assign-reload ] bi* ;
|
split-for-spill 2dup [ assign-spill ] [ assign-reload ] bi* ;
|
||||||
|
|
|
@ -126,18 +126,8 @@ SYMBOL: spill-counts
|
||||||
! Mapping from vregs to spill slots
|
! Mapping from vregs to spill slots
|
||||||
SYMBOL: spill-slots
|
SYMBOL: spill-slots
|
||||||
|
|
||||||
DEFER: assign-spill-slot
|
: assign-spill-slot ( vreg -- n )
|
||||||
|
spill-slots get [ reg-class>> next-spill-slot ] cache ;
|
||||||
: 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 ;
|
|
||||||
|
|
||||||
: init-allocator ( registers -- )
|
: init-allocator ( registers -- )
|
||||||
registers set
|
registers set
|
||||||
|
|
Loading…
Reference in New Issue