T{ ##set-slot-imm f 2 1 3 4 }
} ] [ 2 get instructions>> ] unit-test
+V{
+ T{ ##allot f 1 }
+} 1 test-bb
+V{
+ T{ ##set-slot-imm f 2 1 3 4 }
+ T{ ##write-barrier f 1 2 3 }
+} 2 test-bb
+1 get 2 get 1vector >>successors drop
+cfg new 1 get >>entry 0 set
+
+[ ] [ 0 [ eliminate-write-barriers ] change ] unit-test
+[ V{
+ T{ ##allot f 1 }
+} ] [ 1 get instructions>> ] unit-test
+[ V{
+ T{ ##set-slot-imm f 2 1 3 4 }
+} ] [ 2 get instructions>> ] unit-test
+
V{
T{ ##set-slot-imm f 2 1 3 4 }
T{ ##write-barrier f 1 2 3 }
: has-allocation? ( bb -- ? )
instructions>> [ { [ ##allocation? ] [ ##call? ] } 1|| ] any? ;
+GENERIC: safe-slot ( insn -- slot ? )
+M: object safe-slot drop f f ;
+M: ##write-barrier safe-slot src>> t ;
+M: ##allot safe-slot dst>> t ;
+
M: safe-analysis transfer-set
drop [ H{ } assoc-clone-like ] dip
instructions>> over '[
- dup ##write-barrier? [
- src>> _ conjoin
- ] [ drop ] if
+ safe-slot [ _ conjoin ] [ drop ] if
] each ;
M: safe-analysis join-sets
instructions>> [ eliminate-write-barrier ] filter-here ;
: eliminate-write-barriers ( cfg -- cfg' )
- dup compute-safe-sets
+ dup compute-safe-sets
dup [ write-barriers-step ] each-basic-block ;