| 1 |
|
| 2 |
|
| 3 |
for every frame index i: |
| 4 |
|
| 5 |
S_i = { variable: non-empty-set-of-sources } |
| 6 |
|
| 7 |
source = a variable popped by gc_pop_roots from frame index 'i', |
| 8 |
only looking at the last gc_pop_roots in each block |
| 9 |
keys = variables that appear in inputargs, where a value from a |
| 10 |
'source' can come from |
| 11 |
|
| 12 |
G_i = { variable: non-empty-set-of-targets } |
| 13 |
|
| 14 |
target = a variable pushed by gc_push_roots into frame index 'i', |
| 15 |
only looking at the first gc_push_roots in each block |
| 16 |
keys = variables that appear in inputargs, where a value can |
| 17 |
end up in a 'target' |
| 18 |
|
| 19 |
M_i = S_i intersection G_i |
| 20 |
|
| 21 |
"variable in M_i" <==> at the start of this block, this variable's |
| 22 |
value is already saved in the frame index i (provided "success" below) |
| 23 |
|
| 24 |
split M_i into a partition of independent parts; add (i, P), (i, P'), ... |
| 25 |
to the global list |
| 26 |
|
| 27 |
|
| 28 |
for every (i, P), ideally in some suitable order: |
| 29 |
|
| 30 |
for every variable in P, for every link entering this block: |
| 31 |
|
| 32 |
if prevblock's corresponding variable is from the last gc_pop_roots |
| 33 |
of that block, at index i: |
| 34 |
|
| 35 |
*success = True* |
| 36 |
|
| 37 |
elif prevblock's corresponding variable is not in P: |
| 38 |
|
| 39 |
mark the link |
| 40 |
|
| 41 |
if success: |
| 42 |
|
| 43 |
insert a new gc_save_root() along all links marked above; |
| 44 |
remove the original gc_save_root |
| 45 |
|
| 46 |
for any P' after P that has any variables in common, kill that P' |