Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions quest/m2/ts-async.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ A handoff through 1, 4, and 16 async functions measured 1.5-2.7x faster than #16
generators in Node, 1.8-5.5x in Bun, and 1.4-3.5x in Chrome, and past depth 1 faster
than moq's hand-written promises. `rt.spawn` stays.

std's future helpers translate: `Poll`'s methods, `pin!`, `poll_fn`, `future::pending`,
std's future helpers translate: `Poll`'s methods, `Poll<Poll<T>>`, `pin!`, `poll_fn`, `future::pending`,
`Waker::from(Arc<W>)`, and `Waker::noop`, and so do `Box::pin` and `dyn Future`. What
moq-net still needs, by its census from MIR at the pinned revision:

- Async closures, which only moq-net's tests write today.
- kio's own API, reached across crates (`Pending`, `Consumer::poll`,
`Waiter::poll_future`, `Tasks`), translates from source as a
[dependency](/ts/README.md), and kio's `RawWaker` vtable and
`Box<dyn FnMut>` tasks are [bindings](/ts/README.md#bindings).
- kio's `Tasks`, whose `RawWaker` vtable and `Box<dyn FnMut>` tasks are
[bindings](/ts/README.md#bindings). The rest of kio's API translates from source
across crates; what it still refuses is std's.
- The edge: `rt.spawn`'s shape for callers, and cancelling a spawned task.

An async block that captures part of a variable, which THIR refused 47 times, is a
Expand Down
7 changes: 7 additions & 0 deletions ts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ crate translation reaches is refused, and so are two versions of one crate it re
| `enum` | a union of objects tagged by variant |
| `Option<T>` | `T \| undefined`; `T \| rt.None` where `T` can already be `undefined`, as `()` and `Option` can, so `Option<()>` and `Option<Option<u64>>` keep `None` apart from each `Some` |
| `Result<T, E>` | `rt.Result<T, E>`: `{ ok: true, value }` or `{ ok: false, error }`; `rt.OK` or `rt.ERR` where the payload is `undefined`, as in `Ok(())` |
| `ControlFlow<B, C>` | `rt.Result<C, B>`, `Ok` to continue; what `?` branches on is the value it was applied to |
| `ControlFlow<B, C>` | `rt.Result<C, B>`, `Ok` to continue; what `?` branches on is the value it was applied to, but for a `Poll`'s `Pending` and `Ready(None)`, which continue as `Ok` of themselves |
| tuple, `[T; N]`, `&[T]`, `Vec<T>` | an array; for bytes, `Uint8Array` for `[u8; N]`, `rt.ByteSlice` for `&[u8]` and `&[u8; N]`, and `rt.ByteVec` for `Vec<u8>` |
| `&T`, `&mut T`, `Box<T>`, `Reverse<T>`, `NonZero<T>` | the value; a `&mut` to a value JS copies, such as a number, an `Option`, or a `String`, is an `rt.Place<T>` |
| an iterator | `rt.Iter<Item>`, whose adaptors are runtime functions: `rt.iterMap(rt.iterSlice(v), f)` |
Expand All @@ -104,7 +104,7 @@ crate translation reaches is refused, and so are two versions of one crate it re
| `OnceCell<T>`, `OnceLock<T>` | `rt.OnceCell` and `rt.OnceLock`, holding the `Option<T>` in `v`; a `OnceLock` initialized from within its own initialization panics, as wasm32's does |
| `AtomicU32` and the others of `bool` and integers | `rt.Atomic<T>`, the `rt.Place` of its value; an `atomic::Ordering` is its discriminant, and one an operation can't take panics as std's does |
| `async fn` | a function returning `rt.Future<T>`: a class of its own, its coroutine's state machine |
| `Poll<T>`, `Waker`, `Context` | `T \| typeof rt.Pending`, refused if `T` can already be pending; `rt.Waker`, which is also the context |
| `Poll<T>`, `Waker`, `Context` | `T \| typeof rt.Pending`; `T \| rt.OuterPending` where `T` can already be pending, as `Poll<Poll<u8>>` can, so `Ready(Pending)` keeps apart from `Pending`; `rt.Waker`, which is also the context |
| `pin!(x)`, `poll_fn(f)`, `future::pending()` | `x`; `rt.PollFn`, which drops `f` with itself; `rt.NEVER` |
| `Box::pin(x)`, `dyn Future<Output = T>` | `x`; `rt.Future<T>`: an `async` body or std's future as it is, and another future as an `rt.DynFuture` over its `poll`, which drops it with itself unless borrowed |
| `bytes::Bytes` | `rt.ByteSlice`, as `&[u8]` is: its clones and slices share bytes that never change |
Expand Down Expand Up @@ -504,7 +504,7 @@ they need.
`Box`, or `Arc` ([trait objects](/quest/m3/ts-dyn.md)), fail translation. Until they translate, an item that needs one, such as a boxed closure, binds to
hand-written TS ([bindings](#bindings)).

These fail translation: formatting and parsing an `f64`, and `f64::clamp`, whose panic formats them ([float formatting](/quest/m2/ts-model/floats.md)), `f32` ([`f32`](/quest/m3/ts-f32.md)), statics, async closures, a closure that owns a value
These fail translation: formatting and parsing an `f64`, and `f64::clamp`, whose panic formats them ([float formatting](/quest/m2/ts-model/floats.md)), `f32` ([`f32`](/quest/m3/ts-f32.md)), statics, async closures, a `Poll` of a `Poll` of a `Poll`, a future whose output can be pending, an instance of a generic type whose field is a `Poll` of a type parameter that can be pending, a closure that owns a value
that drops given to a std function that drops it beside another value that drops, as
`for_each` of items that drop does, or keeps it other than in an iterator adaptor, and
values that drop in some iterators ([drop order](/quest/m3/ts-drop-order.md)), a `Cow` of other than `str`,
Expand Down Expand Up @@ -570,9 +570,11 @@ built natively for wasm32 and run beside its translation on the same inputs by
`lang`'s other writes into the same type would hide a write the analysis misses: a
byte array overwritten whole through a type parameter, or, under its features, by std
called directly or through a pointer a generic function calls.
- `task` trims moq's kio to a channel of `Arc`ed state, waiters, and wakers, under async
functions and std's future helpers, with wakers of the crate's `Wake` impls, beside
values that drop inside std's types. Its caller is hand-written TS (`tests/task.ts`): a FIFO executor that runs a
- `task` trims moq's kio to a dependency of its own, `kio`, reached across crates as moq-net
reaches kio: a channel of `Arc`ed state, waiters, and wakers, kio's `Task`, `Pending`, and
`Waiter::poll_future`, and a `Consumer::poll` whose closure is itself pending, a
`Poll<Poll<_>>`. Async functions and std's future helpers run over it, with wakers of
the crate's `Wake` impls, beside values that drop inside std's types. Its caller is hand-written TS (`tests/task.ts`): a FIFO executor that runs a
script of spawns, sends, polls, and drops, and logs every poll, wake, and drop, as the
fixture's native executor does. The logs must match byte for byte. `tests/unwind.ts`
also runs the scripts natively on the host (`examples/unwind.rs`), where a panic
Expand Down
49 changes: 35 additions & 14 deletions ts/fixtures/reject/census.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Census of `reject-fixture`

- Refusals: 74
- Function instances: 84
- Refusals: 77
- Function instances: 88
- Generic functions no instance reached, lowered over their type parameters: 6

## By construct
Expand All @@ -11,9 +11,9 @@
| 11 | unsupported call to `_` | fixtures/reject/src/lib.rs:21:4 |
| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:382:2 |
| 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:101:2 |
| 3 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:257:14 |
| 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:85:2 |
| 3 | unsupported type `_` | fixtures/reject/src/lib.rs:7:14 |
| 2 | `_` is not supported: it would be pending two ways with one value | fixtures/reject/src/lib.rs:105:20 |
| 2 | `_` is not supported: its `None` and `Some` would both be `rt.None` | fixtures/reject/src/lib.rs:16:15 |
| 2 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | fixtures/reject/src/lib.rs:41:42 |
| 2 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | fixtures/reject/src/lib.rs:247:16 |
Expand All @@ -26,7 +26,9 @@
| 1 | `Bytes::from_owner` of `_`, which would drop with the last clone of what it makes, which is not supported | fixtures/reject/src/lib.rs:425:2 |
| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:68:2 |
| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:393:18 |
| 1 | `_` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` | fixtures/reject/src/lib.rs:105:20 |
| 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `None` would be `rt.None` as `_` | fixtures/reject/src/lib.rs:31:2 |
| 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `Pending` would be `rt.OuterPending` as `_` | fixtures/reject/src/lib.rs:517:2 |
| 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:286:6 |
| 1 | `_` of `_`, which drops `_`, which is not supported yet | fixtures/reject/src/lib.rs:53:13 |
| 1 | `_` through a held type's own, which is not supported yet | fixtures/reject/src/lib.rs:318:2 |
Expand All @@ -38,7 +40,7 @@
| 1 | a cast from `_` to `_` | fixtures/reject/src/lib.rs:96:2 |
| 1 | a coercion to `_` | fixtures/reject/src/lib.rs:341:2 |
| 1 | a constant of type `_` | fixtures/reject/src/lib.rs:80:2 |
| 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:257:14 |
| 1 | a future of `_`, which can be `rt.Pending`, as the future's own `Pending` is | fixtures/reject/src/lib.rs:110:34 |
| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:226:13 |
| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:413:12 |
| 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:92:1 |
Expand Down Expand Up @@ -88,18 +90,22 @@ The type or module each refused type or path belongs to.
| 1 | `Noisy` | fixtures/reject/src/lib.rs:53:13 |
| 1 | `T \| undefined` | fixtures/reject/src/lib.rs:31:2 |
| 1 | `Tail` | fixtures/reject/src/lib.rs:506:30 |
| 1 | `Waiting` | fixtures/reject/src/lib.rs:517:2 |
| 1 | `[u16; 1]` | fixtures/reject/src/lib.rs:240:22 |
| 1 | `[u8; 4]` | fixtures/reject/src/lib.rs:496:26 |
| 1 | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 |
| 1 | `f64` | fixtures/reject/src/lib.rs:454:2 |
| 1 | `into_keys` | fixtures/reject/src/lib.rs:53:13 |
| 1 | `poll` | fixtures/reject/src/lib.rs:517:2 |
| 1 | `rt.Poll` | fixtures/reject/src/lib.rs:517:2 |
| 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:172:51 |
| 1 | `std::iter::Rev` | fixtures/reject/src/lib.rs:166:14 |
| 1 | `std::option::Option` | fixtures/reject/src/lib.rs:420:2 |
| 1 | `std::slice::Iter` | fixtures/reject/src/lib.rs:126:11 |
| 1 | `std::string::String` | fixtures/reject/src/lib.rs:74:10 |
| 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:121:2 |
| 1 | `std::sync::Weak` | fixtures/reject/src/lib.rs:470:40 |
| 1 | `std::task::Poll` | fixtures/reject/src/lib.rs:110:34 |
| 1 | `str` | fixtures/reject/src/lib.rs:377:4 |
| 1 | `u32` | fixtures/reject/src/lib.rs:226:13 |
| 1 | `u64` | fixtures/reject/src/lib.rs:96:2 |
Expand All @@ -112,15 +118,16 @@ The type or module each refused type or path belongs to.
| ---: | --- | --- | --- |
| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:382:2 |
| 3 | unsupported type `_` | `f32` | fixtures/reject/src/lib.rs:7:14 |
| 2 | `_` is not supported: it would be pending two ways with one value | `Poll` | fixtures/reject/src/lib.rs:105:20 |
| 2 | `_` is not supported: its `None` and `Some` would both be `rt.None` | `Option` | fixtures/reject/src/lib.rs:16:15 |
| 2 | `_`, a trait object of the generic trait `_`, which is not supported yet | `dyn Scaled`, `Scaled` | fixtures/reject/src/lib.rs:479:23 |
| 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:116:2 |
| 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:85:2 |
| 2 | unsupported call to `_` | `<std::vec::IntoIter as std::iter::Iterator>::sum` | fixtures/reject/src/lib.rs:444:17 |
| 1 | `Bytes::from_owner` of `_`, which would drop with the last clone of what it makes, which is not supported | `std::sync::Arc` | fixtures/reject/src/lib.rs:425:2 |
| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:393:18 |
| 1 | `_` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` | `Poll` | fixtures/reject/src/lib.rs:105:20 |
| 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `None` would be `rt.None` as `_` | `Maybe`, `value`, `Option`, `T \| undefined`, `Option` | fixtures/reject/src/lib.rs:31:2 |
| 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `Pending` would be `rt.OuterPending` as `_` | `Waiting`, `poll`, `Poll`, `rt.Poll`, `Poll` | fixtures/reject/src/lib.rs:517:2 |
| 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:286:6 |
| 1 | `_` of `_`, which drops `_`, which is not supported yet | `into_keys`, `std::collections::HashMap`, `Noisy` | fixtures/reject/src/lib.rs:53:13 |
| 1 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | `HashMap::get`, `Option` | fixtures/reject/src/lib.rs:263:6 |
Expand All @@ -137,6 +144,7 @@ The type or module each refused type or path belongs to.
| 1 | a coercion to `_`, which is not supported yet | `&Tail` | fixtures/reject/src/lib.rs:506:30 |
| 1 | a coercion to `_`, which is not supported yet | `std::sync::Weak` | fixtures/reject/src/lib.rs:470:40 |
| 1 | a constant of type `_` | `&u8` | fixtures/reject/src/lib.rs:80:2 |
| 1 | a future of `_`, which can be `rt.Pending`, as the future's own `Pending` is | `std::task::Poll` | fixtures/reject/src/lib.rs:110:34 |
| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | `u32` | fixtures/reject/src/lib.rs:226:13 |
| 1 | a scalar constant of type `_` | `f32` | fixtures/reject/src/lib.rs:8:2 |
| 1 | a trait object of `_`, which is not supported yet | `[u8; 4]` | fixtures/reject/src/lib.rs:496:26 |
Expand Down Expand Up @@ -205,6 +213,14 @@ The type or module each refused type or path belongs to.

</details>

<details><summary>a copy of a closure that changes what it captured (3)</summary>

- fixtures/reject/src/lib.rs:257:14: a copy of a closure that changes what it captured
- fixtures/reject/src/lib.rs:529:14: a copy of a closure that changes what it captured
- fixtures/reject/src/lib.rs:530:14: a copy of a closure that changes what it captured

</details>

<details><summary>replacing the value behind a reference to `_` (3)</summary>

- fixtures/reject/src/lib.rs:85:2: replacing the value behind a reference to `Meters`
Expand All @@ -221,13 +237,6 @@ The type or module each refused type or path belongs to.

</details>

<details><summary>`_` is not supported: it would be pending two ways with one value (2)</summary>

- fixtures/reject/src/lib.rs:105:20: `Poll<std::option::Option<std::task::Poll<u8>>>` is not supported: it would be pending two ways with one value
- fixtures/reject/src/lib.rs:110:54: `Poll<std::task::Poll<u8>>` is not supported: it would be pending two ways with one value

</details>

<details><summary>`_` is not supported: its `None` and `Some` would both be `rt.None` (2)</summary>

- fixtures/reject/src/lib.rs:16:15: `Option<std::option::Option<std::option::Option<u8>>>` is not supported: its `None` and `Some` would both be `rt.None`
Expand Down Expand Up @@ -309,12 +318,24 @@ The type or module each refused type or path belongs to.

</details>

<details><summary>`_` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` (1)</summary>

- fixtures/reject/src/lib.rs:105:20: `Poll<std::option::Option<std::task::Poll<std::task::Poll<u8>>>>` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending`

</details>

<details><summary>`_` is not supported: its field `_` is `_`, typed `_`, whose `None` would be `rt.None` as `_` (1)</summary>

- fixtures/reject/src/lib.rs:31:2: `Maybe<()>` is not supported: its field `value` is `Option<T>`, typed `T | undefined`, whose `None` would be `rt.None` as `Option<()>`

</details>

<details><summary>`_` is not supported: its field `_` is `_`, typed `_`, whose `Pending` would be `rt.OuterPending` as `_` (1)</summary>

- fixtures/reject/src/lib.rs:517:2: `Waiting<std::task::Poll<u8>>` is not supported: its field `poll` is `Poll<T>`, typed `rt.Poll<T>`, whose `Pending` would be `rt.OuterPending` as `Poll<std::task::Poll<u8>>`

</details>

<details><summary>`_` of `_` by `_`, which is not supported yet (1)</summary>

- fixtures/reject/src/lib.rs:286:6: `HashMap::contains_key` of `std::collections::HashMap<Id, u8>` by `u8`, which is not supported yet
Expand Down Expand Up @@ -381,9 +402,9 @@ The type or module each refused type or path belongs to.

</details>

<details><summary>a copy of a closure that changes what it captured (1)</summary>
<details><summary>a future of `_`, which can be `rt.Pending`, as the future's own `Pending` is (1)</summary>

- fixtures/reject/src/lib.rs:257:14: a copy of a closure that changes what it captured
- fixtures/reject/src/lib.rs:110:34: a future of `std::task::Poll<u8>`, which can be `rt.Pending`, as the future's own `Pending` is

</details>

Expand Down
7 changes: 5 additions & 2 deletions ts/fixtures/reject/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ a constant of type `&u8` at fixtures/reject/src/lib.rs:80:2
replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:85:2
replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:89:2
an assignment through a reference to `std::sync::Arc<u8>` at fixtures/reject/src/lib.rs:101:2
`Poll<std::option::Option<std::task::Poll<u8>>>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:105:20
`Poll<std::task::Poll<u8>>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:110:54
`Poll<std::option::Option<std::task::Poll<std::task::Poll<u8>>>>` is not supported: its `Pending` and `Ready` would both be `rt.OuterPending` at fixtures/reject/src/lib.rs:105:20
a future of `std::task::Poll<u8>`, which can be `rt.Pending`, as the future's own `Pending` is at fixtures/reject/src/lib.rs:110:34
an assignment through a reference to `std::pin::Pin<std::sync::Arc<u8>>` at fixtures/reject/src/lib.rs:116:2
an assignment through a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:121:2
unsupported call to `<std::slice::Iter<'_, u8> as std::iter::Iterator>::cycle` at fixtures/reject/src/lib.rs:126:11
Expand Down Expand Up @@ -66,6 +66,9 @@ a coercion to `std::sync::Weak<dyn Reading>`, which is not supported yet at fixt
`dyn Scaled<u8>`, a trait object of the generic trait `Scaled`, which is not supported yet at fixtures/reject/src/lib.rs:480:4
a trait object of `[u8; 4]`, which is not supported yet at fixtures/reject/src/lib.rs:496:26
a coercion to `&Tail<dyn Reading>`, which is not supported yet at fixtures/reject/src/lib.rs:506:30
`Waiting<std::task::Poll<u8>>` is not supported: its field `poll` is `Poll<T>`, typed `rt.Poll<T>`, whose `Pending` would be `rt.OuterPending` as `Poll<std::task::Poll<u8>>` at fixtures/reject/src/lib.rs:517:2
a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:529:14
a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:530:14
overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:139:2
an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:159:1
overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:193:2
Expand Down
Loading