Start implementing stream internal slots and algos#32730
Start implementing stream internal slots and algos#32730gterzian merged 29 commits intoservo:readablestream-re-implementationfrom
Conversation
a5afb8f to
2fa3292
Compare
6906fa1 to
c50f7f3
Compare
585110e to
1daab8d
Compare
|
🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync. |
1daab8d to
9d7f4aa
Compare
Signed-off-by: gterzian <[email protected]>
Signed-off-by: gterzian <[email protected]>
Signed-off-by: gterzian <[email protected]>
Signed-off-by: gterzian <[email protected]>
Signed-off-by: gterzian <[email protected]>
|
Ok, I also turned-off the old streams, fixed some things, and as a kind of milestone, https://github.com/servo/servo/blob/496ce717c5343984e0f3da00d223604eff03893c/tests/wpt/tests/fetch/api/basic/stream-response.any.js is now passing again(which covers part of the "native" streaming I handled in this PR). So I'd say let review and merge this one, so that work can resume in parallel on:
|
|
I'll try to take a look at this tonight! |
Doesn't that mean that readable-streams test's are run (not skipped)? |
|
|
||
| pub fn enqueue_chunk(&self, mut chunk: Vec<u8>) { | ||
| let mut buffer = self.buffer.borrow_mut(); | ||
| chunk.append(&mut buffer); |
There was a problem hiding this comment.
Doesn't this push the existing buffer onto the end of the newest chunk?
There was a problem hiding this comment.
Yes that seems to be the case.
On this and the comment below: I looked into this and actually we should re-structure this queue concept to allow to any JS value being a chunk, a first step of which I have done in the last commit. There is still a "native" chunk variant, which I guess we could optimize.
| /// <https://streams.spec.whatwg.org/#readablestreamgenericreader-stream> | ||
| stream: Dom<ReadableStream>, | ||
|
|
||
| #[ignore_malloc_size_of = "Rc is hard"] |
There was a problem hiding this comment.
nit: There are no Rc values involved in this field.
There was a problem hiding this comment.
The read request contains a Rc<Promise>.
| let cx = GlobalScope::get_cx(); | ||
| rooted!(in(*cx) let mut underlying_source_dict = UndefinedValue()); | ||
| if let UnderlyingSourceType::Js(ref js_source) = underlying_source_type { | ||
| #[allow(unsafe_code)] |
There was a problem hiding this comment.
nit: it makes more sense to have this annotation at the method level.
| impl ReadRequest { | ||
| /// <https://streams.spec.whatwg.org/#read-request-chunk-steps> | ||
| #[allow(unsafe_code)] | ||
| #[allow(crown::unrooted_must_root)] |
There was a problem hiding this comment.
I was able to remove it by avoiding to assign the read result to a temporary variable.
There was a problem hiding this comment.
I was able to remove it by avoiding to assign the read result to a temporary variable.
| rooted!(in(*cx) let mut rval = UndefinedValue()); | ||
| let result = RootedTraceableBox::new(Heap::default()); | ||
| result.set(*rval); | ||
| let result = ReadableStreamReadResult { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
yes but the byte stream stuff is in a separate folder, at https://github.com/servo/servo/tree/main/tests/wpt/tests/streams/readable-byte-streams, so we were never running them. |
| #[allow(crown::unrooted_must_root)] | ||
| struct PullAlgorithmFulfillmentHandler { | ||
| controller: DomRoot<ReadableStreamDefaultController>, | ||
| controller: Dom<ReadableStreamDefaultController>, |
There was a problem hiding this comment.
I don't think this is safe, since these structs aren't visible to the GC. That's why I recommend Trusted here.
There was a problem hiding this comment.
That's why I recommend Trusted here.
I just tried it and it breaks Callback: JSTraceable + MallocSizeOf .
these structs aren't visible to the GC
But they end-up on the PromiseNativeHandler, which is a dom_struct.
There was a problem hiding this comment.
I've strengthened this by keeping the controller rooted while the native promise handler is setup.
|
b65ba8d is how I would support dictionary callback values. |
78e562b to
d02783b
Compare
I thought this PR would be merged earlier so I was waiting for it. Byte controller and reader is pretty similar to default one. So I believe once we have done the default ones, the byte part will be faster. I'll review the PR again pretty soon. |
There was a problem hiding this comment.
@jdm @gterzian Could we merge this today? I believe @gterzian mentioned we could do more aggressive mergine since this is targeted to the feature branch.
There are some trivial improvements like EnqueuedValue and maybe QueueWithSize should share with byob controller. But I think it could wait for there's PR for such controller implementation.
Edit: I also hope we can update the feature branch to catch up main branch since there are some more commit over weeks.
|
Ok let's do it! @jdm I have addressed all of your comments, although I still had a few questions(about the rooting), but this had been noted in a TODO as needed to revisit... |
./mach build -ddoes not report any errors./mach test-tidydoes not report any errors