gall: virtualize scry

Compare +mute and +mule.  Those pass through scry, which doesn't allow us to
catch crashes due to blocking scry.  If you intercept scry, you can't preserve
the type polymorphically.  By monomorphizing, we are able to do so safely.
This commit is contained in:
Philip Monk 2019-11-21 14:45:56 -08:00
parent 1fb06fbcc2
commit 4fc1ade6ba
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
2 changed files with 33 additions and 5 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3bbcdd56cca219b1f9ae56951bfcc904ea61c20a516bb5519a7e19c1a5dbb064
size 9190612
oid sha256:ed6affa7a4c8d5b50f0f6235907173e9730b81f008712c753244b56e94bf18b5
size 9195975

View File

@ -156,7 +156,7 @@
eny=@uvJ
:: activate
::
ska=sley
ski=sley
==
~% %gall-top ..is ~
|%
@ -1040,7 +1040,7 @@
=/ tyl tyl.marked
::
=/ peek-result=(each (unit (unit cage)) tang)
(mule |.((on-peek:ap-agent-core [term tyl])))
(ap-mule-peek |.((on-peek:ap-agent-core [term tyl])))
::
?- -.peek-result
%& p.peek-result
@ -1303,6 +1303,34 @@
(ap-pass wire %agent dock %leave ~)
=/ way [%out (scot %p p.dock) q.dock wire]
(ap-pass way %arvo %b %huck !>([%unto %kick ~]))
:: +ap-mule: run virtualized with intercepted scry, preserving type
::
:: Compare +mute and +mule. Those pass through scry, which
:: doesn't allow us to catch crashes due to blocking scry. If
:: you intercept scry, you can't preserve the type
:: polymorphically. By monomorphizing, we are able to do so
:: safely.
::
++ ap-mule
|= run=_^?(|.(*step:agent))
^- (each step:agent tang)
=/ res (mock [run %9 2 %0 1] (sloy ski))
?- -.res
%0 [%& !<(step:agent [-:!>(*step:agent) p.res])]
%1 [%| (turn p.res |=(a=* (smyt (path a))))]
%2 [%| p.res]
==
:: +ap-mule-peek: same as +ap-mule but for (unit (unit cage))
::
++ ap-mule-peek
|= run=_^?(|.(*(unit (unit cage))))
^- (each (unit (unit cage)) tang)
=/ res (mock [run %9 2 %0 1] (sloy ski))
?- -.res
%0 [%& !<((unit (unit cage)) [-:!>(*(unit (unit cage))) p.res])]
%1 [%| (turn p.res |=(a=* (smyt (path a))))]
%2 [%| p.res]
==
:: +ap-ingest: call agent arm
::
:: Handle acks here because they need to be emitted before the
@ -1311,7 +1339,7 @@
++ ap-ingest
|= [ack=?(%poke-ack %watch-ack ~) run=_^?(|.(*step:agent))]
^- [(unit tang) _ap-core]
=/ result (mule run)
=/ result (ap-mule run)
=^ new-moves ap-core (ap-handle-result result)
=/ maybe-tang=(unit tang)
?: ?=(%& -.result)