compiler.cfg.stacks.vacant: more docs and removed usage of byte-arrays
parent
ab5e629243
commit
ecead801c1
|
|
@ -1,4 +1,4 @@
|
||||||
USING: help.markup help.syntax sequences strings ;
|
USING: compiler.cfg.instructions help.markup help.syntax sequences strings ;
|
||||||
IN: compiler.cfg.stacks.vacant
|
IN: compiler.cfg.stacks.vacant
|
||||||
|
|
||||||
ARTICLE: "compiler.cfg.stacks.vacant" "Uninitialized/overinitialized stack location analysis"
|
ARTICLE: "compiler.cfg.stacks.vacant" "Uninitialized/overinitialized stack location analysis"
|
||||||
|
|
@ -12,4 +12,21 @@ ARTICLE: "compiler.cfg.stacks.vacant" "Uninitialized/overinitialized stack locat
|
||||||
}
|
}
|
||||||
"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." ;
|
"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." ;
|
||||||
|
|
||||||
|
HELP: initial-state
|
||||||
|
{ $description "Initially the stack bottom is at 0 for both the data and retain stacks and no replaces have been registered." } ;
|
||||||
|
|
||||||
|
HELP: vacant>bit-pattern
|
||||||
|
{ $values
|
||||||
|
{ "vacant" "sequence of uninitialized stack locations" }
|
||||||
|
{ "bit-pattern" "sequence of 1:s and 0:s" }
|
||||||
|
}
|
||||||
|
{ $description "Converts a sequence of uninitialized stack locations to the pattern of 1:s and 0:s that can be put in the " { $slot "scrub-d" } " and " { $slot "scrub-r" } " slots of a " { $link gc-map } "." }
|
||||||
|
{ $examples
|
||||||
|
{ $example
|
||||||
|
"USING: compiler.cfg.stacks.vacant prettyprint ;"
|
||||||
|
"{ 0 1 3 } vacant>bit-pattern ."
|
||||||
|
"{ 0 0 1 0 }"
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
ABOUT: "compiler.cfg.stacks.vacant"
|
ABOUT: "compiler.cfg.stacks.vacant"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
USING: accessors arrays assocs compiler.cfg
|
USING: accessors arrays assocs compiler.cfg
|
||||||
compiler.cfg.dataflow-analysis.private compiler.cfg.instructions
|
compiler.cfg.dataflow-analysis.private compiler.cfg.instructions
|
||||||
compiler.cfg.registers compiler.cfg.stacks.vacant kernel math sequences
|
compiler.cfg.linearization compiler.cfg.registers compiler.cfg.stacks.vacant
|
||||||
sorting tools.test vectors ;
|
kernel math sequences sorting tools.test vectors ;
|
||||||
IN: compiler.cfg.stacks.vacant.tests
|
IN: compiler.cfg.stacks.vacant.tests
|
||||||
|
|
||||||
! Utils
|
! Utils
|
||||||
|
|
@ -72,7 +72,7 @@ IN: compiler.cfg.stacks.vacant.tests
|
||||||
! [
|
! [
|
||||||
! V{
|
! V{
|
||||||
! T{ ##replace { src 10 } { loc D -1 } }
|
! T{ ##replace { src 10 } { loc D -1 } }
|
||||||
! T{ ##alien-invoke { gc-map T{ gc-map { scrub-d B{ } } } } }
|
! T{ ##alien-invoke { gc-map T{ gc-map { scrub-d { } } } } }
|
||||||
! T{ ##peek { dst 0 } { loc D -1 } }
|
! T{ ##peek { dst 0 } { loc D -1 } }
|
||||||
! } create-cfg
|
! } create-cfg
|
||||||
! compute-vacant-sets
|
! compute-vacant-sets
|
||||||
|
|
@ -82,7 +82,7 @@ IN: compiler.cfg.stacks.vacant.tests
|
||||||
{ { -1 { -1 } } } [
|
{ { -1 { -1 } } } [
|
||||||
V{
|
V{
|
||||||
T{ ##replace { src 10 } { loc D 0 } }
|
T{ ##replace { src 10 } { loc D 0 } }
|
||||||
T{ ##alien-invoke { gc-map T{ gc-map { scrub-d B{ } } } } }
|
T{ ##alien-invoke { gc-map T{ gc-map { scrub-d { } } } } }
|
||||||
T{ ##inc-d f -1 }
|
T{ ##inc-d f -1 }
|
||||||
T{ ##peek { dst 0 } { loc D -1 } }
|
T{ ##peek { dst 0 } { loc D -1 } }
|
||||||
} create-cfg output-stack-map first
|
} create-cfg output-stack-map first
|
||||||
|
|
@ -92,14 +92,14 @@ IN: compiler.cfg.stacks.vacant.tests
|
||||||
! [
|
! [
|
||||||
! V{
|
! V{
|
||||||
! T{ ##inc-d f 1 }
|
! T{ ##inc-d f 1 }
|
||||||
! T{ ##alien-invoke { gc-map T{ gc-map { scrub-d B{ } } } } }
|
! T{ ##alien-invoke { gc-map T{ gc-map { scrub-d { } } } } }
|
||||||
! T{ ##peek { dst 0 } { loc D 0 } }
|
! T{ ##peek { dst 0 } { loc D 0 } }
|
||||||
! } create-cfg
|
! } create-cfg
|
||||||
! compute-vacant-sets
|
! compute-vacant-sets
|
||||||
! ] [ vacant-peek? ] must-fail-with
|
! ] [ vacant-peek? ] must-fail-with
|
||||||
|
|
||||||
! visit-insn should set the gc info.
|
! visit-insn should set the gc info.
|
||||||
{ B{ 0 0 } B{ } } [
|
{ { 0 0 } { } } [
|
||||||
{ { 2 { } } { 0 { } } }
|
{ { 2 { } } { 0 { } } }
|
||||||
T{ ##alien-invoke { gc-map T{ gc-map } } }
|
T{ ##alien-invoke { gc-map T{ gc-map } } }
|
||||||
[ visit-insn drop ] keep gc-map>> [ scrub-d>> ] [ scrub-r>> ] bi
|
[ visit-insn drop ] keep gc-map>> [ scrub-d>> ] [ scrub-r>> ] bi
|
||||||
|
|
@ -213,7 +213,7 @@ IN: compiler.cfg.stacks.vacant.tests
|
||||||
|
|
||||||
T{ ##inc-d f -3 }
|
T{ ##inc-d f -3 }
|
||||||
T{ ##peek { dst 0 } { loc D -3 } }
|
T{ ##peek { dst 0 } { loc D -3 } }
|
||||||
T{ ##alien-invoke { gc-map T{ gc-map { scrub-d B{ } } } } }
|
T{ ##alien-invoke { gc-map T{ gc-map { scrub-d { } } } } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} [ over create-block ] assoc-map dup
|
} [ over create-block ] assoc-map dup
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
USING: accessors arrays byte-arrays compiler.cfg.dataflow-analysis
|
USING: accessors arrays compiler.cfg.dataflow-analysis
|
||||||
compiler.cfg.instructions compiler.cfg.registers fry kernel math math.order
|
compiler.cfg.instructions compiler.cfg.registers fry kernel math math.order
|
||||||
sequences sets ;
|
sequences sets ;
|
||||||
IN: compiler.cfg.stacks.vacant
|
IN: compiler.cfg.stacks.vacant
|
||||||
|
|
@ -20,19 +20,17 @@ IN: compiler.cfg.stacks.vacant
|
||||||
: stack>vacant ( stack -- seq )
|
: stack>vacant ( stack -- seq )
|
||||||
first2 [ 0 max iota ] dip diff ;
|
first2 [ 0 max iota ] dip diff ;
|
||||||
|
|
||||||
: vacant>byte-array ( seq -- ba )
|
: vacant>bit-pattern ( vacant -- bit-pattern )
|
||||||
[ B{ } ] [
|
[ { } ] [
|
||||||
dup supremum 1 + 1 <array>
|
dup supremum 1 + 1 <array>
|
||||||
[ '[ _ 0 -rot set-nth ] each ] keep >byte-array
|
[ '[ _ 0 -rot set-nth ] each ] keep
|
||||||
] if-empty ;
|
] if-empty ;
|
||||||
|
|
||||||
! Operations on the analysis state
|
! Operations on the analysis state
|
||||||
: state>gc-map ( state -- pair )
|
: state>gc-map ( state -- pair )
|
||||||
[ stack>vacant vacant>byte-array ] map ;
|
[ stack>vacant vacant>bit-pattern ] map ;
|
||||||
|
|
||||||
! Stack bottom is 0 for d and r and no replaces.
|
CONSTANT: initial-state { { 0 { } } { 0 { } } }
|
||||||
: initial-state ( -- state )
|
|
||||||
{ { 0 { } } { 0 { } } } ;
|
|
||||||
|
|
||||||
: insn>gc-map ( insn -- pair )
|
: insn>gc-map ( insn -- pair )
|
||||||
gc-map>> [ scrub-d>> ] [ scrub-r>> ] bi 2array ;
|
gc-map>> [ scrub-d>> ] [ scrub-r>> ] bi 2array ;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue