Skip to content

Commit a565206

Browse files
authored
Change validation to reject stream<char> (for now) (#607)
1 parent 7bf12e0 commit a565206

5 files changed

Lines changed: 12 additions & 3 deletions

File tree

design/mvp/Binary.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ Notes:
253253
rejects any transitive use of `borrow` in an exported value type.
254254
* Validation of `stream` and `future` rejects element types that transitively
255255
contain a `borrow`.
256+
* Validation of `stream` rejects `(stream char)` as a temporary
257+
[TODO](Concurrency.md#TODO).
256258
* Validation of `resourcetype` requires the destructor (if present) to have
257259
type `[i32] -> []`.
258260
* Validation of `instancedecl` (currently) only allows the `type` and

design/mvp/CanonicalABI.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4210,8 +4210,11 @@ Then a readable or writable buffer is created which (in `Buffer`'s constructor)
42104210
eagerly checks the alignment and bounds of (`i`, `n`). (In the future, the
42114211
restriction on futures/streams containing `borrow`s could be relaxed by
42124212
maintaining sufficient bookkeeping state to ensure that borrowed handles *or
4213-
streams/futures of borrowed handles* could not outlive their originating call.)
4213+
streams/futures of borrowed handles* could not outlive their originating call.
4214+
Additionally, `stream<char>` will be allowed and defined to encode and decode
4215+
according to the `string-encoding`.)
42144216
```python
4217+
assert(not isinstance(stream_t, CharType))
42154218
assert(not contains_borrow(stream_t))
42164219
cx = LiftLowerContext(opts, thread.task.inst, borrow_scope = None)
42174220
buffer = BufferT(stream_t.t, cx, ptr, n)

design/mvp/Concurrency.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,8 @@ comes after:
12591259
* remove the temporary trap mentioned above that occurs when a `read` and
12601260
`write` of a stream/future happen from within the same component instance
12611261
* zero-copy forwarding/splicing
1262+
* allow the `stream<char>` type to validate; make it use `string-encoding`
1263+
and not split code points
12621264
* some way to say "no more elements are coming for a while"
12631265
* add an `async` effect on `component` type definitions allowing a component
12641266
type to block during instantiation
@@ -1270,8 +1272,6 @@ comes after:
12701272
* add a `strict-callback` option that adds extra trapping conditions to
12711273
provide the semantic guarantees needed for engines to statically avoid
12721274
fiber creation at component-to-component `async` call boundaries
1273-
* add `stringstream` specialization of `stream<char>` (just like `string` is
1274-
a specialization of `list<char>`)
12751275
* allow pipelining multiple `stream.read`/`write` calls
12761276
* allow chaining multiple async calls together ("promise pipelining")
12771277
* integrate with `shared`: define how to lift and lower functions `async` *and*

design/mvp/Explainer.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,9 @@ empty futures and streams can be useful for timing-related APIs.
753753
Currently, validation rejects `(stream T)` and `(future T)` when `T`
754754
transitively contains a `borrow`. This restriction could be relaxed in the
755755
future by extending the call-scoping rules of `borrow` to streams and futures.
756+
Additionally, `(stream char)` is temporarily rejected with a future
757+
[TODO](Concurrency.md) to allow and properly use the `string-encoding`,
758+
taking care to not split code points.
756759

757760
#### Specialized value types
758761

design/mvp/canonical-abi/definitions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,6 +2362,7 @@ def stream_copy(EndT, BufferT, event_code, stream_t, opts, thread, i, ptr, n):
23622362
trap_if(e.shared.t != stream_t.t)
23632363
trap_if(e.state != CopyState.IDLE)
23642364

2365+
assert(not isinstance(stream_t, CharType))
23652366
assert(not contains_borrow(stream_t))
23662367
cx = LiftLowerContext(opts, thread.task.inst, borrow_scope = None)
23672368
buffer = BufferT(stream_t.t, cx, ptr, n)

0 commit comments

Comments
 (0)