USING: accessors arrays assocs combinators compiler.cfg.dataflow-analysis
-compiler.cfg.instructions compiler.cfg.registers fry kernel math math.order
-namespaces sequences ;
+compiler.cfg.instructions compiler.cfg.linearization compiler.cfg.registers fry
+kernel math math.order namespaces sequences ;
QUALIFIED: sets
IN: compiler.cfg.stacks.map
SYMBOL: stack-record
+: register-stack-state ( state insn -- )
+ insn#>> stack-record get 2dup at f assert= set-at ;
+
M: map-analysis transfer-set ( in-set bb dfa -- out-set )
drop instructions>> swap [
- [ stack-record get set-at ] [ visit-insn ] 2bi
+ [ register-stack-state ] [ visit-insn ] 2bi
] reduce ;
M: map-analysis ignore-block? ( bb dfa -- ? )
M: map-analysis join-sets ( sets bb dfa -- set )
2drop [ initial-state ] [ first ] if-empty ;
+: uniquely-number-instructions ( cfg -- )
+ cfg>insns [ swap insn#<< ] each-index ;
+
: trace-stack-state ( cfg -- assoc )
- H{ } clone stack-record set compute-map-sets stack-record get ;
+ H{ } clone stack-record set
+ [ uniquely-number-instructions ] [ compute-map-sets ] bi
+ stack-record get ;
USING: accessors arrays assocs compiler.cfg.instructions
-compiler.cfg.stacks.map fry kernel math sequences ;
+compiler.cfg.linearization compiler.cfg.stacks.map fry kernel math sequences ;
IN: compiler.cfg.stacks.vacant
! ! Utils
{ >>scrub-d >>check-d >>scrub-r >>check-r } write-slots ;
: fill-gc-maps ( cfg -- )
- trace-stack-state [ drop gc-map-insn? ] assoc-filter
- [ swap gc-map>> set-gc-map ] assoc-each ;
+ [ trace-stack-state ] [ cfg>insns [ gc-map-insn? ] filter ] bi
+ [ [ insn#>> of ] [ gc-map>> ] bi set-gc-map ] with each ;