compiler.cfg.stacks.uninitialized: this compiler pass isn't used anymore -- let's get rid of it

db4
Björn Lindqvist 2014-12-08 23:46:08 +01:00
parent 8744d908b6
commit a0d4e9b417
3 changed files with 0 additions and 147 deletions

View File

@ -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." } ;

View File

@ -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

View File

@ -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.
<PRIVATE
GENERIC: visit-insn ( insn -- )
: handle-inc ( n symbol -- )
[
swap {
{ [ dup 0 < ] [ neg short tail ] }
{ [ dup 0 > ] [ <byte-array> 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 ;