clay: add %sweep scry to verify refcounts

This commit is contained in:
Philip Monk 2022-05-03 21:59:56 -07:00
parent d59fb3a82b
commit 53353cde11

View File

@ -4881,6 +4881,7 @@
?~ path
~
?+ i.path ~
%sweep ``[%sweep !>(sweep)]
%rang ``[%rang !>(ran.ruf)]
%domes
=/ domes
@ -4902,6 +4903,57 @@
[[ship desk] [let hit lab]:dom.rede]
``[%domes !>(`cone`domes)]
==
::
++ sweep
^- (list [need=@ud have=@ud leak])
=/ marked=(map leak [need=@ud have=@ud])
(~(run by fad.ruf) |=([refs=@ud *] [0 refs]))
=. marked
=/ items=(list [=leak *]) ~(tap by fad.ruf)
|- ^+ marked
?~ items
marked
=/ deps ~(tap in deps.leak.i.items)
|- ^+ marked
?~ deps
^$(items t.items)
=. marked
%+ ~(put by marked) i.deps
=/ gut (~(gut by marked) i.deps [0 0])
[+(-.gut) +.gut]
$(deps t.deps)
::
=/ spills=(list (set leak))
%+ welp
%+ turn ~(tap by dos.rom.ruf)
|= [* =dojo]
spill.fod.dom.dojo
%- zing
%+ turn ~(tap by hoy.ruf)
|= [* =rung]
%+ turn ~(tap by rus.rung)
|= [* =rede]
spill.fod.dom.rede
::
=. marked
|-
?~ spills
marked
=/ leaks ~(tap in i.spills)
|-
?~ leaks
^$(spills t.spills)
=. marked
%+ ~(put by marked) i.leaks
=/ gut (~(gut by marked) i.leaks [0 0])
[+(-.gut) +.gut]
$(leaks t.leaks)
::
%+ murn ~(tap by marked)
|= [=leak need=@ud have=@ud]
?: =(need have)
~
`u=[need have leak]
--
::
:: We clear the ford cache by replacing it with its bunt as a literal.