2015-01-01 05:12:58 -05:00
|
|
|
USING: accessors arrays assocs compiler.cfg.instructions
|
2015-01-19 05:08:06 -05:00
|
|
|
compiler.cfg.linearization compiler.cfg.stacks.map fry kernel math sequences ;
|
2014-08-13 07:06:34 -04:00
|
|
|
IN: compiler.cfg.stacks.vacant
|
|
|
|
|
2015-01-01 05:12:58 -05:00
|
|
|
! ! Utils
|
2014-08-25 16:33:54 -04:00
|
|
|
: write-slots ( tuple values slots -- )
|
|
|
|
[ execute( x y -- z ) ] 2each drop ;
|
|
|
|
|
|
|
|
: vacant>bits ( vacant -- bits )
|
2014-08-25 12:55:27 -04:00
|
|
|
[ { } ] [
|
2014-08-13 07:06:34 -04:00
|
|
|
dup supremum 1 + 1 <array>
|
2014-08-25 12:55:27 -04:00
|
|
|
[ '[ _ 0 -rot set-nth ] each ] keep
|
2014-08-13 07:06:34 -04:00
|
|
|
] if-empty ;
|
|
|
|
|
|
|
|
! Operations on the analysis state
|
2014-08-25 16:33:54 -04:00
|
|
|
: state>gc-data ( state -- gc-data )
|
2015-03-04 15:06:42 -05:00
|
|
|
[ stack>vacant vacant>bits ] map ;
|
2014-08-13 07:06:34 -04:00
|
|
|
|
2014-08-25 16:33:54 -04:00
|
|
|
: set-gc-map ( state gc-map -- )
|
2015-03-04 15:06:42 -05:00
|
|
|
swap state>gc-data { >>scrub-d >>scrub-r } write-slots ;
|
|
|
|
! swap state>gc-data { { } { } } append
|
|
|
|
! { >>scrub-d >>scrub-r >>check-d >>check-r } write-slots ;
|
2014-08-13 07:06:34 -04:00
|
|
|
|
2015-01-01 05:12:58 -05:00
|
|
|
: fill-gc-maps ( cfg -- )
|
2015-01-19 05:08:06 -05:00
|
|
|
[ trace-stack-state ] [ cfg>insns [ gc-map-insn? ] filter ] bi
|
|
|
|
[ [ insn#>> of ] [ gc-map>> ] bi set-gc-map ] with each ;
|