diff --git a/basis/compiler/cfg/stacks/uninitialized/uninitialized-docs.factor b/basis/compiler/cfg/stacks/uninitialized/uninitialized-docs.factor deleted file mode 100644 index a39d4cfdc9..0000000000 --- a/basis/compiler/cfg/stacks/uninitialized/uninitialized-docs.factor +++ /dev/null @@ -1,6 +0,0 @@ -USING: compiler.cfg compiler.cfg.instructions help.markup help.syntax ; -IN: compiler.cfg.stacks.uninitialized - -HELP: compute-uninitialized-sets -{ $values { "cfg" cfg } } -{ $description "Runs the uninitialized compiler pass. The pass serves two purposes; if a " { $link ##peek } " reads an uninitialized stack location, then an error is thrown. Second, it assigns the " { $slot "scrub-d" } " and " { $slot "scrub-r" } " slots of all " { $link gc-map } " instances in the cfg." } ; diff --git a/basis/compiler/cfg/stacks/uninitialized/uninitialized-tests.factor b/basis/compiler/cfg/stacks/uninitialized/uninitialized-tests.factor deleted file mode 100644 index fb9c833136..0000000000 --- a/basis/compiler/cfg/stacks/uninitialized/uninitialized-tests.factor +++ /dev/null @@ -1,60 +0,0 @@ -USING: compiler.cfg.stacks.uninitialized compiler.cfg.debugger -compiler.cfg.registers compiler.cfg.instructions compiler.cfg -compiler.cfg.predecessors cpu.architecture tools.test kernel vectors -namespaces accessors sequences ; -IN: compiler.cfg.stacks.uninitialized.tests - -: test-uninitialized ( -- ) - cfg new 0 get >>entry - compute-uninitialized-sets ; - -V{ - T{ ##inc-d f 3 } -} 0 test-bb - -V{ - T{ ##replace f 0 D 0 } - T{ ##replace f 0 D 1 } - T{ ##replace f 0 D 2 } - T{ ##inc-r f 1 } -} 1 test-bb - -V{ - T{ ##peek f 0 D 0 } - T{ ##inc-d f 1 } -} 2 test-bb - -0 1 edge -1 2 edge - -[ ] [ test-uninitialized ] unit-test - -[ { B{ 0 0 0 } B{ } } ] [ 1 get uninitialized-in ] unit-test -[ { B{ 1 1 1 } B{ 0 } } ] [ 2 get uninitialized-in ] unit-test - -! When merging, if a location is uninitialized in one branch and -! initialized in another, we have to consider it uninitialized, -! since it cannot be safely read from by a ##peek, or traced by GC. - -V{ } 0 test-bb - -V{ - T{ ##inc-d f 1 } -} 1 test-bb - -V{ - T{ ##call f namestack } - T{ ##branch } -} 2 test-bb - -V{ - T{ ##return } -} 3 test-bb - -0 { 1 2 } edges -1 3 edge -2 3 edge - -[ ] [ test-uninitialized ] unit-test - -[ { B{ 0 } B{ } } ] [ 3 get uninitialized-in ] unit-test diff --git a/basis/compiler/cfg/stacks/uninitialized/uninitialized.factor b/basis/compiler/cfg/stacks/uninitialized/uninitialized.factor deleted file mode 100644 index 025541e1f3..0000000000 --- a/basis/compiler/cfg/stacks/uninitialized/uninitialized.factor +++ /dev/null @@ -1,81 +0,0 @@ -! Copyright (C) 2009, 2010 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: kernel sequences byte-arrays namespaces accessors classes math -math.order fry arrays combinators compiler.cfg.registers -compiler.cfg.instructions compiler.cfg.dataflow-analysis ; -IN: compiler.cfg.stacks.uninitialized - -! Uninitialized stack location analysis. - -! Consider the following sequence of instructions: -! ##inc-d 2 -! ... -! ##allot -! ##replace ... D 0 -! ##replace ... D 1 -! The GC check runs before stack locations 0 and 1 have been -! initialized, and so the GC needs to scrub them so that they -! don't get traced. This is achieved by computing uninitialized -! locations with a dataflow analysis, and recording the -! information in GC maps. The scrub_contexts() method on -! vm/gc.cpp reads this information from GC maps and performs -! the scrubbing. - - ] [ prepend ] } - } cond - ] change ; - -M: ##inc-d visit-insn n>> ds-loc handle-inc ; -M: ##inc-r visit-insn n>> rs-loc handle-inc ; - -ERROR: uninitialized-peek insn ; - -: visit-peek ( ##peek -- ) - dup loc>> [ n>> ] [ class-of get ] bi ?nth 0 = - [ uninitialized-peek ] [ drop ] if ; inline - -M: ##peek visit-insn visit-peek ; - -: visit-replace ( ##replace -- ) - loc>> [ n>> ] [ class-of get ] bi - 2dup length < [ [ 1 ] 2dip set-nth ] [ 2drop ] if ; - -M: ##replace visit-insn visit-replace ; -M: ##replace-imm visit-insn visit-replace ; - -M: gc-map-insn visit-insn - gc-map>> - ds-loc get clone >>scrub-d - rs-loc get clone >>scrub-r - drop ; - -M: insn visit-insn drop ; - -: prepare ( pair -- ) - [ first2 [ [ clone ] [ B{ } ] if* ] bi@ ] [ B{ } B{ } ] if* - [ ds-loc set ] [ rs-loc set ] bi* ; - -: visit-block ( bb -- ) instructions>> [ visit-insn ] each ; - -: finish ( -- pair ) ds-loc get rs-loc get 2array ; - -: (join-sets) ( seq1 seq2 -- seq ) - 2dup max-length '[ _ 1 pad-tail ] bi@ [ bitand ] 2map ; - -PRIVATE> - -FORWARD-ANALYSIS: uninitialized - -M: uninitialized-analysis transfer-set ( pair bb analysis -- pair' ) - drop [ prepare ] dip visit-block finish ; - -M: uninitialized-analysis join-sets ( sets bb dfa -- set ) - 2drop sift [ f ] [ [ ] [ [ (join-sets) ] 2map ] map-reduce ] if-empty ;