winio: Fix #18382
Here we refactor WinIO's IO completion scheme, squashing a memory leak and fixing #18382 (closed).
To fix #18382 (closed) we drop the special thread status introduced for IoPort
blocking, BlockedOnIoCompletion
, as well as drop the non-threaded RTS's special dead-lock detection logic (which is redundant to the GC's deadlock detection logic), as proposed in #20947 (closed).
Previously WinIO relied on foreign import ccall "wrapper"
to create an adjustor thunk which can be attached to the OVERLAPPED
structure passed to the operating system. It would then use foreign import ccall "dynamic"
to back out the original continuation from the adjustor. This roundtrip is significantly more expensive than the alternative, using a StablePtr
. Furthermore, the implementation let the adjustor leak, meaning that every IO request would leak a page of memory.